문제

행동을 전달하는 방법이 있습니다 <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

나는 혼자서 답을 찾습니다 :). 어쩌면 누군가에게 도움이 될 것입니다.

나는 페이스 렛을 사용하여 이것을했다. 내 페이지에 팝업을 포함하면 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}, 그것은 우리에게 필요합니다 $ 하지만 #.

다른 팁

페이스 섹스를 사용하면 살펴보십시오 Rick Hightower의 기사 "전달 행동"섹션. 사용한 것과 동일한 기본 방법이지만 콩의 방법을 통과합니다.

예 :

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

기본적으로 모달 패널의 출력에는 TestBean의 값이 포함됩니다.

편집 (오해):

나는 당신이 다음과 같이 모달 패널을 정의해야한다고 생각합니다.

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

그리고 당신의 관리 콩에서 당신은 다음과 같이 Java와 함께 동적으로 모달 패널을 추가해야합니다.

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