我想使用ap:dialog,其中包含一些commandButtons,但是我无法从command按钮调用bean,也不知道为什么。
在xhtml页面上,有两种形式,第一种形式包含某些内容,例如面板,panelgrid,按钮等。第二种形式仅包含我的对话框。
我的beanHandler(beanHandler)是ViewAccessScoped。此xhtml页面上的所有内容均正常运行,而我的p:panel不正常
<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:m="http://java.sun.com/jsf/composite/components/mmnet">
<h:form id="activityForm">
<p:panel >
...
...
<f:facet name="footer">
...
<p:commandButton id="readyButton"
action="#{beanHandler.toggleStatus()}"
rendered="#{beanHandler.ready}"
value="#{labels.erledigt}"
icon="ui-icon-check"
update="@form :dialogForm"
onclick="dlg.show()">
<p:tooltip for="readyButton" style="width:300px;">
<h:outputText value="#{messages.adviceWfEventActivityFinish}" />
</p:tooltip>
</p:commandButton>
</f:facet>
</p:panel>
</h:form>
<h:form id="dialogForm">
<p:outputPanel id="justAPanel">
<p:dialog header="Ticket schließen?" widgetVar="dlg" resizable="false" appendToBody="true" rendered="#{beanHandler.lastActivity}" id="dlg">
<h:panelGrid columns="2" style="margin-bottom:10px">
<h:outputLabel value="Soll das Ticket geschlossen werden?" />
<p:spacer />
<p:commandButton id="yesButton"
value="#{labels.ja}" update=":workflowContentPanel"
onclick="dlg.hide()"
action="#{beanHandler.closeTicket()}" process="@form"/>
<p:commandButton id="noButton" value="#{labels.nein}" update=":workflowContentPanel" onclick="dlg.hide()"/>
</h:panelGrid>
</p:dialog>
</p:outputPanel>
</h:form>
</ui:composition>
如果我使用上面显示的页面,则p:panel不会出现在buttonClick上。如果我更改代码的这一部分
<p:dialog header="Ticket schließen?" widgetVar="dlg" resizable="false" appendToBody="true" rendered="#{beanHandler.lastActivity}" id="dlg">
到
<p:dialog header="Ticket schließen?" widgetVar="dlg" resizable="false" appendToBody="true" rendered="true" id="dlg">
(将属性更改为true),将显示对话框,但是我的按钮不起作用(无法调用Bean)。如果不知道为什么会这样。
有人有主意吗?
问候
使用该属性,appendToBody
可以将实际对话框直接附加到body
-element。通过它,它不再是形式。没有周围的形式,就不可能进行Bean调用。可能的解决方案:
<h:form>
进入p:dialog
appendToBody
属性,可以对其进行设置并将其false
移动p:dialog
到另一个位置(直接作为您已经存在的子对象<h:form>
)希望能帮助到你...
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句