0

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();"/>&nbsp;
                ->>>>>    <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;
    }
    }
Community
  • 1
  • 1
Nelly Junior
  • 556
  • 2
  • 10
  • 30
  • Your problem matches #5 of the duplicate. In the future, please go through the entire list instead of stopping after 1st item. Also, creating a MCVE based on the instructions in http://stackoverflow.com/tags/jsf/info should have nailed down this much sooner. Your question in its current form implies that your problem disappears when you remove e.g. `
    `. But this is not true and therefore that piece (and many other pieces) are only noise which distracts the potential answerer from reading through the question.
    – BalusC Jun 14 '16 at 12:59
  • Which is the duplicated page? I just posted the sourses that didn't help me. – Nelly Junior Jun 14 '16 at 13:02
  • Just look in top of the question? It's the 1st source you linked yourself. – BalusC Jun 14 '16 at 13:03
  • Indeed because of that. The code clearly tells so. I'm not randomly guessing. Or are you implying that your problem still persists when you hardcode a `test="#{true}"`, or remove the ``/`` altogether? – BalusC Jun 14 '16 at 13:11
  • @BalusC: I read the enitely at the first time. Why do you think my problem matches #5 in the "post1", because I have the inside the ? The parameter send is indeed instructions. In from – Nelly Junior Jun 14 '16 at 13:17
  • Your problem is not the displaying of the form, but submitting the form and invoking the method, right? Just click the "See also" link of that item. It coincidentally describes exactly your case. – BalusC Jun 14 '16 at 13:23
  • I use jsf 2.2. sending parameters into a commandButton is another problem I have, but hopefully I will make it work. However, I saw you told that guy to use f:param inside commandButton, and it seem that is not working. I tried it too. – Nelly Junior Jun 14 '16 at 14:11
  • If you edit the question to incldue a real MCVE as per the instructions in the link in the 1st comment, so that it's reproducible for anyone else in the world without noise and additional instructions, then I will reopen the question. – BalusC Jun 14 '16 at 14:12
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/114645/discussion-between-nelly-junior-and-balusc). – Nelly Junior Jun 14 '16 at 14:14
  • Well, the problem persists. If somebody have an answer, it is welcome. – Nelly Junior Jun 15 '16 at 07:30
  • When you remove that ``, then it works fine? If so, when you retain `#{param.type}` via ``, as explained in the duplicate, then the problem still persists? – BalusC Jun 15 '16 at 08:46
  • Instead of I used rendered but the problem persists. – Nelly Junior Jun 21 '16 at 09:09
  • I didn't suggest to replace, but to **remove**. Just an one-time test in order to naildown or exclude it being the cause. Both approaches would have exactly the same effect when incorrectly used, as explained in the duplicate. If you have no clue what I'm talking about, carefully read [mcve] and the link in my 1st comment what exactly a MCVE is. – BalusC Jun 21 '16 at 09:09
  • If I remove c:when and c:choose the method is called. But how can I do now to render the only the components that I want? – Nelly Junior Jun 21 '16 at 12:05
  • Apparently the `` solution was done bad. – BalusC Jun 21 '16 at 12:15
  • My solution was to create 2 different pages. – Nelly Junior Jun 21 '16 at 21:33

0 Answers0