【问题标题】:h:commandbutton with ajax calls wrong action methodsh:commandbutton 与 ajax 调用错误的操作方法
【发布时间】:2013-07-18 09:51:25
【问题描述】:

我对带有 <f:ajax> 标签的 jsf <h:commandButton> 有疑问。如果它有<f:ajax> 标签,它会调用支持bean 中的其他actionactionListener 方法。如果它没有<f:ajax> 标签,它会调用它自己的权利action 方法。 这是我的sn-p:

 <h:form>
    <h:panelGroup id="loanContent" layout="block">
        <ui:include src="#{mainView.typePage}.xhtml"/>
    </h:panelGroup>
    <h:commandButton id ="rLoanBtn" value="Create" action="#{mainView.createNewType}">
        <f:ajax execute="loanContent" render="@form"/>
    </h:commandButton>  
 </h:form>

如果我省略 &lt;f:ajax execute="loanContent"/&gt; 部分,它工作正常。如果我保持原样,它会调用其他方法,这些方法负责相同形式的其他按钮。顺便说一句,mainView 支持 bean 是一个 ViewScoped 托管 bean。

【问题讨论】:

  • 您是否尝试将执行属性更改为包括相关命令按钮在内的内容?喜欢 execute="@this" 或 "@form" 开头吗?
  • 动态包含导致了这种情况。哪个 JSF 实现/版本?
  • @BalusC 经过几次实验。我知道它不是动态包含。但无论这些方法在其实际方法之前是什么,它都会调用其他方法。我使用的是 Mojarra 2.1.23 和 2.1.24 是一样的。
  • 它在自己的操作方法之前通过其他方法,该方法与同一视图中的另一个 commandButton 组件相关联。

标签: jsf action actionlistener commandbutton


【解决方案1】:

我已经找到原因了。如果我有其他按钮的&lt;type = "button"&gt; 属性,它会在其实际方法之前通过绑定到其他按钮的方法。所以我省略了它然后它工作正常。

【讨论】:

    猜你喜欢
    • 2013-06-26
    • 2012-07-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多