PrimeFaces コンポーネントを使用する JSF ページに問題があります。長くてすぐに飽きてしまうかもしれないので、できるだけ簡潔にしようと思います。次のマネージド Bean について考えてみましょう。
@Named(value = "testBean")
@RequestScoped
public class TestBean implements Serializable {
private String test;
public String update() {
test = "Updated.";
return "test";
}
// Getters and Setters...
}
test.xhtml
無関係なコンテンツとスタイルが削除された の本文は次のとおりです。
<h:body>
<p:layout id="layout" fullPage="true">
<p:layoutUnit position="north">
<!-- Does not matter -->
</p:layoutUnit>
<p:layoutUnit id="input" position="west">
<p:panel header="">
<p:tabView>
<p:tab title="">
<!-- INPUTS and SUBMIT BUTTON -->
</p:tab>
</p:tabView>
</p:panel>
</p:layoutUnit>
<p:layoutUnit id="output" position="center">
<h:form>
<p:panel id="display" header="Information">
<h:outputText value="#{testBean.test}" />
</p:panel>
<p:separator />
<p:commandButton value="Update !" action="#{testBean.update()}" ajax="false" />
</h:form>
</p:layoutUnit>
<p:layoutUnit position="south">
<!-- Does not matter -->
</p:layoutUnit>
</p:layout>
</h:body>
そして、すべてがうまくいきます。ただし、2つの問題があります。
commandButton
を別のlayoutUnit
(入力)に移動する必要がありますが、<h:form>
要素を適切な位置に配置できません。すべてのレイアウト ユニットを囲むように横に移動しようとしまし<p:layout>
たが、壊れました (更新されたページには "Updated." という文字列がなくなりました)。別のlayoutUnitのボタンでajax経由で更新したい。
ajax="false"
から属性を削除し、グローバル フォーム要素commandButton
の属性を設定するとprependId="false"
、出力テキストが更新されません。
よろしくお願いいたします。