oracle-adfjdeveloper-11g

How to display/hide textboxes fields upon changing values of select


I am working on a project where user have facility to enter his record , I want to know about how to display or hide textboxes while changing select box values Here I have a select box named with marital status Options for marital status are : 'married' and 'un-married'. If user selects 'Married' from above options, then a textbox appear for entering Spouse name and his/her birthday/children If user select 'Un-Married' from above option then a spouse name textbox and athers should disappear. i'm using oracle adf jdevolper 12c i need your help..


Solution

    1. Use the autoSubmit property on your select box values component and ensure it has an id property set.
    2. Embed the fields that you want to render conditionally in some enclosing component, like a panelGroup.
    3. Add the partialTriggers attribute to the panelGroup with the id of your select component.

    Here's a (slightly modified ) example from the documentation that would fit your use case. See https://docs.oracle.com/middleware/1212/adf/ADFUI/af_ppr.htm#ADFUI389 for more information.

    <af:form>
      <af:selectOneChoice id="socMar" value="#{bindings.maritalStatus.inputValue}" 
                          required="true" autoSubmit='true'>
        <f:selectItems value="#{bindings.maritalStatus.items}"/>
      </af:selectOneChoice>
      <af:panelGroupLayout partialTriggers="socMar"
                           rendered="#{bindings.maritalStatus.inputValue == 'Married'}">
        <af:inputText label="Spouse" required="true" value="#{bindings.someBinding.inputValue}"/>
         ...
      </af:panelGroupLayout>
    </af:form>