0

I'm trying to close a dialog with a cancel button, I receive the event but the dialog does not close. After a lot of digging I realize the problem is where the dialog has an input field with the ticket description, but it works when I remove it and I leave only de buttons.

Does it make any sense?

Form base code

...
<p:commandButton icon="fa fa-bug" actionListener="#{ticketBean.viewTicket}"/>
...

TicketBean code

@ManagedBean
@ViewScoped
public class TicketBean {
...
public void viewTicket() {
    logger.info("--------------ViewTicket");
    Map<String, Object> options = new HashMap<>();
    options.put("modal", true);
    options.put("width", 640);
    options.put("height", 250);
    options.put("resizable", false);
    options.put("contentWidth", "100%");
    options.put("contentHeight", "100%");
    options.put("closable", false);

    RequestContext.getCurrentInstance().openDialog("maintenance/ticket", options, null);
}

public void cancel() {
    RequestContext.getCurrentInstance().closeDialog(null);
}
...

ticket.xhtml dialog code DOES NOT WORK

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <h:head>
        <title>#{msgs.ticket_create}</title>
    </h:head>

    <h:body>
        <h:form id="frmTicket">
            <p:inputTextarea rows="5" cols="70" value="#{ticketBean.ticket.descripcio}" >
            </p:inputTextarea>
            <br/>
            <h:inputHidden value="#{ticketBean.ticket.path}" />
            <p:commandButton value="#{msgs.save}" style="width:auto" 
                      styleClass="GreenButton"
                      actionListener="#{ticketBean.save}"/>
            <p:commandButton value="#{msgs.cancel}" style="width:auto" 
                      styleClass="RedButton"
                      actionListener="#{ticketBean.cancel}"/>
        </h:form>
    </h:body>

</html>

ticket.xhtml dialog code DOES WORK

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui"
      xmlns:ui="http://java.sun.com/jsf/facelets">

    <h:head>
        <title>#{msgs.ticket_create}</title>
    </h:head>

    <h:body>
        <h:form id="frmTicket">
            <p:commandButton value="#{msgs.save}" style="width:auto" 
                      styleClass="GreenButton"
                      actionListener="#{ticketBean.save}"/>
            <p:commandButton value="#{msgs.cancel}" style="width:auto" 
                      styleClass="RedButton"
                      actionListener="#{ticketBean.cancel}"/>
        </h:form>
    </h:body>

</html>

faces-config.xml

...
<application>
  <action-listener>
    org.primefaces.application.DialogActionListener
  </action-listener>
  <navigation-handler>
    org.primefaces.application.DialogNavigationHandler
  </navigation-handler>
  <view-handler>
    org.primefaces.application.DialogViewHandler
  </view-handler>
</application>
...

web.xml

...
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
...
Kukeltje
  • 12,223
  • 4
  • 24
  • 47
Joe
  • 7,749
  • 19
  • 60
  • 110
  • options.put("closable", false); ? you've tried options.put("closable", true); ? – Angelo Dec 15 '16 at 13:50
  • I already tried that, what that option does is to show a X to close the dialog. – Joe Dec 15 '16 at 13:53
  • Ok and why you use closeDialog(null)? you should use: closeDialog("maintenance/ticket") for close this dialog -->"maintenance/ticket" – Angelo Dec 15 '16 at 13:54
  • We are using Dialog Framework, not a simple dialog. Look this example http://www.primefaces.org/showcase/ui/df/nested.xhtml – Joe Dec 15 '16 at 14:13
  • are you SURE nested dialogs are supported on your PrimeFaces version? – Kukeltje Dec 15 '16 at 14:32
  • Yes, I am using primefaces 6. And t'he Example from web works well – Joe Dec 15 '16 at 15:23

1 Answers1

0

The solution is to change the code

<p:inputTextarea rows="5" cols="70" value="#{ticketBean.ticket.descripcio}" >
</p:inputTextarea>

for this one

<h:inputTextarea rows="5" cols="70" value="#{ticketBean.ticket.descripcio}" >
</h:inputTextarea>

The problems seems to be with the coponent p:inputTextarea

*Possible primefaces 6 bug

Joe
  • 7,749
  • 19
  • 60
  • 110