0

i want to display required messages on pop up after click update button when without give input fields and pop up must be open.If i enter all fields and then enter update button pop up should close.

below is jsf code,

<h:form id="dia">
            <p:dialog header="Reset password" widgetVar="reset" id="dialog"  modal="true" appendToBody="true"
        visible="#{facesContext.validationFailed}">
                <h:panelGrid columns="3" cellpadding="10px" cellspacing="10px">
                    <h:outputLabel  value="New password" />
                    <p:inputText id="npwd" value="#{crmBean.newPassword}" requiredMessage="Enter password" required="true" >
                     </p:inputText>
                             <h:message for="npwd" display="icon" />
                    <h:outputLabel value="Confirm password" />
                    <h:inputText id="opwd" value="#{crmBean.confirmPassword}" requiredMessage="Enter password" required="true" >
                    </h:inputText>
                             <h:message for="opwd" display="icon" />
                </h:panelGrid>

                <p:commandButton actionListener="#{crmBean.resetPassword()}"
                    value="Update password"  class="sitebtn" style="margin-left: 350px;" oncomplete="if (args &amp;&amp; !args.validationFailed) reset.show()" />
            </p:dialog>
</h:form>

below is backing bean code,

public void resetPassword(){
    cust_id=105;
        if (newPassword.equalsIgnoreCase(confirmPassword)) {
        int i = crmService.resetPassword(newPassword, cust_id);
              if (i==1) {
                  RequestContext.getCurrentInstance().execute("reset.hide()");
                      FacesContext.getCurrentInstance().addMessage(
                         "crmprofile",
                         new FacesMessage("Reset password successfully..","Thank you..."));
                      this.confirmPassword=null;
                      this.newPassword=null;
    } else {
        FacesContext.getCurrentInstance().addMessage(
                "crmprofile",
                new FacesMessage("Please enter values correctly:","Thank you..."));
        this.confirmPassword=null;
        this.newPassword=null;

    }
          }
        else {
            FacesContext.getCurrentInstance().addMessage(
                    "crmprofile",
                    new FacesMessage("Please enter values correctly:","Thank you..."));
            this.confirmPassword=null;
            this.newPassword=null;
        }

    }
  • There are too many mistakes in this code that it basically needs a full rewrite. It's confusing which mistake you want an answer for. For the JSF part, those mistakes are possibly already answered in at least one of the following related questions: http://stackoverflow.com/q/9195756, http://stackoverflow.com/q/18958729, http://stackoverflow.com/q/16125235, http://stackoverflow.com/q/25339056 – BalusC Oct 19 '15 at 09:09
  • finally i want show required messages in pop up without closing of pop up – Suresh M Gowda Oct 19 '15 at 09:20

0 Answers0