質問

アクションを渡す方法がいくつかあります <rich:modalPanel>. 。「はい」と「いいえ」ボタンを含む単純なポップアップを作成し、このポップアップを別のページで再利用したいのです。そのため、「はい」ボタンが押されたときに別のアクションが呼び出される必要があります。何らかの値を渡す方法があります <rich:modalPanel><a4j:actionparam>:

<a4j:commandButton value="See details…" id="det"
    reRender="popup_dataIdField, …">

    <rich:componentControl for="popup"
        operation="show" event="onclick" />

    <a4j:actionparam name="message" assignTo="#{popupBean.message}"
        value="#{myBean.message}" />                                        
</a4j:commandButton>

しかし、何らかの方法でアクションを実行できるでしょうか?

役に立ちましたか?

解決 2

私は自分自身で答えを見つける:)。多分それは誰かのために参考になります。

私はFaceletsのを使用して、これをやりました。私は私のページへのポップアップが含まれていたとき、私はそれにparametrを渡します:

            <ui:include src="./WEB-INF/popup/popup.xhtml">
                <ui:param name="yesAction" value="${thisPageBean}" />
            </ui:include>  

どこthisPageBeanは - どのようなポップアップ呼び出さからBeanです。

その後、私のポップアップに私が書いた:

 <a4j:commandButton id="yesButton" value="#{msgs.yesButton}"
                     action="#{yesAction.someAtion}"
 </a4j:commandButton>

そして、これで私はthisPageBean.someAtionを呼び出します。すべての魔法はそれが${thisPageBean}が、私たちに必要なのです、$あるなし#ます。

他のヒント

あなたはリック・ハイタワーの記事

はい、これを行うことに問題はありません。必要に応じて、私のコードを使用できます。

<rich:modalPanel id="popup" width="261" height="386"  autosized="true"left="180" top="200" keepVisualState="true">
    <h:panelGrid id="panelGrid">
        <h:outputText value="#{PopupBean.output}" id="popupMessage"/>
            <a4j:commandLink action="#">
                <h:outputText value="Close" />
                <rich:componentControl for="popup" operation="hide" event="onclick"/>
            </a4j:commandLink>
    </h:panelGrid>
</rich:modalPanel>
<h:panelGrid columns="2">
    <a4j:commandLink action="#"  reRender="panelGrid">
        <h:outputText value="Yes" />
        <rich:componentControl for="popup" operation="show" event="onclick"/>
        <a4j:actionparam name="message" assignTo="#{PopupBean.output}" value="#{TestBean.input1}"/>
    </a4j:commandLink>
    <a4j:commandLink action="#" reRender="panelGrid">
         <h:outputText value="No" />
         <rich:componentControl for="popup" operation="show" event="onclick"/>
         <a4j:actionparam name="message2" assignTo="#{PopupBean.output}" value="#{TestBean.input2}"/>
    </a4j:commandLink>
 </h:panelGrid>

基本的に、モーダル パネルの出力には TestBean の値が含まれます。

編集(誤解):

次のようにモーダルパネルを定義する必要があると思います。

<rich:modalPanel id="popup" width="261" height="386"  autosized="true"left="180" top="200" keepVisualState="true"
    binding="#{PopupBean.popupPanel}">
</rich:modalPanel>

そして、マネージド Bean では、次のように Java を使用してモーダル パネルに動的に addChildren を追加する必要があります。

public String action_PoppingThePanel() {
    HtmlCommandButton button = new HtmlCommandButton();
    button.setValue("Yes");
    String action = "#{TestBean.action_yes}";
    MethodExpression methodExpression =
            FacesContext.getCurrentInstance().getApplication().getExpressionFactory().
            createMethodExpression(FacesContext.getCurrentInstance().getELContext(), action, null,
            new Class<?>[0]);

    button.setActionExpression(methodExpression);
    getPopupPanel().getChildren().add(button);
    button = new HtmlCommandButton();
    button.setValue("No");
    String action = "#{TestBean.action_no}";
    methodExpression =
            FacesContext.getCurrentInstance().getApplication().getExpressionFactory().
            createMethodExpression(FacesContext.getCurrentInstance().getELContext(), action, null,
            new Class<?>[0]);

    button.setActionExpression(methodExpression);
    getPopupPanel().getChildren().add(button);        
    getPopupPanel().setRendered(true);
    getPopupPanel().setShowWhenRendered(true);
    return null;
}
scroll top