0 Replies Latest reply on Oct 1, 2008 2:56 PM by Sandeep Shenoy

    Conditionally required

    Sandeep Shenoy Newbie

      I have a drop down userType, when the user type is "Temporary" i need to display the daysOfWeek multiple select and make it a required field, on switiching back to "Regular" i need to hide the "daysOfWeek" multiple select and now this is not a required field. I tried disabling the daysOfWeek field via JS when userType is regular but then the form does not submit, it still expects a value for dayOfWeek. Is there some way of doing this. I cannot have byPassUpdates as false and check based on a bean property cause the user can cancel at any time and the bean should not be updated.


      <s:decorate id="userTypeDecoration" template="layout/edit.xhtml" rendered="#{s:hasRole('Admin')}">
                      <ui:define name="label">User Type</ui:define>
                      <h:selectOneMenu id="status" required="true" value="#{userHome.instance.userType}" onchange="showTemp();">
                                      <f:selectItem itemValue="Regular" itemLabel="Regular"/>
                              <f:selectItem itemValue="Temporary" itemLabel="Temporary"/>
                         <a:support event="onblur" reRender="userTypeDecoration" bypassUpdates="true" ajaxSingle="true"/>

      <s:decorate id="daysDecoration" template="layout/editDays.xhtml" >
                      <label for="user:daysDecoration:days" class="name ">Days of Week:</label>
                                      <h:selectManyListbox id="daysOfWeek" value="#{userHome.selectedColumns}" required="true">
                                                      <f:selectItem id="item1" itemLabel="Sunday" itemValue="Sunday"/>
                                                      <f:selectItem id="item2" itemLabel="Monday" itemValue="Monday" />
                                                      <f:selectItem id="item3" itemLabel="Tuesday" itemValue="Tuesday" />
                                                      <f:selectItem id="item4" itemLabel="Wednesday" itemValue="Wednesday" />
                                                      <f:selectItem id="item5" itemLabel="Thursday" itemValue="Thursday" />
                                                      <f:selectItem id="item6" itemLabel="Friday" itemValue="Friday" />
                                                      <f:selectItem id="item7" itemLabel="Saturday" itemValue="Saturday" />
                                                      <a:support event="onblur" reRender="daysDecoration" bypassUpdates="true" ajaxSingle="true"/>