2
私は単純にユーザーに名前を入力し、その名前のリソースを作成する非常に簡単なページを持っています。ユーザーが送信ボタンを押すと、作成したエンティティのページに直接移動したいと思います。だから私のページには、次のようになります。動的IDを持つPrettyfaceを使用したナビゲーション
<h:form id="form">
<p:fieldset legend="Create new">
<p:panelGrid columns="2">
<h:outputText value="Name" />
<p:inputText value="#{createBean.entity.name}" />
</p:panelGrid>
<p:commandButton value="Create Entity" ajax="false"
action="#{createBean.submit}">
</p:commandButton>
</p:fieldset>
</h:form>
createBean
のsubmit
アクションは今エンティティを永続化する必要があります。これは、副作用として、エンティティにIDを割り当てます。そして今、私はこのエンティティに移動したいと思います。レコードの
<url-mapping id="entity">
<pattern value="/entities" />
<view-id value="/views/entity/list.xhtml"/>
</url-mapping>
<url-mapping parentId="entity" id="entity-detail">
<pattern value="/view/#{id}" />
<view-id value="/views/entity/entityDetail.xhtml"/>
</url-mapping>
::ApacheのMyFacesを2.1.5と3.3.2 PrettyFacesを使用して
public void submit() {
/* Persist entity, entity.getId() will now
return a meaningful value. */
FacesContext context = FacesContext.getCurrentInstance();
NavigationHandler handler = FacesContext.getCurrentInstance().getApplication().getNavigationHandler();
// How could I pass the ID?
handler.handleNavigation(context, null, "pretty:entity-detail");
}
entity-detail
のマッピングは次のようになります。
マッピング「entity-detail」を投稿できますか? – chkal
ああ、確かに。どのように私はそれを忘れることができるかわからない。 –