0 Replies Latest reply: Jun 3, 2014 6:34 AM by Brent Harlow RSS

    Avoiding validation when immediate components used

    Brent Harlow

      Dear all,

       

      I'm using JDeveloper 11.1.2 and JHeadstart 11.1.2.1.28

       

      I've had this issue for a long time and seem to have tried every single suggestion on the internet about how to fix it - unfortunately none of the suggested solutions has worked for me. 

       

      The problem is avoiding mandatory validation within a wizard when the user clicks on the cancel button - when the mandatory component has autoSubmit and immediate set to true as it is used to conditionally render other fields on the same page.

       

      I've tried using javscript like ADF Practice: How to avoid validation of immediate inputs, I've tried using renderResponse like ADF Practice: Understanding the JSF Immediate Attribute but both seem to have no effect (I know the JHeadstart RollbackBean.execute already uses JsfUtils.jumpToRenderResponseIfNeeded but perhaps the timing of it is not in the right place ?

       

      The code for my mandatory, autosubmit dropdown list

       

                              <af:selectOneChoice id="SubjectVisitWizardWithdrawEarlyv2" value="#{bindings.SubjectVisitWizardWithdrawEarlyv2.inputValue}"
                                                  label="#{nls['SUBJECTVISITWIZARD_WITHDRAWEARLYV2']}" required="true"
                                                  readOnly="#{!(jhsUserRoles['SubjectVisits.update'])}"
                                                  rendered="#{bindings.SubjectVisitWizardCurrentVisit.inputValue=='2' and (bindings.SubjectVisitWizardHardVisitWindow.inputValue=='OK' or jhsUser.userRoleShort=='HMD') and bindings.SubjectVisitWizardNumNrsRecorded.inputValue>1}"
                                                  shortDesc="#{bindings.SubjectVisitWizardWithdrawEarlyv2.hints.tooltip}"
                                                  valueChangeListener="#{ValidateBean.toggle}" autoSubmit="true" immediate="true"
                                                  unselectedLabel="#{nls['UNSELECTED_LABEL']}">
      

       

      The code for the cancel button

       

                          <af:commandButton textAndAccessKey="#{nls['CANCEL']}" immediate="true" partialSubmit="true"
                                            rendered="#{!pageFlowScope.hideCancelButton}" actionListener="#{jhsRollback.execute}"
                                            action="SubjectVisitsDeepLink" id="SubjectVisitWizardCancelButton">
                          </af:commandButton>
      

       

      public class ValidateBean {
          private static final ADFLogger sLog = ADFLogger.createADFLogger(ValidateBean.class);
          
          public void toggle (ValueChangeEvent vce) {
             sLog.info("*** toggle");
             vce.getComponent().processUpdates(FacesContext.getCurrentInstance());       
              // This is to avoid validation errors on the rest of the page if they select a value here
              // before completing mandatory fields 
             FacesContext.getCurrentInstance().renderResponse();
          }
      

       

      It doesn't make any sense to the users to have to complete fields simply to cancel the transaction !  Can someone please help ?? How has this problem being avoided in other JHeadstart projects ?

       

      Would really appreciate any input/help with this problem.

       

      Cheers,

      Brent