I don't know why the method called on the
action="#{template.questionMB.navigateToQuestionPage()}
is not called.
I am using JSF 2.2, I have no errors in the output and in h:messages. The logs that I put in the method are does not print into the output, because the method is not invoked.
I tried to figure out the problem by reading these posts, post1 and post2 and few others, I didn't find out the problem. I used type=submit, I used commandLink instead commandButton, but nothing.
I indicated the commandButton with ->>>> <<<<-
in the code bellow.
<ui:define name="content">
<ul class="breadcrumb">
<li><a href="#"><h:outputText value="#{labels['breadcrumb.home']}"/></a></li>
<li><a href="listTemplates.xhtml"> <h:outputText value="#{labels['breadcrumb.listTemplates']}"/></a></li>
<li><a href="displayTemplate.xhtml"><h:outputText value="#{labels['breadcrumb.displayTemplates']} #{template.templateDt.mnemonic}"/></a></li>
<li><a href="displayQuestionnaire.xhtml"><h:outputText value="#{labels['breadcrumb.viewQuestionnaire']} #{template.questionnaireMB.currentQuestionnaire.mnemonic}"/></a></li>
<li><a href="displayChapter.xhtml"><h:outputText value="#{labels['breadcrumb.viewChapter']} #{template.chapterMB.currentChapter.mnemonic}"/></a></li>
<li><a href="displayQuestion.xhtml"><h:outputText value="#{labels['breadcrumb.viewQuestion']} #{template.questionMB.currentQuestion.mnemonic}"/></a></li>
<c:choose>
<c:when test="${param['type'] eq 'instructions'}">
<li><h:outputText value="#{labels['editQuestionDetails.QuestionInstructions']} #{template.questionMB.currentQuestion.mnemonic}"/></li>
</c:when>
...
</c:choose>
</ul>
<h:form id="form" class="form-horizontal">
<c:choose>
<c:when test="${param['type'] eq 'instructions'}">
<h2 class="ico_general_settings">Question instructions</h2>
->>>>> <h:messages errorClass="ico_cancel" infoClass="ico_success" fatalClass="ico_cancel" warnClass="ico_warning"/>
<h:message for="returnBtn"/> <<<<<-
<label id="lblInstructions" for="instructions" class="top">Instrucţiuni </label>
<h:inputTextarea id="instructions" rows="3" value="#{template.questionMB.currentQuestion.instructions}" styleClass="input-sm form-control"/>
<h:commandButton value="Save" styleClass="btn btn-sm btn-primary" action="#{template.questionMB.saveQuestion}" onclick="return !checkTemplateTasksInProgress();"/>
->>>>> <h:commandButton id="returnBtn" value="Return" styleClass="btn btn-sm btn-default" action="#{template.questionMB.navigateToQuestionPage()}" immediate="true" /> <<<<<-
And the method in the bean is:
public String navigateToQuestionPage() {
logger.debug("+++ navigateToQuestionPage() called");
if (currentQuestion.getAnswer() != null && currentQuestion.getAnswer().getClass() == AnswerMatrix.class) {
return ACTION_DISPLAY_QUESTION_MATRIX;
} else {
navigationRuleType = NavigationRuleEditType.QUESTION;
return ACTION_DISPLAY_QUESTION;
}
}