3 Replies Latest reply on Mar 28, 2008 8:12 AM by Chuck G

    modalPanel not submitting form information correctly

    Chuck G Newbie

      Hi,

      I have a page that uses a modal panel to confirm a user's password. I followed the cookbook/example and placed the modal panel at the bottom of the page in its own form, but the value being passed to the backing bean is always null. If anyone has any insight into what I am doing wrong, it would be greatly appreciated. Here is the code:

      <a4j:form id="mainForm">
      <rich:tabPanel activeTabClass="tabStyle tabHeaderOn" inactiveTabClass="tabStyle tabHeaderOff" disabledTabClass="tabStyle tabHeaderDisabled" binding="#{tabHeader.mainPanel}" id="tabHeader"
       switchType="server">
       <rich:tab>
       ...
       </rich:tab>
      </rich:tabPanel>
      </a4j:form>
      <ui:include src="/WEB-INF/content/employeeProfile/passwordConfirm.jspx"/>


      And passwordConfirm.jspx:
      <rich:modalPanel id="confirmPasswordPanel" left="300" width="450" height="150" moveable="false" binding="#{userProfileHelper.passwordModalPanel}">
       <h:form id="passwordModalForm">
       <f:facet name="header">
       <h:outputText value="Confirm Password"/>
       </f:facet>
      
       <h:panelGrid width="100%" columns="1" columnClasses="smtxt2">
      
       <h:panelGrid columns="3" width="100%" border="0" cellspacing="0" cellpadding="0" columnClasses="alignRight smtxt2, ,alignLeft">
       <h:outputText value="Please cofirm your password to view #{userProfile.firstName} #{userProfile.lastName}'s SSN: " />
       <rich:spacer width="3" />
       <h:inputSecret value="#{userProfileHelper.passwordConfirmation}" id="confirmPasswordSecret" immediate="true">
       </h:inputSecret>
       </h:panelGrid>
       <h:panelGrid columns="3" width="100%" cellspacing="0" cellpadding="0" columnClasses="alignRight, ,alignLeft">
       <h:commandButton type="submit" action="#{userProfileHelper.confirmPassword}" value="OK" immediate="true" id="confirmPasswordButton" styleClass="regbtn"/>
      
       <rich:spacer width="5" />
       <a4j:commandButton type="button" onclick="Richfaces.hideModalPanel('mainForm:confirmPasswordPanel'); return false" value="Cancel" styleClass="regbtn" />
       </h:panelGrid>
       </h:panelGrid>
       </h:form>
       </rich:modalPanel>


      And userProfileHelper.confirmPassword() :
      public void confirmPassword() {
       logger.debug( ">UserProfileHelper.confirmPassword" );
      
       FacesContext context = FacesContext.getCurrentInstance();
      
       // TODO: Constant-ify the demsUser property somewhere.
       DEMSUser currentUser = (DEMSUser)FacesUtil.getSessionMapValue( "loggedInUser" );
      
       logger.debug( "Validating password for " + (currentUser != null ? currentUser.getUserId() : "NO USER!!") +
       " using password " + getPasswordConfirmation() );
      
       try {
       DomainUtil domainUtil = DomainUtil.getInstance();
       if( domainUtil.validatePassword( currentUser.getUserId(), getPasswordConfirmation() ) ) {
       logger.debug( "UserProfileHelper.confirmPassword TRUE" );
       // set request value to true, close modal and display SSN field.
       setSsnVisible( !getSsnVisible() );
       if( getSsnButtonValue().equals( SSN_BUTTON_OFF ) ) {
       setSsnButtonValue( SSN_BUTTON_ON );
       if( getSsnOpener() != null ) {
       getSsnOpener().setOnclick( "" );
       }
       if( getSsnOpenerActive() != null ) {
       getSsnOpenerActive().setOnclick( "" );
       }
      
       } else {
       setSsnButtonValue( SSN_BUTTON_OFF );
       //getPasswordModalPanel().
       getSsnOpener().setOnclick( "Richfaces.showModalPanel('mainForm:confirmPasswordPanel'); return false;" );
       }
       } else {
       logger.debug( "UserProfileHelper.confirmPassword FALSE" );
       // set request value to false, display Wrong modal window, maintain a count of incorrect attempts, ask again.
      
       setPasswordErrorCount( getPasswordErrorCount() + 1 );
       if( getPasswordErrorCount() == 3 ) {
       HttpServletRequest request = (HttpServletRequest)context.getExternalContext().getRequest();
       request.getSession().invalidate();
       FacesUtil.setRequestMapValue( "passwordTooManyFailures", true );
       } else {
       FacesUtil.setRequestMapValue( "passwordError", true );
       }
       }
       } catch( DomainException de ) {
       logger.error( "Error validating password for user", de );
       }
       logger.debug( "<UserProfileHelper.confirmPassword" );
       context.renderResponse();
       }
      


      getPasswordConfirmation is always returning null. What am I doing incorrectly? Thanks!