2

我正在尝试使 ap:commandLink 在 primefaces mobile 中的 ap:dataList 中工作。

在此代码段中,commandButton 进入方法内部并重定向到不同的视图,但 commandLink 没有。为什么是这样?

<pm:content id="resultsContent">
    <h:form id="resultsForm">
        <p:dataList type="inset" id="studyList" value="#{navigationBean.studies}" var="study">
            <p:commandLink action="{navigationBean.individualStudy}" update=":studyView">#{study.styRefNum} - #{study.shortDesc}</p:commandLink>
            <p:commandButton value="#{study.styRefNum} - #{study.shortDesc}" action="#{navigationBean.individualStudy}" update=":studyView" />
        </p:dataList>
    </h:form>
</pm:content>


@ManagedBean
@ViewScoped
public class NavigationBean {
    public String individualStudy() {
        System.out.println("in individualStudy");
        return "pm:studyView?transition=slide";
    }
}
4

1 回答 1

1

首先,我想这是您写问题时的错字,但您的actioninp:commandLink错过了前面的#.

现在我可以想到两件事来尝试:

添加process="@this"到您的commandLink

<p:commandLink process="@this" action="#{navigationBean.individualStudy}" update=":studyView">

或尝试actionListener改用:

<p:commandLink actionListener="#{navigationBean.individualStudy}" update=":studyView">

[更新]

或使用remoteCommand

<p:commandLink onclick="studyFunc()" />
<p:remoteCommand name="studyFunc" update=":studyView" actionListener="#{navigationBean.individualStudy}" />
于 2014-04-09T08:53:02.370 回答