2013-07-04 63 views
4

想實現「基本對話框架」,但在執行沒有用...... 它沒有顯示任何錯誤控制檯...對話框架PrimeFaces 4.0不工作

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); 
     } 
} 

我需要打開intimationDeposit.xhtml的對話,當我在program.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> 

管理豆---> 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> 

但沒有打開對話框...並沒有得到任何錯誤信息...

+0

你的瀏覽器Web控制檯中是否有任何JavaScript錯誤? – Sonic

+0

控制檯沒有錯誤 – Ranjan

+0

通過包含jquery-plugins.js進行檢查。 –

回答

0

您可能需要使用註釋。我有同樣的問題,我解決它在init方法中使用註釋@postconstruct並在執行// setter/getters和一些邏輯來獲得您需要的PendingRep列表。

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