JSF验证错误

时间:2017-04-17 15:05:54

标签: validation jsf netbeans xhtml

我的转换器:

@ManagedBean
@RequestScoped
@FacesConverter("tr.com.java.efaturaportal.util.converters.IndividualInstitutionalTypeConverter")
public class IndividualInstitutionalTypeConverter implements Converter{

    @Override

    public Object getAsObject(FacesContext context, UIComponent component, String value)
    {

            IndividualInstitutionalType inditype = new IndividualInstitutionalType();

            if ("Client".equals(value)){
                inditype.setName("Client");
                inditype.setDescription("Müşteri");

            }
            else {
                inditype.setName("Supplier");
                inditype.setDescription("Tedarikçi");       
            }
            return inditype;
    }

    @Override
    public String getAsString(FacesContext context, UIComponent component, Object value) 
    {
        if (value!= null) {
            IndividualInstitutionalType inditype = (IndividualInstitutionalType) value;

            return inditype.getName();
        }

        return null;
    }
}

我的xhtml:

<div class="form-group">
    <h:outputLabel value="Türü: " for="Type"/>               
    <h:selectOneMenu id="Type"  value="#{clientSupplierAddBean.clientsupplier.individualInstitutionalType}" 
                      class="form-control" required="true" requiredMessage="Tüzel yada Gerçek Kişi Türü Boş Geçilemez">               

        <!--In here we are using converter for individualInstituationalType  -->

        <f:converter converterId="tr.com.java.efaturaportal.util.converters.IndividualInstitutionalTypeConverter"/>

<!--                        <f:selectItem itemValue="Client"
                      itemLabel="Müşteri" />                

        <f:selectItem itemValue="Supplier"
                      itemLabel="Tedarikçi" />-->

        <f:selectItems value="#{clientSupplierAddBean.availableItems}" var="v" itemValue="#{v}" itemLabel="#{v.description}" />

        <f:passThroughAttribute name="placeHolder" value="Tür Giriniz"/>
    </h:selectOneMenu>            
</div> 

任何帮助表示赞赏

0 个答案:

没有答案