12 Replies Latest reply on Nov 22, 2012 6:05 PM by Timo Hahn

    validate required value on save not when navigating

    JerryJacobs
      hi how can i validate requred field on save and not in navigation.for example if i click createInsert in child table and what to navigate to parent table,i don't what to see the error field required for child record when am navigating, i only what to see the error when saving record or clicking save/commit button,am in jdeveloper 11.1.1.6.0

      Edited by: adf0994 on 2012/11/19 2:53 PM

      Edited by: adf0994 on 2012/11/19 3:06 PM
        • 1. Re: validate required value on save
          Mohammad Jabr
          set the immediate property for your action component to true.
          • 2. Re: validate required value on save
            JerryJacobs
            ok i set my createInsert Button to
             <af:commandButton actionListener="#{bindings.CreateInsert.execute}"
                                                        text="Add New"
                                                        id="cb5"
                                                        shortDesc="Add Table Fields For Existing table"
                                                        immediate="true"/>
            but now am geting this error for primary key
            Error
            Messages for this component are listed below.
                 
            Error     
            Too many objects match the primary key oracle.jbo.Key[bansetable feildbanse ].
            Error     
            Attribute Fieldlabel in MaSchModel.CfgFieldsView1 is required.

            what i did is i click add for my child table/form and when i navigate to parent table am geting the error

                 
            Error     
            Too many objects match the primary key oracle.jbo.Key[bansetable feildbanse ].
            Error     
            Attribute Fieldlabel in MaSchModel.CfgFieldsView1 is required.

            Edited by: adf0994 on 2012/11/19 3:15 PM
            • 3. Re: validate required value on save
              user404
              Try Create instead of CreateInsert
              • 4. Re: validate required value on save
                JerryJacobs
                its showing error you must enter value and its only giving option to insert one value
                <af:commandButton actionListener="#{bindings.Create.execute}"
                                                            text="Create"
                                                            id="cb5" immediate="true"/>
                
                but this field i can navigate to other table without error required field the error only come when i try to save if the fieild is empty
                <af:selectOneChoice value="#{bindings.Type.inputValue}"
                                                        label="#{bindings.Type.label}"
                                                        required="#{bindings.Type.hints.mandatory}"
                                                        shortDesc="#{bindings.Type.hints.tooltip}"
                                                        id="soc1" immediate="true">
                                      <f:selectItems value="#{bindings.Type.items}" id="si1"/>
                                    </af:selectOneChoice>
                the whole form is
                <af:inputText value="#{bindings.Fieldlabel.inputValue}"
                                                  label="#{bindings.Fieldlabel.hints.label}"
                                                  required="#{bindings.Fieldlabel.hints.mandatory}"
                                                  columns="20"
                                                  maximumLength="#{bindings.Fieldlabel.hints.precision}"
                                                  shortDesc="#{bindings.Fieldlabel.hints.tooltip}"
                                                  id="it4" immediate="true">
                                      <f:validator binding="#{bindings.Fieldlabel.validator}"/>
                                    </af:inputText>
                                    <af:inputText value="#{bindings.Format.inputValue}"
                                                  label="#{bindings.Format.hints.label}"
                                                  required="#{bindings.Format.hints.mandatory}"
                                                  columns="20"
                                                  maximumLength="#{bindings.Format.hints.precision}"
                                                  shortDesc="#{bindings.Format.hints.tooltip}"
                                                  id="it3">
                                      <f:validator binding="#{bindings.Format.validator}"/>
                                    </af:inputText>
                                    <af:selectOneChoice value="#{bindings.Type.inputValue}"
                                                        label="#{bindings.Type.label}"
                                                        required="#{bindings.Type.hints.mandatory}"
                                                        shortDesc="#{bindings.Type.hints.tooltip}"
                                                        id="soc1">
                                      <f:selectItems value="#{bindings.Type.items}" id="si1"/>
                                    </af:selectOneChoice>
                                    <af:inputText value="#{bindings.Length.inputValue}"
                                                  label="#{bindings.Length.hints.label}"
                                                  required="#{bindings.Length.hints.mandatory}"
                                                  columns="20"
                                                  maximumLength="#{bindings.Length.hints.precision}"
                                                  shortDesc="#{bindings.Length.hints.tooltip}"
                                                  id="it2">
                                      <f:validator binding="#{bindings.Length.validator}"/>
                                      <af:convertNumber groupingUsed="false"
                                                        pattern="#{bindings.Length.format}"/>
                                    </af:inputText>
                                    <af:inputText value="#{bindings.Fielddescription.inputValue}"
                                                  label="#{bindings.Fielddescription.hints.label}"
                                                  required="#{bindings.Fielddescription.hints.mandatory}"
                                                  columns="20"
                                                  maximumLength="#{bindings.Fielddescription.hints.precision}"
                                                  shortDesc="#{bindings.Fielddescription.hints.tooltip}"
                                                  id="it1">
                                      <f:validator binding="#{bindings.Fielddescription.validator}"/>
                                    </af:inputText>
                                    <f:facet name="footer">
                                      <af:panelGroupLayout layout="vertical" id="pgl5">
                                        <af:panelGroupLayout layout="horizontal" id="pgl2">
                                          <af:commandButton actionListener="#{bindings.First.execute}"
                                                            text="First"
                                                            partialSubmit="true" id="cb2"/>
                                          <af:commandButton actionListener="#{bindings.Create.execute}"
                                                            text="Create"
                                                            id="cb5" immediate="true"/>
                Edited by: adf0994 on 2012/11/19 4:09 PM
                • 5. Re: validate required value on save
                  Suresh Karunarathne
                  Hi,
                  When navigate use immediate="true" and it will skip validations.
                  immediate     boolean     Yes     Default Value: false

                  whether data validation - client-side or server-side - will be skipped when events are generated by this component. When immediate is true, the command's action and ActionListeners, including the default ActionListener provided by the JavaServer Faces implementation, will be executed during Apply Request Values phase of the request processing lifecycle, rather than waiting until the Invoke Application phase. Because validation runs during Process Validators (after Apply Request Values, but before Invoke Application), setting immediate to true will skip validation.
                  See
                  http://jdevadf.oracle.com/adf-richclient-demo/docs/tagdoc/af_commandButton.html
                  • 6. Re: validate required value on save
                    JerryJacobs
                    hi but i did make my immediate="true",but still geting validation error required field

                    Edited by: adf0994 on 2012/11/22 11:02 AM
                    • 7. Re: validate required value on save
                      Ranjith Chitharanjan
                      Hi,
                      Use immediate = true in the command link , i guess, which is used to navigate only, not on every component

                      Ranjith
                      • 8. Re: validate required value on save not when navigating
                        JerryJacobs
                        am not using command link am using button,which is also been used to insert new record
                        <af:commandButton actionListener="#{bindings.CreateInsert.execute}"
                                                                    text="Add Field"
                                                                    id="cb5" immediate="true"
                                                                    shortDesc="Add New Fields"/>
                        this is the form i like to validate on save and not when am navigating,i what to check the required field when clicking save not when am navigating out of the form
                        <af:panelFormLayout id="pfl1" maxColumns="2" rows="3"
                                                              partialTriggers="t1"
                                                              inlineStyle="width:641px; height:126px;">
                                            <af:inputText value="#{bindings.Fieldlabel.inputValue}"
                                                          label="Fieldlabel"
                                                          columns="20"
                                                          maximumLength="#{bindings.Fieldlabel.hints.precision}"
                                                          shortDesc="#{bindings.Fieldlabel.hints.tooltip}"
                                                          id="it4" immediate="true" required="true">
                                              <f:validator binding="#{bindings.Fieldlabel.validator}"/>
                                            </af:inputText>
                                            <af:inputText value="#{bindings.Format.inputValue}"
                                                          label="Format"
                                                          columns="20"
                                                          maximumLength="#{bindings.Format.hints.precision}"
                                                          shortDesc="#{bindings.Format.hints.tooltip}"
                                                          id="it3" immediate="true"
                                                          showRequired="false" autoSubmit="true"
                                                          required="true">
                                              <f:validator binding="#{bindings.Format.validator}"/>
                                            </af:inputText>
                                            <af:selectOneChoice value="#{bindings.Type.inputValue}"
                                                                label="#{bindings.Type.label}"
                                                                shortDesc="#{bindings.Type.hints.tooltip}"
                                                                id="soc1" immediate="true"
                                                                required="true">
                                              <f:selectItems value="#{bindings.Type.items}" id="si1"/>
                                            </af:selectOneChoice>
                                            <af:inputText value="#{bindings.Length.inputValue}"
                                                          label="Length"
                                                          columns="20"
                                                          maximumLength="#{bindings.Length.hints.precision}"
                                                          shortDesc="#{bindings.Length.hints.tooltip}"
                                                          id="it2" immediate="true" required="true">
                                              <f:validator binding="#{bindings.Length.validator}"/>
                                              <af:convertNumber groupingUsed="false"
                                                                pattern="#{bindings.Length.format}"/>
                                            </af:inputText>
                                            <af:inputText value="#{bindings.Fielddescription.inputValue}"
                                                          label="Fielddescription"
                                                          columns="20"
                                                          maximumLength="#{bindings.Fielddescription.hints.precision}"
                                                          shortDesc="#{bindings.Fielddescription.hints.tooltip}"
                                                          id="it1" immediate="true" required="true">
                                              <f:validator binding="#{bindings.Fielddescription.validator}"/>
                                            </af:inputText>
                                            <f:facet name="footer">
                                              <af:panelGroupLayout layout="vertical" id="pgl5">
                                                <af:panelGroupLayout layout="horizontal" id="pgl2">
                                                  <af:commandButton actionListener="#{bindings.Commit.execute}"
                                                                    text="Save"
                                                                    id="cb7"/>
                                                  <af:commandButton actionListener="#{bindings.CreateInsert.execute}"
                                                                    text="Add Field"
                                                                    id="cb5" immediate="true"
                                                                    shortDesc="Add New Fields"/>
                                                  <af:commandButton actionListener="#{bindings.Delete.execute}"
                                                                    text="Delete"
                                                                    id="cb6"/>
                                                </af:panelGroupLayout>
                                              </af:panelGroupLayout>
                                            </f:facet>
                                          </af:panelFormLayout>
                        Edited by: adf0994 on 2012/11/20 10:38 AM

                        Edited by: adf0994 on 2012/11/22 11:03 AM
                        • 9. Re: validate required value on save not when navigating
                          Dimitris Stasinopoulos
                          Hi,

                          I dont seem to find the code that actually navigates you out from the form.
                          Are you calling createInsert or create for both creating and navigating?

                          please check this link,
                          it might help you understand regarding validation

                          http://dstas.blogspot.co.uk/2011/12/validator-or-valuechangelistener-adf.html

                          Regards,
                          Dimitrios.
                          • 10. Re: validate required value on save not when navigating
                            Alejandro Tovar Lanz
                            Hi,

                            Can you please explain how are you "navigating" out of the form???? Because I just can see three buttons with different listener but never used to navigate.
                            Regards

                            Edited by: Alejandro T. Lanz on 22-Nov-2012 03:11
                            • 11. Re: validate required value on save not when navigating
                              JerryJacobs
                              oh am not navigating using button what am talking about is if i click createinsert and try to click in another table or form it show error for those required value that i must fill before i continue,i only what that validation when i click save button not when am navigating or selecting value on the other table/form

                              Edited by: adf0994 on 2012/11/22 8:22 PM

                              Edited by: adf0994 on 2012/11/23 11:13 AM
                              • 12. Re: validate required value on save not when navigating
                                Timo Hahn
                                Have you read http://jobinesh.blogspot.de/2009/08/how-to-skip-validation.html?
                                Jobinesh describes (in detail) what validation properties you have at hand and how the different settings work.

                                Beside that , it's difficult to understand your use case as it only comes out after 10 - 20 questions. It would help if you would give the needed information when you start a question. Right now I don't know if the topic of the thread matches what you really like to know. Posting long code listings without a reason doesn't help either. You can't expect us to analyze your code just to understand the problem.

                                Timo