且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何将JSF UIInput组件重置为其托管bean值

更新时间:2023-01-27 07:59:30

事实上,可能没有比明确调用 resetValue $更好的方法了c $ c>关于组件。在我的例子中,所有对话框都在同一个大JSF视图树中,底层页面打开它们。因此,从JSF的角度来看,应该保留包含无效输入值的相同视图组件状态,直到我们离开视图为止,因为它无法看到我们如何在客户端切换显示属性。

In fact, there may turn out to be no better way than explicitly calling resetValue on components. In my case, all of the dialogs are in the same big JSF view tree with the underlying page that opens them. So from JSF's perspective, the same view component state including invalid input values should be preserved until we navigate away from the view, as it has no visibility into how we're toggling display attributes client-side.

可能工作的唯一另一件事是,构成对话框的组件实际上没有在JSF视图树中呈现,除非它们可见。就我而言,它们总是被渲染,使用CSS来切换可见性。

The only other thing that might work is if the components that make up the dialog are actually not rendered in the JSF view tree unless they're visible. In my case, they're always rendered, using CSS to toggle visibility.