primefaces DialogFramework在open上调用commandButton动作

时间:2014-09-18 09:07:01

标签: jsf primefaces dialog

这是我在openDialog metod上调用对话框的页面

<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"
      xmlns:f="http://java.sun.com/jsf/core"> 
    <h:head>
        <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
    </h:head> 
    <h:body> 

           <h:form>  
            <p:commandButton value="OpenDialog" action="#{cnt.openDialog()}"/> 
           </h:form>

   </h:body>  
</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"
      xmlns:f="http://java.sun.com/jsf/core"> 
    <h:head>
        <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
    </h:head>
<h:body> 
 <h:form id="insModForm">  

            <p:panel id="searchCitizenPanel"   header="Just Panel" > 
                <h:panelGrid columns="2">
                    <h:outputText value="name"/>
                    <p:inputText  value="#{iamasCnt.citizen.name}"/> 
                    <h:outputText value="surname"/>
                    <p:inputText  value="#{iamasCnt.citizen.surname}"/> 
                    <h:outputText   value="bdate"/>
                    <p:calendar value="#{iamasCnt.citizen.bdate}"/>  
                    <h:outputText   value=""/>
                    <p:commandButton value="check"   action="#{cnt.searchThis()}"  />   
                </h:panelGrid> 
            </p:panel> 
  </h:form>
</h:body> 

和CDI,我称之为主要面孔框架对话框

@Named("cnt")
@SessionScoped
public class IAMASController implements Serializable {

    public void openDialog() {
        logger.info("// opendialog");

        Map<String, Object> options = new HashMap<String, Object>();
        options.put("modal", true);
        options.put("draggable", false);
        options.put("resizable", false);
        options.put("contentHeight", 720);
        options.put("contentWidth", 720);
        RequestContext.getCurrentInstance().openDialog("/dialogTest/dialog", options, null);
    }

 }

我刚使用primefaces对话框架遇到了一些问题 问题是p:commandButton action searchThis()每次打开素面对话框时都会调用

1 个答案:

答案 0 :(得分:0)

我找到了!有这么奇怪的情况 我把评论放在

旁边
<p:commandButton value="check"   action="#{cnt.searchThis()}"/><!-- action="#{iamasCnt.hiddenSearch()}"--> 

由于jsf问题hiddenSearch()每当对话框加载时都会调用注释中的操作,所以我摘下了这个注释一切正常