I have a table where I list some actors.. This page is actor.xhtml. Here is the relavent part:
<p:dataTable id="allActors" var="actor" value="#{actorTableBackingBean.allActors}">
<p:column headerText="Actor Name" sortBy="#{actor.firstName}">
<h:outputText value="#{actor.firstName}"/>
</p:column>
<p:column headerText="Actor Detail">
<h:link value="Go to actor detail" outcome="actorDetail?actorId=#{actor.actorId}" />
</p:column>
</p:dataTable>
So when I click link Go To Actor Detail in the table, I am successfully navigated to: actorDetail.xhtml?actorId=1
And here is actorDetail.xhtml:
<ui:composition template="../maintemp.xhtml">
<f:metadata>
<f:viewParam name="actorId" value="#{actorDetailBackingBean.actorId}" />
</f:metadata>
<ui:define name="mainarea">
<div class="well" style="padding: 15px" >
<h3>Actor Detail</h3>
</div>
#{actorDetailBackingBean.actorWith().firstName}
</ui:define>
</ui:composition>
And here is my ActorDetailBackingBean.java :
@Named
@RequestScoped
public class ActorDetailBackingBean extends BasePage {
@Inject
ActorDao actorDao;
@Inject
Actor actor;
private int actorId;
public int getActorId() {
return actorId;
}
public void setActorId(int actorId) {
this.actorId = actorId;
}
public Actor actorWith(){
actor = actorDao.getWithId(actorId);
return actor;
}
}
But this returns zero data.. So the detail is not loaded. actorDao.getWithId is called with parameter 0.
What is it that I am missing?
Also a bonus question:
How would I do this with a POST request?