我有一个问题,我对 primefaces 和 JSF 完全陌生,可能是我缺乏知识,但我还没有找到答案,我有 XHTML-s,在主要的我有几个按钮,我写了一个反馈对话框,告诉操作成功,以及操作的名称。
对话框出现,看起来不错,但消息始终是我在最后一个按钮上指定的内容。也许我误解了这个概念,任何人都可以帮助我我做错了什么?
这是代码:
豆
@ManagedBean
@ViewScoped
public class ActionSuccessController extends AbstractAction implements
Serializable {
public String setParam(String actionName) {
ResourceBundle messageBundle = ResourceBundle
.getBundle("hu.avhga.web.partner.messages");
description = messageBundle.getString("actionSuccess");
this.actionName = actionName;
return "";
}
...
我有按钮的主要 XHTML
...
<p:commandButton id="lock"
value="#{msg['PartnerAdmin.button.lock']}"
action="#{partnerAccountAdminAction.lock}"
update=":partnerAccountAdminForm :actionSuccessForm"
disabled="#{partnerAccountAdminAction.disabledButtonMap.get('LOCK')}"
rendered="#{partnerAccountAdminAction.passwordAdmin}"
styleClass="gold"
onclick="#{actionSuccessController.setParam(msg['PartnerAdmin.button.lock'])}"
oncomplete="usersTableWidget.filter();actionSuccessDialogVar.show();"/>
<p:commandButton id="unlock"
value="#{msg['PartnerAdmin.button.unlock']}"
action="#{partnerAccountAdminAction.unlock}"
update=":partnerAccountAdminForm :actionSuccessForm"
disabled="#{partnerAccountAdminAction.disabledButtonMap.get('UNLOCK')}"
rendered="#{partnerAccountAdminAction.passwordAdmin}"
styleClass="gold"
onclick="#{actionSuccessController.setParam(msg['PartnerAdmin.button.unlock'])}"
oncomplete="usersTableWidget.filter();actionSuccessDialogVar.show();"/>
<p:commandButton id="suspend"
value="#{msg['PartnerAdmin.button.suspend']}"
action="#{partnerAccountAdminAction.suspend}"
update=":partnerAccountAdminForm :actionSuccessForm"
disabled="#{partnerAccountAdminAction.disabledButtonMap.get('SUSPEND')}"
rendered="#{partnerAccountAdminAction.userAdmin}"
styleClass="gold"
onclick="#{actionSuccessController.setParam(msg['PartnerAdmin.button.suspend'])}"
oncomplete="usersTableWidget.filter();actionSuccessDialogVar.show();"/>
<p:commandButton id="remove"
value="#{msg['PartnerAdmin.button.remove']}"
action="#{partnerAccountAdminAction.remove}"
update=":partnerAccountAdminForm :actionSuccessForm"
disabled="#{partnerAccountAdminAction.disabledButtonMap.get('REMOVE')}"
rendered="#{partnerAccountAdminAction.userAdmin}"
styleClass="gold"
onclick="#{actionSuccessController.setParam(msg['PartnerAdmin.button.remove'])}"
oncomplete="usersTableWidget.filter();actionSuccessDialogVar.show();"/>
...
在此之后,我导入了以下 XHTML:
<p:dialog id="actionSuccessDialogId" header="#{actionSuccessController.actionName}"
styleClass="dialog" closable="false"
widgetVar="actionSuccessDialogVar" modal="true" appendToBody="true" dynamic="true"
resizable="false" showEffect="fade" hideEffect="explode">
<h:form id="actionSuccessForm" style="text-align:center;">
<h:outputText value="#{actionSuccessController.description}" />
<br />
<br />
<p:commandButton id="okButtonId" value="#{msg['Common.ok']}"
onclick="actionSuccessDialogVar.hide()"
type="button" />
</h:form>
</p:dialog>
我确信这些“setParam”总是运行,对我来说似乎没有理由。所以再次问为什么我总是得到“删除”属性的名称。是因为ajax吗?或者因为当我点击某个地方时这些都会运行?我有点困惑。提前致谢!