Pergunta

I have been trying to create a link in each row of a datable like that :

        <f:view>
        <h:form>
            <p:dataTable id="TasksList"
                         value="#{TaskController.tasks}"
                         var="task"
                         rendered="#{TaskController.currentCorbeilleId != null}">
                <p:column>
                    ...
                </p:column>
                <p:column>
                    ...
                </p:column>
                <p:column>
                    ...
                </p:column>
                <p:column>
                   ...
                </p:column>
                <p:column>
                    <f:facet name="header">
                        <h:outputText value="Link" />
                    </f:facet>
                    <h:commandLink value="GO" action="goToTask">
                        <f:setPropertyActionListener value="#{task.id}" target="#{TaskController.currentTaskId}"/>
                    </h:commandLink>
                </p:column>
            </p:dataTable>
        </h:form>
    </f:view>

But this is not working. When I click on "GO" the current page just reloads... I tried to copy/post this part of the code outside the datatable :

<h:commandLink value="GO" action="goToTask">
    <f:setPropertyActionListener value="#{task.id}" target="#{TaskController.currentTaskId}"/>
</h:commandLink>

And in the case the link works. How can I do to make it works within the datatable?

Thank you for your answers,

Martin

Foi útil?

Solução

Try putting your TaskController bean into view scope. I had similar problems if the bean containing the collection for the datatable was request scoped!

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top