简体   繁体   English

h:inputText无法自动从Bean更新

[英]h:inputText not updating from bean automatically

I have an h:inputText in my form. 我的表单中有一个h:inputText。 The value is not properly updating when I update its panelGroup. 当更新其panelGroup时,该值未正确更新。 JSF version is 2.1.13. JSF版本是2.1.13。

If I used disable="true" OR displaying the bean value in h:outputText OR refresh the page its updating properly. 如果我使用disable =“ true”或在h:outputText中显示Bean值,或刷新页面其更新正确。 But by default its not happening. 但是默认情况下它不会发生。

<span style="min-width: 100px;"> First Name: #{NewPatient.newPatientBean.firstName}</span>
                <h:inputText id="fname" 
                    value="#{NewPatient.newPatientBean.firstName}"
                    onchange="initialCaps(this);" maxlength="50">
                    <f:ajax execute="@this" event="blur"/>
                </h:inputText>

In the above code 在上面的代码中

First Name: #{NewPatient.newPatientBean.firstName} is properly updating but the inputText is not. 名:#{NewPatient.newPatientBean.firstName}正确更新,但inputText不正确。

Kindly let me know the mistake and solution for the above issue. 请让我知道上述问题的错误和解决方案。 Thanks in advance. 提前致谢。

That will happen when a validation error occurred during the current or previous postbacks. 当当前或先前的回发过程中发生验证错误时,就会发生这种情况。 The input component will then not redisplay the model value, but only the initially submitted value when the component itself failed validation or the local value when another component in the same form failed validation. 然后,输入组件将不会重新显示模型值,而仅在组件本身未通过验证时才重新显示模型初始提交的值,或在同一表单中的另一个组件在验证失败时重新显示局部值。

As the concrete functional requirement is completely absent in the question, it's not possible to propose the right solution for this. 由于问题中完全没有具体的功能要求,因此无法提出正确的解决方案。 So here's just a link which explains the problem more generically which should give new insights as to the cause and the solution: How can I populate a text field using PrimeFaces AJAX after validation errors occur? 因此,这里仅是一个链接,它更笼统地解释了问题,应该给出有关原因和解决方案的新见解: 发生验证错误后,如何使用PrimeFaces AJAX填充文本字段?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM