1

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

我有以下代码:

<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 中的属性),稍后此绑定用于密码验证器。

这一切都很好。

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

当reset按钮被clicket时,registrationBB中的所有属性都被清空,调用如下代码:

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

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

我的问题是:如何访问这个绑定并在 faces 后端删除?

我们使用 jsf 1.2 版。

问候,阿拉什

4

1 回答 1

0

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

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

或者由 a<navigation-case>和 a <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>
于 2012-05-24T12:56:13.793 回答