不调用调用commandButton操作的方法

时间:2016-06-14 12:55:04

标签: jsf jsf-2.2 commandbutton commandlink

我不知道为什么这个方法会调用

action="#{template.questionMB.navigateToQuestionPage()} 

未被调用。

我正在使用JSF 2.2,输出和h:消息中没有错误。我放在方法中的日志不会打印到输出中,因为不会调用该方法。

我试着通过阅读这些帖子来解决问题,post1post2以及其他一些帖子,我没有发现问题。我使用了type = submit,我使用了commandLink而不是commandButton,但没有使用。

我在下面的代码中用->>>> <<<<-表示了commandButton。

 <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" />   <<<<<-

bean中的方法是:

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;
    }
    }

0 个答案:

没有答案
相关问题