4

我正在尝试实现“基本对话框框架”,但在实现中没有用......它在控制台中没有显示任何错误......

xhtml 页面 ---> 程序.xhtml

 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui" template="/pages/BaseTemplate.xhtml">
 <ui:define name="body">
 <h:form id="form">
     <p:commandButton value="ABCD" actionListener="#{pc_Program.goToCurrentStage}"/>
 </h:form>
 </ui:define>
 </ui:composition>

托管 bean --> Program.java

 @ManagedBean(name = "pc_Program")
 @SessionScoped
 public class Program{

      public void goToCurrentStage(){
     Map<String,Object> options = new HashMap<String, Object>();  
        options.put("modal", true);  
        options.put("draggable", false);  
        options.put("resizable", false);  
        options.put("contentHeight", 320);  
     RequestContext.getCurrentInstance().openDialog("intimationDepositHome", options, null);
      }
 }

当我单击 program.xhtml 中的命令按钮时,我需要打开一个 intimationDeposit.xhtml 对话框

 <ui:composition xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:p="http://primefaces.org/ui" template="/pages/BaseTemplate.xhtml">
    <ui:define name="body">
    <h:form id="form">
 <p:dataTable id="serDetails" var="bean" value="#{pc_intimationDeposit.pendingReps}" >
   <p:column headerText="Unique Id" style="width: 15px">                                        
   <h:outputText value="#{bean.uniqueId}" styleClass="box text"/>           
   </p:column>
 </p:dataTable>
 </ui:define>
 </ui:composition>

托管 bean ---> IntimationDeposit.java

 @ManagedBean(name = "pc_intimationDeposit")
 @SessionScoped
 public class IntimationDeposit{
 public List<PendingRep> pendingReps = new ArrayList<PendingRep>();
 //setter/getters and some logic to get PendingRep List
 }

在我的 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>

导航案例


 <navigation-rule>
    <from-view-id>*</from-view-id>
    <navigation-case>
        <from-outcome>intimationDepositHome</from-outcome>
        <to-view-id>/pages/intimationDeposit.xhtml</to-view-id>
    </navigation-case>
</navigation-rule>

但是没有打开对话框...并且没有收到任何错误消息...

4

2 回答 2

0

it's possible that you need to use an annotation. I have the same problema and I resolve it using annotation @postconstruct in init method and after do the //setter/getters and some logic to get PendingRep List that you need.

于 2013-11-25T14:44:05.063 回答
0

我也有和你的代码一样的发展。这对我来说是工作。但是,我认为您的代码中没有关键问题。

您的代码中只有一个错误。

there is no end tag `</h:form>` at `intimationDeposit.xhtml` page.

如果是这样,对话框将不会打开。但是你会得到如下错误:

 element type "h:form" must be terminated by the matching end-tag "</h:form>"
于 2014-01-24T10:48:17.457 回答