【发布时间】:2017-01-24 10:51:01
【问题描述】:
我们在 weblogic 11g 下使用 jsf 2.1 + primefaces 6.0 + primefaces-extensions 6.0.0,mojarra 2.1.7。
由于嵌套对话框的要求,我们首次使用 primefaces 6.0。
在带有框架的页面中使用对话框框架从支持 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);
}
}
这个问题有解决办法吗?
提前致谢,
亚历杭德罗
附言。 Primefaces 5.2 中的相同代码适用于框架
【问题讨论】:
标签: jquery ajax jsf jsf-2 primefaces