Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 2 从ManageBean中的jsf inputText获取空值_Jsf 2 - Fatal编程技术网

Jsf 2 从ManageBean中的jsf inputText获取空值

Jsf 2 从ManageBean中的jsf inputText获取空值,jsf-2,Jsf 2,我在jsf inputText中遇到了奇怪的问题。在浏览器上,它在输入框中显示管理bean名称和变量名称(即#{loginModel.userName})。下面是我的jsf页面代码 <body> <f:view> <h:form> <h:outputLabel value="Username"></h:outputLabel> <h:inputText value="#{loginModel

我在jsf inputText中遇到了奇怪的问题。在浏览器上,它在输入框中显示管理bean名称和变量名称(即#{loginModel.userName})。下面是我的jsf页面代码

<body>
<f:view>
    <h:form>
        <h:outputLabel value="Username"></h:outputLabel>
        <h:inputText value="#{loginModel.userName}"></h:inputText>
        <h:outputLabel value="Password"></h:outputLabel>
        <h:inputSecret value="#{loginModel.password}"></h:inputSecret>
        <h:commandButton value="Submit" action="#{loginModel.process}" ></h:commandButton>
    </h:form>
</f:view>
</body>
和我的faces-config.xml文件

<managed-bean>
        <managed-bean-name>loginModel</managed-bean-name>
        <managed-bean-class>net.varun.dto.LoginModel</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
</managed-bean>

登录模型
net.varun.dto.LoginModel
一场

下面是我在浏览器上的输出,当我单击submit按钮时,我的输出为空。请尝试以下代码:

更改primefaces进程的h:commandButton、
partialSubmit
ajax

<body>
<f:view>
    <h:form>
        <h:outputLabel value="Username"></h:outputLabel>
        <h:inputText value="#{loginModel.userName}"></h:inputText>
        <h:outputLabel value="Password"></h:outputLabel>
        <h:inputSecret value="#{loginModel.password}"></h:inputSecret>
        <p:commandButton value="Submit" action="#{loginModel.process}" process="@form" partialSubmit="true" ajax="true" />
    </h:form>
</f:view>
</body>

因此,您可以在流程方法中设置断点,以查看更新值

<body>
<f:view>
    <h:form>
        <h:outputLabel value="Username"></h:outputLabel>
        <h:inputText value="#{loginModel.userName}"></h:inputText>
        <h:outputLabel value="Password"></h:outputLabel>
        <h:inputSecret value="#{loginModel.password}"></h:inputSecret>
        <p:commandButton value="Submit" action="#{loginModel.process}" process="@form" partialSubmit="true" ajax="true" />
    </h:form>
</f:view>
</body>