2013-06-03 43 views
0

我正在迁移我的项目从seam 2JSF 2.xJSF 2,noSelectionOption与转换器,不工作,因为它应该

缝2,枚举的,我们有

<s:convertEnum /> 

当选择正确的值不是noSelectionOption值将调用转换器。

JSF 2.x的我创建了像

@Named("enumConverter") 
@ApplicationScoped 
public class EnumConverter implements Converter { 

public Object getAsObject(FacesContext context, UIComponent component, String key) 
     throws ConverterException { 
if(!key.equalsIgnoreCase("-- Choose one --")){ 
    // DO LOGIC 
} 
return null; 
} 

public String getAsString(FacesContext context, UIComponent component, Object object) { 
} 

现在我的自定义转换器的问题,我认为我使用 转换器像

<h:selectOneMenu value="#{user.DocumentType}" required="true"> 
     <f:selectItem itemLabel="-- Choose one --" itemValue="#{null}" noSelectionOption="true"/> 
     <f:selectItems value="${user.Constants(user.statuses)}" 
      var="Val" itemLabel="#{user.Display(Val)}" 
     /> 
     <f:converter converterId="enumConverter"></f:converter> 
    </h:selectOneMenu> 

这儿如果我选择NoSelectionOption然后我的转换器正在调用,,,这不应该发生,只有在需要正确值时才应该调用

仅在接缝2转换器的情况下,如果选择了正确的值,则只有转换器将被调用,否则将调用“需要值”被显示。

请请告诉我,我在这里失踪.... 提前欣赏和帮助......

感谢

回答

0

上述问题A4J是由于:commandlink其为具有重新解析属性,我用render属性替换它,现在消息正在显示。

但现在的问题是

*如果需要的话=真是不存在的,我选择noSelectionOption那么它将存储在数据库空值。 是它必要noSelectionOption提供验证JSF 2 ????

谢谢

相关问题