2
votes

I'm trying to make a p:commandLink work in a p:dataList in primefaces mobile.

In this snippet, the commandButton gets inside the method and redirects to a different view, but the commandLink does not. Why is this?

<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";
    }
}
1
Place the commandLink inside a <p:column/>kolossus
I tried that. Didn't work.Catfish
What does the generated HTML look like?kolossus
Here's the generated HTML pastebin.com/fDxLPAb6Catfish

1 Answers

1
votes

First, I guess it's a typo when you were writing the question, but your action in p:commandLink misses a preceding #.

Now I can think of two things to try:

add process="@this" to your commandLink

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

or try using actionListener instead:

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

[UPDATE]

or using remoteCommand:

<p:commandLink onclick="studyFunc()" />
<p:remoteCommand name="studyFunc" update=":studyView" actionListener="#{navigationBean.individualStudy}" />