JSF Primefaces TabView 问题
我在 PF 论坛上问过这个问题,但似乎没有人愿意回答,所以我想在这里碰碰运气。
我有一个 ui:repeat,当它位于 TabView 中时,在 Ajax 调用后未正确更新。
简单的场景是我有一个 ui:repeat 指向 ArrayList (ArrayList 包含带有字符串的简单 pojo)。其中我有一个 h:inputText ,其值是 pojo 的字符串 getter/setter。 ui:repeat 包含在 ah:panelGroup 中。我使用 ap:commandButton 运行一个操作来更新 ArrayList(只需向其添加几个对象,即字符串的 Math.random 值),然后更新 h:panelGroup。 ArrayList 中的更新值未反映在 ui:repeat 输入字段中。这似乎只会影响输入字段,因为输出文本字段会正确更新。另外,如果我对 ap:dataTable 执行相同的操作,输入字段将正确更新。如果我删除 Tabview 和 Tab 标签,它就可以正常工作。
由于它在删除选项卡时起作用,我只能假设这是一个错误,并且不是设计为这样工作的。如果有人可以请确认是否是这样或者是否有可行的解决办法。我需要使用 ui:repeat 因为我的字段不是表格格式。从 PF 2.2 迁移后才出现这种情况。我目前使用的是 PF 3.1、Weblogic 10.3.4 和 Mojarra 2.0.4
<p:tabView>
<p:tab title="Test">
<h:form prependId="false">
<p:commandButton id="testStringCheck"
value="Test String Check"
process="@form"
update="testPanel"
action="#{testBean.generateVOwithRandomStrings}">
</p:commandButton>
<h:panelGroup id="testPanel" layout="block">
<ui:repeat value="#{testBean.voList}" var="entry">
<h:outputText value="#{entry.randomString}"/>
<p:inputText style="display:block;"
value="#{entry.randomString}"
size="15">
</p:inputText>
</ui:repeat>
</h:panelGroup>
</h:form>
</p:tab>
</p:tabView>
I asked this in the PF Forum but no one seems to want to answer so I though I'd try my luck here.
I have a ui:repeat that is not being updated correctly after an Ajax call when it is within a TabView.
Simple scenario is I have a ui:repeat pointing at an ArrayList (ArrayList contains simple pojos with a String). Within this I have an h:inputText whose value is the pojo's String getter/setter. The ui:repeat is contained within a h:panelGroup. I use a p:commandButton to run an action to update the ArrayList (just add a couple of objects to it a Math.random value for the String) and then update the h:panelGroup. The updated values in the ArrayList are not reflecting in the ui:repeat input fields. This only appears to be affecting input fields as outputText fields do update correctly. Also if I do the same for a p:dataTable the input field are updated correctly. If I remove the Tabview and Tab tags it works fine.
As it works when removing the Tabs I can only assume this is a bug and not designed to work like this. If someone could please confirm if this is so or if there is a viable work around. I need to use a ui:repeat as my fields are not in a tabular format. This has only occurred since migrating from PF 2.2. I'm currently on PF 3.1, Weblogic 10.3.4 and Mojarra 2.0.4
<p:tabView>
<p:tab title="Test">
<h:form prependId="false">
<p:commandButton id="testStringCheck"
value="Test String Check"
process="@form"
update="testPanel"
action="#{testBean.generateVOwithRandomStrings}">
</p:commandButton>
<h:panelGroup id="testPanel" layout="block">
<ui:repeat value="#{testBean.voList}" var="entry">
<h:outputText value="#{entry.randomString}"/>
<p:inputText style="display:block;"
value="#{entry.randomString}"
size="15">
</p:inputText>
</ui:repeat>
</h:panelGroup>
</h:form>
</p:tab>
</p:tabView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
作为解决方法,我使用 ap:datagrid 而不是 ui:repeat。这实现了我在 ui:repeat 中的外观,所以我很高兴。希望这个错误能够在未来的版本中得到修复。
As a workaround I've used a p:datagrid instead of a ui:repeat. This achieves the look I had in the the ui:repeat so I'm happy. Hopefully this bug will be fixed on future releases.
这是 Primefaces 命令按钮中的一个错误。请参阅以下主题:
http://forum.primefaces.org/viewtopic。 php?f=3&t=17454
您可以尝试
用
替换上面的链接中还有一个有趣的方法,有人已发布,使您能够正确找到要更新的正确 clientId。
http://paste.kde.org/177698/
This is something of a bug in Primefaces commandButton. See the following thread:
http://forum.primefaces.org/viewtopic.php?f=3&t=17454
You can try replacing
With an
<h:commandLink>
Also from the above link here is an interesting method that somebody posted that enables you to correctly find the correct clientId to update.
http://paste.kde.org/177698/
临时解决方案:在 h:panelGroup: 外部插入
并更新 outputPanel 而不是 panelGroup
或者使用 datalist 组件而不是 ui:repeat。
还有一点,我不确定,但你可以尝试,所以更新类而不是 id:
并更新:
@(.testPanelCl)
,不要忘记 panelGroup 的 id,没有 id JSF 无法更新班级temp solution: insert outside h:panelGroup:
and update outputPanel instead of panelGroup
Or use a datalist component instead of ui:repeat.
One more, i'm not sure but you can try, so update class instead id:
and update :
@(.testPanelCl)
, don't forget id of panelGroup, without id JSF can not update by class