How to make a field mandatory in JSPX page in ADF

In this scenario, we need to make <inputListOfValues> field as Mandatory, which means no NULL values are accepted and User cannot enter NULL value in the Field. We need to display an Error message when ever User submits the form without any value.

This solution works well with any field which accepts “required” property attribute.

So in my case I dragged and dropped the column from the data control as a LOV then the below code is added in the JSPX page –

                           <af:inputListOfValues id=”fiscalYear1Id”
                                                      popupTitle=”Search and Select: #{bindings.FiscalYear1.hints.label}”
                                                      value=”#{pageFlowScope.Bean.fiscalYear}”
                                                      label=”#{bindings.FiscalYear1.hints.label}”
                                                      model=”#{bindings.FiscalYear1.listOfValuesModel}”
                                                      required=”#{bindings.FiscalYear1.hints.mandatory}
                                                      showRequired=”true” editMode=”input”
                                                      columns=”#{bindings.FiscalYear1.hints.displayWidth}”
                                                      shortDesc=”#{bindings.FiscalYear1.hints.tooltip}”>
                                  <f:validator binding=”#{bindings.FiscalYear1.validator}”/>
                                </af:inputListOfValues>

From the above code we have “required” attribute which is to make the field as Mandatory one. But this did not work in my case. So I have to modify the “required” attribute value from =”#{bindings.FiscalYear1.hints.mandatory}” to “true”.

                             <af:inputListOfValues id=”fiscalYear1Id”
                                                      popupTitle=”Search and Select: #{bindings.FiscalYear1.hints.label}”
                                                      value=”#{pageFlowScope.Bean.fiscalYear}”
                                                      label=”#{bindings.FiscalYear1.hints.label}”
                                                      model=”#{bindings.FiscalYear1.listOfValuesModel}”
                                                      required=”true
                                                      showRequired=”true” editMode=”input”
                                                      columns=”#{bindings.FiscalYear1.hints.displayWidth}”
                                                      shortDesc=”#{bindings.FiscalYear1.hints.tooltip}”>
                                  <f:validator binding=”#{bindings.FiscalYear1.validator}”/>
                                </af:inputListOfValues>
 

 By this the the field became as Mandatory and it shows the below error message when the user submits with NULL value.

showRequired=”true” displays the ‘*’ before the field.

 

This entry was posted in ADF (Application Development Framework) and tagged , , , , , , . Bookmark the permalink.

2 Responses to How to make a field mandatory in JSPX page in ADF

  1. Ashok says:

    Uday,
    Making required property makes the user to enter the field mandatory, in my case…. where iam having list of jspx pages navigating from one page to another page and in one page i have dragged & dropped an VO as table , if we set one of the column(in the table) as required is true, then it does not allow to move forward nor backward, for forward this may fine..but how can we navigate to backward….?

    • udayarocks says:

      Hi Ashok,
      I think if you set the attribute immediate=”true” on the column where you defined required=”true” in the table will solve your problem.

      Please let me know if you still faces the same issue.

      Thanks,
      Udaya

Leave a comment