I have below structure for my forgotpassword.xhtml
view.
<p:outputPanel id="forgotPassword" autoUpdate="true">
<!--Accepting email address-->
<h:form>
<p:outputPanel rendered="#{!vctrl.status && !vctrl.accountLocked}">
<div class="row">
<div class="input-field s12">
<h:inputText id="emailAddress" value="#{vctrl.emailAddress}" size="35"/>
</div>
<div class="col s12 btn-col">
<p:commandButton value="Submit" styleClass="waves-effect waves-light btn btn-med"
update=":forgotPassword" actionListener="#{vctrl.checkIfEmailExists}" />
<p:commandButton value="Cancel" styleClass="waves-effect waves-light btn btn-med red darken-4"
immediate="true" style="float:right" action="#{vctrl.logout}" />
</div>
</div>
</p:outputPanel>
</h:form>
<!--checking for security question and answer-->
<h:form>
<p:outputPanel rendered="#{vctrl.status && !secBean.secBeanBlockDisplay && !vctrl.accountLocked}">
<div class="row">
<div class="input-field s12">
<h:inputSecret id="secBeanAns1" value="#{secBean.secBeanAnswer1}"/>
</div>
<div class="input-field s12">
<h:inputSecret id="secBeanAns2" value="#{secBean.secBeanAnswer2}"/>
</div>
<div class="col s12 btn-col">
<p:outputPanel>
<p:commandButton value="Submit" update=":forgotPassword"
data="#{vctrl.emailAddress}"
actionListener="#{secBean.checksecBeanQuestionsAndResetPass}"
oncomplete="setFocus();showpopup();"
styleClass="waves-effect waves-light btn btn-med" />
<p:commandButton value="Cancel"
action="#{vctrl.logout}"
styleClass="waves-effect waves-light btn btn-med red darken-4"
immediate="true" style="float:right" />
</p:outputPanel>
</div>
</div>
</p:outputPanel>
<p:outputPanel rendered="#{secBean.secBeanBlockDisplay}">
<div id="reloginpopup" class="modal" style="top: 35%">
<div class="modal-content">
</div>
</div>
</p:outputPanel>
</h:form>
</p:outputPanel>
Once the user enters his email address, next ajax view within 2nd form will be displayed. But the button inside this rendered element
doesn't submit as expected. It doesn't hit the actionListner
method - checksecBeanQuestionsAndResetPass
at all. It just reloads the page and renders forgotPassword
initial view.
My question is, will or not p:commandButton
work when rendered through ajax
? I went through this post and as per the answer there, p:commandButton
should be included within already rendered element. For me its the form
which will be rendered
initially, within which am loading the rest of the contents for security questions. So this should behave as expected. But am totally out of ideas as in why this is not calling bean method. Anything else to be configured here?
Edit
I've also added @ManagedBean
and @RequestScoped
to my beans
.
Update
So after visiting post 1, post 2, post 3 etc., still I couldn't get this working. My bean
method is never called at all. Below is how I've updated my commandButton
within rendered
html
<p:commandButton value="Submit" immediate="true"
update=":forgotPassword"
actionListener="#{secBean.checkSecurityQuestionsAndResetPass}"
process="@this"
data="#{vctrl.emailAddress}"
styleClass="waves-effect waves-light btn btn-med" />
<p:commandButton value="Cancel" immediate="true"
actionListener="#{vctrl.logout}"
styleClass="waves-effect waves-light btn btn-med red darken-4"
style="float:right"/>
and my bean method is as below:
public void checkSecurityQuestionsAndResetPass(ActionEvent event) {
String emailAddress = (String) event.getComponent().getAttributes()
.get("data");
//some processing
}
Any other ways I can try to get this to work?