別の ui:define にある 2 つのフォーム間でパラメーターを渡す必要があります。
左部分がツリーテーブルで、中央部分がフォームである Web サイトがあります。左側のノードをクリックし、その ID を後で使用する中央部分に渡したいと思います。
目標は、ユーザーが左側のツリーテーブルに新しいカテゴリを追加できるようにすることです。そこで、ユーザーがツリーテーブルの「+」記号をクリックすると、それまで非表示だったフォームが表示されるというアイデアを思いつきました。
レイアウトのメイン部分です。
        <p:layoutUnit position="west" size="600" header="Categories" resizable="true" closable="false" collapsible="true">
            <h:form>
                <ui:insert name="westContent">West default content</ui:insert>
            </h:form>
        </p:layoutUnit>
        <p:layoutUnit position="center">
            <h:form>
                <ui:insert name="centerContent">Center default content</ui:insert>
            </h:form>
        </p:layoutUnit>
これは、treetable がある左側のコンテンツです。centerContent にある別のフォームに document.id を渡したいです。
<ui:define name="westContent">
    <h:form id="form">
        <p:treeTable value="#{documentsController.root}" var="document"
                     selection="#{documentsController.selectedNodes}" selectionMode="single">
            <p:column style="width:300px">
                <f:facet name="header">
                    Name
                </f:facet>
                <h:outputText value="#{document.name}" />
            </p:column>
            <p:column style="width:20px">
                <f:facet name="header">
                    Add Category
                </f:facet>
                <p:commandButton value="+" styleClass="ui-priority-primary"
                                 actionListener="#{editorBean.print}"
                                 onclick="addCategory.show();">
                </p:commandButton>
            </p:column>
        </p:treeTable>
    </h:form>
</ui:define>
これは、document.id を渡す中心のコンテンツです。
<ui:define name="centerContent">
    <h:form id="addCategoryForm">
        <p:panel id="addCategory" widgetVar="addCategory" header="New Category" style="margin-bottom:10px;" closable="true" visible="false">
            <p:messages id="messages" />
            <h:panelGrid columns="3">
                <h:outputLabel for="name" value="Name: *" />
                <p:inputText id="name" value="#{editorBean.name}" required="true" label="Name">
                    <f:validateLength minimum="2" />
                </p:inputText>
                <p:message for="name" />
                <h:outputLabel for="description" value="Description: *" />
                <p:inputText id="description" value="#{editorBean.description}" required="true" label="Description"/>
                <p:message for="description" />
            </h:panelGrid>
            <h:panelGrid columns="1">
                <h:outputLabel value="Html" />
                <pe:ckEditor id="editor" value="#{editorBean.html}" interfaceColor="#cccccc" />
                <p:commandButton id="submitButton" value="Submit" update="addCategoryForm" 
                                 icon="ui-icon-disk" actionListener="#{editorBean.print}" />
            </h:panelGrid>
        </p:panel>
    </h:form>
</ui:define>
これは、私が使用しているマネージド Bean の構造です。
@ManagedBean
@Scope("view")
public class EditorBean {
    private String name;
    private String description;
    private String html;
    private boolean isCategory;
    private int id;
}
私はjspとコンストラクターで物事を処理する古いスタイルで作業することに慣れているので、これは私にとってかなり混乱しています。この問題に対する他の解決策を受け入れます。
ツリーテーブルの ID を EditorBean に入力し、後で残りを入力できると思ったのですが、うまくいかないようです。
返信ありがとうございます