Search code examples
jsficefacesjsf-1.2

Why conversion is not skipped?


I have two input components on my page. Each of them has a converter (It's a converter which checks for empty values, like JSF required one, but for some reasons I cannot use jsf one so I've made my own converter).

I also have a ice:selectBooleanCheckbox:

<ice:selectBooleanCheckbox
                    styleClass="graUserAppUserGroupAddChk"
                    value="#{userGroupTableNewRecordBean.addNewDomain}"
                    partialSubmit="true"
                    immediate="true"
                    valueChangeListener="#{userGroupTableNewRecordBean.addDomainListener}"></ice:selectBooleanCheckbox>

As you see I put immediate=true attribute on it, becase when I select this checkbox I do want the conversion phase to be skipped but it does not work, the converters still show their warnings. Do you know why?

I also add a valueChangeListener on this checkbox and called there the renderResponse directly, based on this quote:

So in the value changed listener method for the dropdown lists, just 

call renderResponse() from the FacesContext object and validation and conversion is bypassed and you can still do what you want.

public void addDomainListener(final ValueChangeEvent valueChangeEvent) {
    // skip validation
    logger.info("listener calleddddddddddddd");
    FacesContext.getCurrentInstance().renderResponse();
}

Maybe a JSF guru can help?

Thanks a lot...

UPDATE: I know that a solution would be to put the checkbox in a separate form but I cannot afford this...

UPDATE 2: I've corrected some code about listener, so now it is called when clicked but still the converter fails and render response phase is not done...

UPDATE 3: This is not an icefaces issue... I've tried with a h:selectBooleanCheckbox and it happens the same...


Solution

  • Solved it finally...

    I post here the sum up of the question and the solution.

    I had a checkbox in my popup. When I select it I want to show some hidden fields but this did not work because I also had two required fields on the same page so jsf PROCESS_VALIDATIONS phase came up...

    I thought that putting immediate=true will solve this, but it did not...

    So, in my ValueChangeListener of the checkbox I had to manually skip the jsf validation phase:

    public void addDomainListener(final ValueChangeEvent valueChangeEvent) {
            // skip validation
            final PhaseId phaseId = valueChangeEvent.getPhaseId();
            final Boolean newValue = (Boolean) valueChangeEvent.getNewValue();
            if (phaseId.equals(PhaseId.ANY_PHASE)) {
                valueChangeEvent.setPhaseId(PhaseId.UPDATE_MODEL_VALUES);
                valueChangeEvent.queue();
    
                this.addNewDomain = newValue;
                FacesContext.getCurrentInstance().renderResponse();
            }
        }