Ajax not work on primefaces selectManyCheckbox with converter

638 Views Asked by At

I'm trying to use primefaces selectManyCheckBox with ajax and converter, but the ajax not fired. If I'm didn't use converter, the ajax can fired. Is there something wrong with my converter?

<div class="form-group">
    <p:outputLabel value="Atur Grade Pinjaman" for="gradePinjaman"/>        
    <p:selectManyCheckbox id="gradePinjaman" value="#{autoInvestController.param.grades}" converter="companyGradeConverter">
        <f:selectItems value="#{autoInvestController.grades}" var="grade" itemLabel="#{grade.id}" itemValue="#{grade}"/>                        
        <p:ajax update="selectAll estimation" listener="#{autoInvestController.valueChange}"/>
    </p:selectManyCheckbox>                
    <p:message for="gradePinjaman"/>
</div>

Here is my backing bean code

public void valueChange() {     
    if (param.getGrades() != null && !param.getGrades().isEmpty()) {
        checkAll = param.getGrades().size() == grades.size();
        calculateCollectEstimation();
    }
}

Here is my converter

@Override
public Object getAsObject(FacesContext context, UIComponent component, String value) {        
    if (Strings.isNullOrEmpty(value)) {
        return null;
    } else {
        try {
            PlatformService platformService = (PlatformService) CDI.current().select(PlatformService.class).get();
            Map<String, Object> param = new HashMap<>();
            param.put("id", value);
            CompanyGradeResponse companyGrade = platformService.getCompanyGrade(param).get(0);                
            return companyGrade;
        } catch (EndpointException e) {
            LOG.error(e.getMessage(), e);
            return null;
        }            
    }
}

@Override
public String getAsString(FacesContext context, UIComponent component, Object value) {        
    if (value != null) {
        return ((CompanyGradeResponse) value).getId();
    } else {
        return null;
    }
}

I think my converter work well, but why the ajax won't fired when i check the checkbox?

Thanks

0

There are 0 best solutions below