So I have the following jsf page (working):
<ui:define name="content">
<h:form>
<p:dataTable id="projectList" value="#{studyController.studyList}" var="item">
<p:column headerText="ID" >
<h:outputText value="#{item.id}"/>
</p:column>
<p:column headerText="Name">
<h:outputText value="#{item.name}"/>
</p:column>
<p:column headerText="Action">
<h:commandLink action="#{projectController.openProject(item.id)}" value="Project">
</h:commandLink>
</p:column>
</p:dataTable>
</h:form>
</ui:define>
And this is the bean, that is called on link click:
@Named
public class ProjectController{
private Integer projectId;
public String openProject(Integer projectId){
// this works, System.out.println shows correct setting
this.projectId = projectId;
// now redirect to correct jsf page via faces-config.xml
return "show_project";
}
// this is called by the jsf page to be shown
public Integer getProjectId(){
// this is null :(
return this.projectId;
}
}
My faces-config.xml is something like:
<navigation-rule>
<from-view-id>*</from-view-id>
<navigation-case>
<from-outcome>show_project</from-outcome>
<to-view-id>/project.xhtml</to-view-id>
<redirect/>
</navigation-case>
</navigation-rule>
It all works, except the projectId of the ProjectController is lost between the call of openProject - which is called and debug shows correct id in the console - and the rendering of the page, where the page does someting linke #{projectController.getProjectId} - because this returns null.
How can i retain the value in the bean until the page is rendered? I tried with some @SessionScope, @RequestScope and stuff, but frankly I don't understand the full Extend of the JFS lifecycle.
Just to provide some more info, I'm using JBoss AS 7.2 with PrimeFaces 3.4.2