In my login.xhtml file I have 1 form. This form also contains 2 <p:commandButton>
which are mutual exclusively rendered.
The actions point to 2 different methods defined in my LoginController Java-class.
When the command button with the loginController.login
action is clicked, the corresponding method in my LoginController is called as exptected.
But when the command button with the loginController.resetpassword
action is clicked, the corresponding method in my LoginController is not called. The LoginController is just being reloaded and then nothing else (attempt #1).
First, I thought it's because I cannot have 2 command buttons in the same form, even though only 1 of them is rendered at any time, but if I swap the actions of the two action buttons, then the loginController.resetpassword is being called (attempt #2)! It does not matter if I swap the lines of code, so the lines of codes with the command buttons are read in another order (attempt #3).
For some readon, it seems as if I can only get the command button with id=loginButton
to work?
I do not use navigation in my faces-config.xml. The form element is of type <h:form>
What am I doing wrong? Java 8, Primefaces 6.1
Attempt#1: default code
<p:commandButton id="resetpasswordButton"
value="#{msg['reset_password']}"
action="#{loginController.resetpassword}"
rendered="${not empty param.pw_reset}"
/> <!-- #resetpasswordButton button does not work -->
<p:commandButton id="loginButton"
value="#{msg['login']}"
action="#{loginController.login}"
rendered="${empty param.pw_reset}"
/> <!-- #loginButton button works, calling login() -->
Attempt#2: actions switched
<p:commandButton id="resetpasswordButton"
value="#{msg['reset_password']}"
action="#{loginController.login}"
rendered="${not empty param.pw_reset}"
/> <!-- #resetpasswordButton button does not work -->
<p:commandButton id="loginButton"
value="#{msg['login']}"
action="#{loginController.resetpassword}"
rendered="${empty param.pw_reset}"
/> <!-- #loginButton button works, calling resetpassword() -->
Attempt#3: order switched
<p:commandButton id="loginButton"
value="#{msg['login']}"
action="#{loginController.login}"
rendered="${empty param.pw_reset}"
/> <!-- #loginButton button works, calling login() -->
<p:commandButton id="resetpasswordButton"
value="#{msg['reset_password']}"
action="#{loginController.resetpassword}"
rendered="${not empty param.pw_reset}"
/> <!-- #resetpasswordButton button does not work -->