[英]Primefaces 6.0 Dialog Framework and frameset
我們在Weblogic 11g下使用jsf 2.1 + primefaces 6.0 + primefaces-extensions 6.0.0,mojarra 2.1.7。
由於嵌套對話框的要求,我們第一次使用primefaces 6.0。
在帶有框架的頁面中,使用Dialog Framework從支持bean中打開對話框時,我們檢測到一個問題。
我們在左右兩側都有一個菜單,可以訪問此xhtml頁面(取自展示櫃):
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form>
<p:commandButton value="View" icon="ui-icon-extlink" actionListener="#{dfView.viewCars}" />
</h:form>
</h:body>
</html>
單擊p:commandbutton后,DOM檢查器將顯示對話框已在body和html標記外部創建,如下圖所示:
如果我們使用相同的代碼(沒有框架)創建一個新的.xhtml,然后單擊p:commandButton,結果與預期的一樣,並打開對話框:
我們一直在嘗試從backingBean添加屬性“ appendTo”,但是“ body”或“ @body”或“ @(body)”都不起作用:
package test;
import java.util.HashMap;
import java.util.Map;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import org.primefaces.context.RequestContext;
import org.primefaces.event.SelectEvent;
@ManagedBean(name = "dfView")
public class DFView {
public void viewCars() {
final Map<String,Object> options = new HashMap<String, Object>();
options.put("resizable", false);
options.put("appendTo", "@(body)");
RequestContext.getCurrentInstance().openDialog("viewCars", options, null);
}
public void viewCarsCustomized() {
final Map<String,Object> options = new HashMap<String, Object>();
options.put("modal", true);
options.put("width", 640);
options.put("height", 340);
options.put("contentWidth", "100%");
options.put("contentHeight", "100%");
options.put("headerElement", "customheader");
RequestContext.getCurrentInstance().openDialog("viewCars", options, null);
}
public void chooseCar() {
RequestContext.getCurrentInstance().openDialog("selectCar");
}
public void onCarChosen(final SelectEvent event) {
final Car car = (Car) event.getObject();
final FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "Car Selected", "Id:" + car.getId());
FacesContext.getCurrentInstance().addMessage(null, message);
}
public void showMessage() {
final FacesMessage message = new FacesMessage(FacesMessage.SEVERITY_INFO, "What we do in life", "Echoes in eternity.");
RequestContext.getCurrentInstance().showMessageInDialog(message);
}
}
有沒有解決此問題的方法?
提前致謝,
亞歷杭德羅
PS。 Primefaces 5.2中的相同代碼適用於框架
我正在使用primeface 6.0,並且創建了一個對話框以及一個內部確認對話框。 我解決了與對話框相關的問題,並確認了對話框。
我在內部確認對話框中添加了下一個代碼: <p:confirmDialog appendTo="@(body)"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.