我有一张表,其中列出了一些演员。这个页面是 actor.xhtml。这是相关的部分:
<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>
因此,当我单击表中的 Go To Actor Detail 链接时,我成功导航到:actorDetail.xhtml?actorId=1
这是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>
这是我的 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;
}
}
但这返回零数据..所以细节没有加载。使用参数 0 调用 actorDao.getWithId。
我错过了什么?
还有一个额外的问题:
我将如何使用 POST 请求执行此操作?