weird selectOneMenu behavior in tabPanel after validation
achildress Jun 18, 2008 10:30 AMI have a selectOneMenu inside a tab of a tabPanel. This selectOneMenu has a blank entry as its first selectItem (empty string value and displayed value). If I change the selection of this selectOneMenu to the blank entry select a new tab and the form is submitted, and validation fails, this selectOneMenu reverts back to its originally selected value. I would like it to remain with the blank entry selected. Is this normal JSF behavior? If not, is there something in my code below that is causing this?
tabPanel code:
<a4j:form id="interviewform"> <a4j:outputPanel ajaxRendered="true" id="myerrors"> <table> <tr> <td><h:outputLabel styleClass="stdLabel" value="The following errors have occurred. Please fix them and save again." rendered="#{! empty facesContext.maximumSeverity}" /></td> </tr> </table> <rich:messages id="error" layout="list" styleClass="stdLabel"> <f:facet name="errorMarker"> <h:graphicImage value="/images/failed.gif" /> </f:facet> </rich:messages> </a4j:outputPanel> <table cellpadding="0" cellspacing="0"> <tr> <td align="center"> <a4j:commandButton status="savestatus" id="saveButton" value="Save Interview" oncomplete="javascript:showErrors();" actionListener="#{DOPIntakeAdminTechInterviewBean.saveInterview}" reRender="myerrors"/> <a4j:status forceId="true" id="savestatus" onstart="Richfaces.showModalPanel('saveprogressmp',{width:450, top:200})" onstop="Richfaces.hideModalPanel('saveprogressmp')" /> <h:graphicImage id="waiterrors" url="/images/waitforerrors.gif" style="display: none;"></h:graphicImage> </td> </tr> </table> <rich:spacer height="4px"></rich:spacer> <rich:tabPanel id="admintechinterviewtabs" switchType="ajax" style="width: 96%;" valueChangeListener="#{DOPIntakeAdminTechInterviewBean.newTabSelected}" binding="#{DOPIntakeAdminTechInterviewBean.adminTechTabs}"> <rich:tab status="majorstatus" id="identification" label="Identification"> <ui:include src="\interviewidentification.xhtml"/> </rich:tab> <rich:tab status="majorstatus" id="family" label="Family"> <ui:include src="\interviewfamily.xhtml"/> </rich:tab> <rich:tab status="majorstatus" id="demographics" label="Demographics"> <ui:include src="\blankpage.xhtml"/> </rich:tab> <rich:tab status="majorstatus" id="educationjobs" label="Education/Employment"> <ui:include src="\blankpage.xhtml"/> </rich:tab> <rich:tab status="majorstatus" id="stg" label="STG"> <ui:include src="\blankpage.xhtml"/> </rich:tab> <rich:tab status="majorstatus" id="criminalhistory" label="Criminal History"> <ui:include src="\blankpage.xhtml"/> </rich:tab> <rich:tab status="majorstatus" id="complete" label="Mark Complete"> <ui:include src="\blankpage.xhtml"/> </rich:tab> </rich:tabPanel> <h:inputHidden id="maximumSeverity" rendered="#{! empty facesContext.maximumSeverity}" value="#{facesContext.maximumSeverity.ordinal}" /> </a4j:form>
Content of included facelet interviewidentification.xhtml that contains the selectOneMenu in question:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:a4j="http://richfaces.org/a4j" xmlns:rich="http://richfaces.org/rich"> <rich:panel id="intidpanel" style="width: 650px; height: 276px; overflow: auto;"> <table> <tr> <td align="right"> <h:outputLabel styleClass="stdLabel" value="Height: " /> </td> <td align="left"> <h:inputText required="true" id="heightFeet" label="Height Feet" value="#{IntakeOffenderBean.heightFeet}" maxlength="1" size="2" styleClass="stdTextBox"> <f:validator validatorId="heightFeetValidator" /> </h:inputText> <rich:spacer width="4px"/><h:outputLabel styleClass="stdLabel" value="ft" /><rich:spacer width="4px"/> <h:inputText required="true" id="heightInches" label="Height Inches" value="#{IntakeOffenderBean.heightInches}" maxlength="2" size="2" styleClass="stdTextBox"> <f:validator validatorId="heightInchesValidator" /> </h:inputText> <rich:spacer width="4px"/><h:outputLabel styleClass="stdLabel" value="in" /> </td> <td align="right"> <h:outputLabel styleClass="stdLabel" value="Body Build: " /> </td> <td align="left"> <h:selectOneMenu required="true" label="Body Build" id="bodyBuildCombo" value="#{IntakeOffenderBean.bodyBuild}"> <f:selectItems value="#{CodeCacheBean.getASICodes$['CMBODBLD'][true]}"/> </h:selectOneMenu> </td> </tr> </table> </rich:panel> </ui:composition>