My site has a page with a datatable. This datatable has a button called 'Edit', where the user can click to edit the data of a single row. When the use clicks on it, he gets redirected to another page, where the data of the selected item will be displayed for him to edit.
The way I make it right now is with a SessionScoped bean, where I can keep the value for the selectedItem variable. However, it feels gross to use SessionScoped here.
Simplified Code:
<h:form>
<p:dataTable id="dataTable" var="item" value="#{exampleController.itens}">
<p:column headerText="Name">
<h:outputText value="#{item.name}" />
</p:column>
<p:column>
<p:commandLink title="Edit" action="/pages/anotherPage?faces-redirect=true">
<f:setPropertyActionListener value="#{item}" target="#exampleController.selectedItem}" />
</p:commandLink>
</p:column>
</p:dataTable>
</h:form>
What is a better way of doing this?
Thank you.