我尝试使用以下代码从我的 Backing-Bean 创建一个对话框:
<i>Map<String, Object> options = new HashMap<String, Object>();
options.put("modal", true);
options.put("draggable", true);
options.put("resizable", false);
options.put("closable", true);
options.put("contentHeight", 240);
options.put("contentWidth", 500);
// hint: available options are modal, draggable, resizable, width,
// height, contentWidth and contentHeight
RequestContext.getCurrentInstance().openDialog(
"/verwaltung/registrierung.xhtml", options, null);</i>
这是我的对话框:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<h:form id="form">
<h:panelGrid columns="2" var="Registrierung">
<p:outputLabel value="Benutzer:"
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"></p:outputLabel>
<p:inputText
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"
required="
true" value="#{userBean.user.username}"></p:inputText>
<p:outputLabel value="E-Mail:"
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"></p:outputLabel>
<p:inputText
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"
required="
true" value="#{userBean.user.email}"></p:inputText>
<p:outputLabel value="Passwort:"
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"></p:outputLabel>
<p:inputText
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"
required="
true" value="#{userBean.user.password}"></p:inputText>
<p:outputLabel value="Passwort wiederholen:"
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"></p:outputLabel>
<p:inputText
style="font-family: Arial, Helvetica, sans-serif;font-size:small;"
required="
true" value="#{userBean.user.retypePassword}"></p:inputText>
</h:panelGrid>
<p:commandButton value="Anmelden" ajax="false"
actionListener="#{menuBean.hideRegisterDialog}"
style="margin-top:20px;font-size:small;"
icon="ui-icon ui-icon-arrow-1-e">
<p:ajax event="dialogReturn" update="form" />
</p:commandButton>
</h:form>
</h:body>
</html><i>
我想在按下命令按钮后再次销毁对话框。
和:
public void hideRegisterDialog() {
RequestContext.getCurrentInstance().closeDialog(null);
}
但对话框仍然出现。