在传递行动<丰富:modalPanel>
题
有一些方法来传递动作<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
- 从弹出调用什么豆
然后在我弹出我写道:
<a4j:commandButton id="yesButton" value="#{msgs.yesButton}"
action="#{yesAction.someAtion}"
</a4j:commandButton>
和与此我调用thisPageBean.someAtion
。所有魔法${thisPageBean}
,这是我们所必需的$
但没有#
。
其他提示
当你正在使用的Facelets再看看里克·海托华的文章一>和部分“传操作”。这是一个你用什么,而且还通过该方法对bean相同的基本方法。
例如:
<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>
Basicly在模式面板的输出将包含在中,testBean的值
修改(误解)强>:
我相信你会有这样定义你的模式面板:
<rich:modalPanel id="popup" width="261" height="386" autosized="true"left="180" top="200" keepVisualState="true"
binding="#{PopupBean.popupPanel}">
</rich:modalPanel>
而在你的管理豆你将不得不addChildren您模式面板动态,像这样的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;
}
不隶属于 StackOverflow