对话框框架在有输入字段时不会关闭

时间:2016-12-15 13:13:35

标签: primefaces jsf-2.2 dialog-framework

我试图用取消按钮关闭对话框,我收到了该事件,但对话框未关闭。 经过大量的挖掘后,我意识到问题是对话框有一个带有故障单描述的输入字段,但是当我删除它并且我只留下de按钮时它会起作用。

它有意义吗?

表单基本代码

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

TicketBean代码

@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对话框代码无效

<!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对话框代码正常工作

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

面-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>
...

1 个答案:

答案 0 :(得分:0)

解决方案是更改代码

s.replace("th", "dogs").replace("sh", "dogs")

这个

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

问题似乎与组件p:inputTextarea

有关

*可能的primefaces 6 bug