Primefaces 5.2 对话框表单未提交

Primefaces 5.2 dialog form not submitting

我正在使用 primefaces 5.2 对话框框架从我的支持 bean 中弹出一个对话框。该对话框带有一个简单的登录表单。

main.xhtml 为:

<h:form prependId="false">
  ......
  <p:commandButton value="#{apps['application.sec.login']}" immediate="true" actionListener="#{loginControlBean.fireLoginDialog}" icon="fa fa-fw fa-sign-in" />
  .....
</h:form>

支持 bean LoginControlBean.java 作为:

@Named(value = "loginControlBean")
@SessionScoped
public class LoginControlBean implements Serializable{
  private static final Logger logger =Logger.getLogger(LoginControlBean.class.getName());
  @Inject
  private StaffSession staffSession;
  /* ... get/set pairs ...*/
  ......
  public void fireLoginDialog() {
    Map<String,Object> options = new HashMap<String, Object>();
    options.put("modal", true);
    options.put("draggable", false);
    options.put("resizable", false);
    RequestContext.getCurrentInstance().openDialog("/sec/login", options, null);
  }
  .......
  public void login(ActionEvent event) {
    logger.info("Passed in information: User name: "+staffSession.getTempUserName()+" Password: "+staffSession.getTempPassword());
    .......
  }

login.xhtml 为:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
  xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
  xmlns:f="http://xmlns.jcp.org/jsf/core"
  xmlns:p="http://primefaces.org/ui"
  xmlns:h="http://xmlns.jcp.org/jsf/html">
<h:head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<h:outputStylesheet library="css"  name="default.css"/>
<h:outputStylesheet library="css"  name="cssLayout.css"/>
<title>Staff Login</title>
</h:head>
<h:body>
<ui:composition>
    <h:form id="loginform">
        <p:growl id="logingrowl" sticky="true" showDetail="true" life="60000" />
        <h:panelGrid columns="2" cellpadding="5">
            <h:outputLabel for="username" value="#{apps['application.sec.username']}" />
            <p:inputText id="username" value="#{staffSession.tempUserName}" required="true" label="username" />

            <h:outputLabel for="password" value="#{apps['application.sec.password']}" />
            <p:password id="password" value="#{staffSession.tempPassword}" required="true" label="password" />

            <f:facet name="footer">
                <p:commandButton process="@form" value="Login" update="logingrowl" actionListener="#{loginControlBean.login}"/>
            </f:facet>
        </h:panelGrid>
    </h:form>
</ui:composition>
</h:body>
</html>

对话框正确弹出,当我输入用户名和密码时,然后点击登录按钮。我的后端(服务器端)日志出现异常:

####<Nov 2, 2016 5:20:10 PM AEDT> <Info> <com.longz.ozssc.web.staff.LoginControlBean> <macmini16g.tweedheadstorage.com.au> <OzsscWEBServer> <[ACTIVE] ExecuteThread: '5' for queue: 'weblogic.kernel.Default (self-tuning)'> <<anonymous>> <> <49d77419-9b42-461a-92bb-25b06f512a63-0000001d> <1478067610444> <[severity-value: 64] [rid: 0] [partition-id: 0] [partition-name: DOMAIN] > <BEA-000000> <Passed in information: User name: null Password: null> 

表单中填写的字段绑定到 staffSession,但不幸的是,当我尝试从支持 bean staffSession 访问值时,它是 "null"。似乎表单提交不起作用。

有什么想法吗??

您没有正确设置输入字段的值。

value="#{staffSession.tempUserName}"

您需要将 bean 添加到值中:

value="#{loginControllBean.staffSession.tempUserName}"