Pregunta

I would like to use a p:dialog which contains some commandButtons, but I can not call my bean from the command button and don't know why.

On the xhtml page there aere two forms, the first form contains some stuff, like panels, panelgrids, buttons, etc. The second form contains only my dialog.

My beanHandler (beanHandler) is ViewAccessScoped. Everything on this xhtml page is working only my p:panel is not working

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

If I use the page like shown above, the p:panel does not appear on buttonClick. If I change this part of the code

<p:dialog header="Ticket schließen?" widgetVar="dlg" resizable="false" appendToBody="true" rendered="#{beanHandler.lastActivity}" id="dlg">

to

<p:dialog header="Ticket schließen?" widgetVar="dlg" resizable="false" appendToBody="true" rendered="true" id="dlg">

(changed the attribute rendered to true) the dialog is shown, but my buttons are not working (calling the bean not possible). If have no idea why this happens.

Anyone an idea?

Regards

¿Fue útil?

Solución

with the attribute appendToBody you append the actual dialog box direct to the body-element. Through that, it is not in the form anymore. Without a form around, there are no Bean calls possible. Possible solutions:

  • put another <h:form> into the p:dialog
  • change the appendToBody attribute accordingly, possibly set it false and move the p:dialog to another place (direct as a child of your already existing <h:form>)

Hope it helps...

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top