警告:@FacesConverter同时使用value和forClass,仅应用值

时间:2013-09-25 09:18:36

标签: jsf jsf-2 warnings converter omnifaces

我安装了OmniFaces 1.6,并创建了带注释的类@FacesConverter(forClass=MyClass.class)

在GlassFish项目部署期间,我有几个问题:

INFO: Initialisation de Mojarra 2.2.2 ( 20130809-1625 https://svn.java.net/svn/mojarra~svn/tags/2.2.2@12376) pour le contexte «/ErpCCFWEB»
WARNING: @FacesConverter is using both value and forClass, only value will be applied.
WARNING: @FacesConverter is using both value and forClass, only value will be applied.
WARNING: @FacesConverter is using both value and forClass, only value will be applied.
WARNING: @FacesConverter is using both value and forClass, only value will be applied.
WARNING: @FacesConverter is using both value and forClass, only value will be applied.
INFO: Running on PrimeFaces 4.0.RC1

我有3个带注释的类,其中一个是以下内容:

@FacesConverter(forClass = Commune.class)
public class CommuneConverter implements Converter {

    private static final Logger LOG = Logger.getLogger(CommuneConverter.class.getName());
    @EJB
    private ReferentielDaoLocal myService;
    @Override
    public Object getAsObject(FacesContext context, UIComponent component, String value) {
        if (value == null) {
            return null;
        } else {
            try {
               // ReferentielDaoLocal myService = (ReferentielDaoLocal) new InitialContext().lookup("java:global/ErpCCF/ErpCCF-ejb/ReferentielDaoImpl");
                return myService.findCommuneByCode(value);
            } catch (Exception ex) {
                LOG.log(Level.SEVERE, "Converter Commune Error", ex.getMessage());
                return null;
            }

        }
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) {
        if (value == null) {
            return null;
        } else {
            return String.valueOf(((Commune) value).getIdCommune());
        }
    }
}

1 个答案:

答案 0 :(得分:4)

根据this

  

警告特定于Mojarra,与OmniFaces完全无关。这已在Mojarra 2.1.26修复:https://java.net/jira/browse/JAVASERVERFACES-2987

跟踪器还包括2.2.3作为修复版本,因此您可以尝试一下。