如何在jsf中访问inputtext绑定

时间:2012-05-24 09:49:27

标签: jsf

我遇到以下问题,无法在任何地方找到解决方案。

我有以下代码:

<h:inputText id="username" value="#{registrationBB.userName}" binding="#{userNameToConfirm}"/>

以及后来:

<h:inputSecret id="confirmed-password" value="#{registrationBB.userPasswordConfirmed}">
  <f:validator validatorId="usernameNotInPasswordValidator"/>
  <f:attribute name="username" value="#{userNameToConfirm.value}" />
</h:inputSecret>

inputText绑定到#{userNameToConfirm}(它不是任何backingbean中的属性),稍后在密码验证器中使用此绑定。

这一切都运作良好。

但是,这些字段所在的表单包含一个“重置”按钮,该按钮应该清空表单上的所有字段。

当clickt重置按钮时,registrationBB中的所有属性都被清空,并调用以下代码:

getViewRoot().getChildren().clear();

但是,用户名永远不会为空,因为它总是由“#userNameToConfirm”绑定中的值设置。

我的问题是:如何在面后端访问此绑定并删除?

我们使用jsf 1.2版。

的问候, Arash的

1 个答案:

答案 0 :(得分:0)

让重置按钮重新加载页面。

<h:commandButton value="Reset" onclick="location.reload(true)" />

<navigation-case> <redirect>

<h:commandButton value="Reset" action="reloadPagename" />

<navigation-rule>
    <navigation-case>
        <from-outcome>reloadPagename</from-outcome>
        <to-view-id>/pagename.jsf</to-view-id>
        <redirect />
    </navigation-case>
</navigation-rule>
相关问题