5 Replies Latest reply on May 4, 2010 5:59 AM by Ilya Shaikovsky

    'required=true' is preventing ajax show/hide functionality

    Jon Gott Newbie



      I'm trying to use the rendered attribute on an input component to show or hide the component based on the selection value of a radio button. But the components dont show up unless the 'required' components have values entered. Is there anyway I can keep validations on and still get this 'show/hide' functionality to work?


      This is the Radio Button input:


      <s:decorate template="layout/edit.xhtml">
      <ui:define name="label">Party Type</ui:define>
      <h:selectOneRadio id="partyType" value="#{partyHome.temp}">
           <f:selectItem itemValue="PER" itemLabel="Person"/>
           <f:selectItem itemValue="ORG" itemLabel="Organization"/>
           <a:support event="onchange" reRender="partyDet"/>
           <a:support event="onblur" reRender="partyTypeField" bypassUpdates="true" ajaxSingle="true"/>                

      This is the Component that I am trying to show or hide:


      <h:panelGrid id="partyDet" columns="1" > 
      <s:decorate id="firstnameField" template="layout/edit.xhtml" rendered="#{partyHome.temp == 'PER'}">
           <ui:define name="label">Firstname</ui:define>
           <h:inputText size="25" maxlength="25" value="#{personHome.instance.firstname}">
                <a:support event="onblur" reRender="firstnameField" bypassUpdates="true" ajaxSingle="true"/>
      <s:decorate id="orgNameField" template="layout/edit.xhtml" rendered="#{partyHome.temp == 'ORG'}">
           <ui:define name="label">Org name</ui:define>
           <h:inputText id="orgName" maxLength="25" value="#{organizationHome.instance.orgName}">
                <a:support event="onblur" reRender="orgNameField" bypassUpdates="true" ajaxSingle="true"/>

      I have other components in the form that has 'required=true' and if these fields are not filled in BEFORE the radio button selection is made, then the 'partyDet' panelGrid doesnt work the way. If I remove all the 'required' attribute from all the components, then whenever I click on the radio button, then the corresponding components work correctly.


      The logs show this error whenever I click on the radio button before the required fields are filled:


      [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.

      sourceId=contactInfo:contactTypeField:contactType[severity=(ERROR 2), summary=(value is required), detail=(value is required)]


      I tried looking through the forum for this specific problem, could find it. Any help is appreciated.