【问题标题】:P:CommandLink doesn't work with ui:repeatP:CommandLink 不适用于 ui:repeat
【发布时间】:2012-07-16 05:16:56
【问题描述】:

当我将p:commandLink 标签与ui:repeat 标签一起使用时,我遇到了奇怪的问题!

commandLink 根本不起作用。

这是我的 xhtml 代码:

<h:form>
    <ui:repeat varStatus="miteraionno" value="#{bussinessOwnerViewerMB.bOwner.bOBranches}" var="branch" >

        <div class="details" >       

        <ul class="services">
            <li>
               <p:commandLink actionListener="#{bussinessOwnerViewerMB.testMethod}" styleClass="nav_services" oncomplete="">
                    <h:outputText value="#{branch.branchName}"/>
               </p:commandLink>
            </li>
        </ul>
        </div>
    </ui:repeat>

ActionListener 只是测试方法:

public void testMethod(){
    System.out.println("BussinessOwnerViewerMB.changeMapListener()");
}

我尝试c:foreach,但结果相同!

任何帮助将不胜感激..

【问题讨论】:

  • &lt;p:messages /&gt; 放在您的页面中用于调试目的,您将看到发生的任何错误。另外我会删除 &lt;h:ouputText /&gt; 并将其放入 &lt;p:commandLink /&gt; 作为值参数
  • 我已经有 并且没有出现错误信息!我删除了
  • b.t.w 删除空的oncomplete=""

标签: jsf jsf-2


【解决方案1】:

将方法签名改为

public void testMethod(ActionEvent event){
    System.out.println("BussinessOwnerViewerMB.changeMapListener()");
} 

或者把actionListener=...改成action="...

也看看 BalusC

的以下回答

Differences between action and actionListener


编辑

将 bean 的范围更改为 View Scope(现在是它的请求范围)

并阅读 BalusC

h:commandLink / h:commandButton is not being invoked 处的第 N#4 条

【讨论】:

  • thnaks daniel ,但我尝试了所有这些,我的问题不在于 commandLink 只是“因为如果我把它放在 标签之外它工作正常”问题出现在ui:repeat 中的 commandLink 渲染!
  • 你的bussinessOwnerViewerMB bean 的作用域是什么?
  • 将其更改为查看范围(至少),阅读此内容(bullet N#4 stackoverflow.com/a/2120183/617373
  • 太棒了.. 非常感谢丹尼尔,你让我的一天在更改范围以查看范围后工作“但我应该更改所有相关类以实现可序列化”非常感谢 :)
猜你喜欢
  • 2012-11-29
  • 2011-12-30
  • 1970-01-01
  • 2012-01-23
  • 2014-05-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多