سؤال

هناك طريقة لتمرير العمل في <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

أجد الإجابة بنفسي :). ربما سيكون مفيدا لشخص ما.

لقد فعلت هذا باستخدام Fielelets. عندما أشمل المنبثقة إلى صفحتي، أقرر Parametr به:

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

أين thisPageBean - هل الفول من ما تم استدعاء المنبثقة.

ثم في بلدي المنبثقة أنا كتبت:

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

ومع هذا استدعاد thisPageBean.someAtion. وبعد كل السحر هو ${thisPageBean}, ، هذا ضروري بالنسبة لنا $ لكن لا #.

نصائح أخرى

كما كنت تستخدم Fiellets ثم انظر مقالة ريك هايتور وقسم "اجتياز الإجراءات". إنها الطريقة الأساسية نفسها لما استخدمته، ولكن أيضا يمر في الطريقة على الفول.

على سبيل المثال:

<ui:include src="./WEB-INF/popup/popup.xhtml">
  <ui:param name="yesAction" value="save"/>
  <ui:param name="cancelAction" value="cancel"/>
  <ui:param name="backingBean" value="#{thisPageBean}"/>
</ui:include>

ثم في المنبثقة:

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

لاحظ أنك تستخدم #.

نعم أنا لا أرى أي مشاكل في القيام بذلك. يمكنك استخدام التعليمات البرمجية الخاصة بي إذا كنت تريد:

<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>

أساسا سوف يحتوي الإخراج في لوحة مشروط على القيم في الخيانات

تحرير (سوء الفهم):

أعتقد أنك سوف تضطر إلى تحديد لوحة مشروط الخاصة بك مثل هذا:

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

وفي الفاصوليا المدارة، سيكون لديك لإدخال لوحة مشرويمتك بشكل حيوي مع جافا مثل هذا:

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;
}
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top