Search code examples
jsfrichfaces

Rendering doesnt work for a4j:outputPanel


I have designed a jsf page and my scenario is to render output panel based on changing the dopdown in selectonemenu. My problem here is required=true in inputtext box. It dosnt allow other components to render and when i give value in textbox , then it allows the selectonemenu to render . What is the mistake i have done.Please can someone solve my problem

Code

<a4j:outputPanel id="thapalSection" >
    <ui:fragment>
        <fieldset style="table-layout: fixed;">
            <legend>#{msg.lbl_post_offSect}</legend>
            <table border="0" cellpadding="1" cellspacing="15" width="100%" 
                style="border-width: 1px;border-spacing: 1px;border-style: solid;border-color:#c2c2c2">
                <tr>
                    <td align="left"  width="20%">#{msg.lbl_SenDTo}<span>
                        <font color="red"><b>*</b></font></span>
                    </td>
                    <td align="left"  colspan="3"  width="30%">
                        <a4j:outputPanel id="tapalSectionSendToPanel">
                            <h:inputText id="sendToId"  value="#{DataBean.kabalSectionBean.sendTo}"  class="createresizedTextbox"
                                readonly="true" required="true" requiredMessage="#{msg.labl_required}" />
                            <h:message for="sendToId" style="color:red" />
                        </a4j:outputPanel>
                    </td>
                </tr>
                <tr>
                    <td align="left"  width="20%" >#{msg.lbl_lettRef}</td>
                    <td align="left"  width="34%" >
                        <a4j:outputPanel id="letterReferenceIDPAnel">
                            <h:inputText id="lettRefId" value="#{DataBean.kabalSectionBean.letterFileRefNo}" 
                                class="createresizedTextbox"  required="true" requiredMessage="#{msg.labl_required}" immediate="true"/>
                            <h:message  for="lettRefId" style="color:red" />
                        </a4j:outputPanel>
                    </td>
                </tr>
                <tr>
                    <td>#{msg.lbl_Sender_type}</td>
                    <td>
                        <a4j:outputPanel id="senderTypePanel" >
                            <h:selectOneMenu value="#{DataBean.kabalSectionBean.senderType}" class="createresizedTextbox"  id="senderTypeID">
                                <a4j:ajax event="change" render="thapalSection internalPanel" listener="#{FileTrackAction.selectSenderType}"  />
                                <f:selectItem itemValue="--select--" itemLabel="--Select--" />
                                <f:selectItem itemValue="internal" itemLabel="Internal" />
                                <f:selectItem itemValue="external" itemLabel="External" />
                                <f:validator validatorId="org.gov.tnwrd.bean.validation.DropdownValidation" />
                            </h:selectOneMenu>
                            <h:message for="senderTypeID" style="color:red" />
                        </a4j:outputPanel>
                    </td>
                </tr>
                <a4j:outputPanel id="internalPanel" >
                    <ui:fragment  rendered="#{DataBean.kabalSectionBean.sendTypeIntEnabled==true}" >
                        <tr>
                            <td align="left"  width="20%" >#{msg.lbl_office_name}</td>
                            <td align="left" width="34%">
                                <h:inputText id="internalType" value="#{DataBean.kabalSectionBean.officeName}" class="createresizedTextbox"  readonly="true" />
                            </td>
                            <td align="left" width="17%"  >#{msg.lbl_type_letter}</td>
                            <td align="left">
                                <h:selectOneMenu class="createresizedTextbox" value="#{DataBean.kabalSectionBean.typeOfletter}">
                                    <f:selectItem itemValue="--" itemLabel="--Select--" />
                                    <f:selectItem itemValue="ordinaryLetter" itemLabel="Ordinary Letter" />
                                    <f:selectItem itemValue="doLetter" itemLabel="D.O Letter" />
                                    <f:selectItem itemValue="confidentialLetter" itemLabel="Confidential Letter" />
                                    <f:selectItem itemValue="OtherLetter" itemLabel="Other Letter" />
                                </h:selectOneMenu>
                            </td>
                        </tr>
                    </ui:fragment>
                </a4j:outputPanel>
            </table>
        </fieldset>
    </ui:fragment>
</a4j:outputPanel>
</td>
</tr>
</table>
</td>
</tr> 
</table>
<table cellspacing="1" cellpadding="15" width="100%" border="0">
    <tr>
        <td></td>
        <td colspan="6" align="right">
            <div class="buttons">
                <a4j:commandButton id="addThapal" value="#{msg.btn_send}" type="button" render="thapalPanel savePopUp" action="#{FileTrackAction.saveThapalDetails}" oncomplete="if(#{DataBean.kabalSectionBean.statusCode eq 'Success'})  #{rich:component('savePopUp')}.show();"/>
                <a4j:commandButton id="clearId" value="#{msg.btn_clear}" render="thapalPanel" action="#{FileTrackAction.clearTapalSection}"  type="button" />
            </div>
        </td>
    </tr>
</table>
</a4j:outputPanel>

Solution

  • The problem is, that the validation fails. This causes JSF to interrupt its lifecycle and jump from validation directly to rendering without changing anything in between.

    I don't know exactly when you set DataBean.kabalSectionBean.sendTypeIntEnabled but you can check that this value will not be set to true and thus your panel will not be changed.

    You have different options here. Either you can use the immediate="true" attribute to skip validation, or you can use execute="list of components you want to execute". Execute means, that the data will be sent to the backing bean, will be validated and the setXXX(...) methods will be called for this input. Here you would NOT list the required field and thus its validation won't be a problem.

    If you use execute="@none" it has the same effect like immediate="true".