0
votes

I am unsing JSF 1.2 with the richfaces implementation. What I am trying to do is to enable a selectOneRadio when a selectBooleanCheckbox is checked. It works so far. But there is a strange effect:

Consider following situation: Field selectA shows an error-Message in its rich:message tag. After checking myCheckbox selectOneRadio selectToReRender is enabled but the error message in all rich-message tags on the page disappear.

Thanks for your Help.

Regards,

Max

<!-- Field which shows error-Message if vlaue was not entered -->
<h:selectOneRadio id="selectA" 
                  value ="#{controller.entity.valueA}"
                  required="true"
                  label="#{text['selectA.label']}"
                  layout="pageDirection">
    <f:selectItem itemValue="#{true}" itemLabel="Yes" />
    <f:selectItem itemValue="#{false}" itemLabel="No"/>
</h:selectOneRadio>

<rich:message for="selectA"/>



<!-- Field which enables selectOneRadio selectToReRender if it is checked -->
<h:selectBooleanCheckbox id="myCheckbox" 
                         label="#{text['myCheckbox.label']}"
                         value="#{controller.entity.valueB}" 
                         required="false">
    <a4j:support event="onclick" ajaxSingle="true" reRender="selectToReRender"/>
</h:selectBooleanCheckbox>
<rich:message for="myCheckbox"/>

<!-- Field which is disabled until myCheckbox is checked. 
     Function getSelectToReRenderDisabled() of controller checks the boolean value of controller.entity.valueB -->
<h:selectOneRadio id="selectToReRender"
                  value="#{controller.entity.valueC}"
                  label="#{text['selectToReRender.label']}"
                  layout="pageDirection"
                  required="true"
                  disabled="#{controller.selectToReRenderDisabled}">
    <f:selectItems value="#{MySelectItems.myEntitySelectItems}"
                   var="" />
</h:selectOneRadio>
<rich:message for="selectToReRender"/>
2

2 Answers

0
votes

The manual says, that the component rich:message supports "auto rerendering after Ajax request without help of <a4j:outputPanel>". So this component is rerendered automatically within every AJAX-request. In the list of attributes you can see, that ajaxRendered has it's default value set to true.

So you could try to set it to false but then you have to be aware that it has to be rerendered manually during concerned AJAX-requests (e.g. if your selectA has AJAX-support).

0
votes

ajaxSingle="true" in the <a4j:support/> for myCheckbox means that when that box is checked, only myCheckbox is submitted for processing (sort of) and validation. As a result, all other components within that form and any associated validation errors and messages are ignored during processing of that request.

To ensure that the entire form is submitted and validated when myCheckBox is selected, set ajaxSingle="false" or remove it altogether