更新 panelPopup 的值

update value of a panelPopup

提问人:Anton Styopin 提问时间:8/24/2017 最后编辑:KukeltjeAnton Styopin 更新时间:8/25/2017 访问量:224

问:

我在使用 ICEFaces 时遇到了问题,无法更新我的 ice:panelPopup 的值。我的main.xhtml页面中有一个值wbw

<ice:inputText value="#{main.wbw}" size="5">
    <f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</ice:inputText>

enter image description here

我在我的主 xhtml 页面中包含了第二个 xhtml 页面:

<ui:include src="/resources/includs/second.xhtml" />

在我的第二个.xhtml中,我的值与main.xhtml中的值相同:

<ice:inputText value="#{main.wbw}"/>

enter image description here

问题是,当我更改第二个 .xhtml 中的值时,该值会在 main.xhtml 中自动更改,但是当我关闭弹出窗口并更改主 .xhtml 页面中的值时,他不会更新,也不会更改我的第二个 .xhtml 页面中的值,因此弹出窗口不会更新并将旧值保留在里面。有人知道如何更新值吗?

JSF JSF-2 XHTML 冰面

评论

0赞 Usagi Miyamoto 8/24/2017
你使用了这个属性吗?render
0赞 Anton Styopin 8/24/2017
不,我不使用 render 属性,因为它仅用于渲染组件或不渲染组件。因此,如果我放置 render=“false”,则不会渲染整个输入组件。所以这不是我需要的。我知道在Primefaces中有一个“更新”属性,它完全可以满足我的需求,但ICEFaces没有这个。
0赞 Kukeltje 8/24/2017
IceFaces确实有一个“更新”......你在哪里读到他们没有?
0赞 Anton Styopin 8/24/2017
我还没有找到。你能给我看看吗?
0赞 Usagi Miyamoto 8/24/2017
render将组件的 ID 设置为重新渲染,它仅存在于基于 AJAX 的组件上。你把它混合的是......(在 1.x 中被称为......renderedJSFrenderreRender

答:

0赞 Anton Styopin 8/25/2017 #1

我发现了为什么它没有更新。当弹出菜单关闭时,菜单的状态类似于隐藏,因此该菜单中的值在生命周期中不存在。当您打开弹出窗口时,它们就会被创建。因此,当它关闭时,inputText 是未定义的。当您打开弹出菜单时,您需要通过 javascript 更新值。

var wbw = document.getElementById(inputText_id of main.xhtml).value;
if (document.getElementById(inputText_id of second.xhtml) != null)
    document.getElementById(inputText_id of second.xhtml).value = wbw;

这个解决方案对我有用。打开弹出菜单后,我只是通过 javascript 更新了值。