如何使用JSTL在JSF 1.2页面中强制构建阶段? [英] How to force the build phase in a JSF 1.2 page using JSTL?

查看:93
本文介绍了如何使用JSTL在JSF 1.2页面中强制构建阶段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在JSF应用程序中使用了JSTL标记.通过某些操作,我需要像重新构建一样重新构建组件树.我当前的症状是与组件关联,对象ID重复以及对象过时的其他问题不正确.这是使用在构建阶段使用的c:foreach(不能使用重复标记,请参见示例链接)标记.

I am making use of JSTL tags in my JSF application. With certain actions, I need the component tree to be rebuilt as if it was an initial build. My current symptoms are incorrect object to component associations, duplicate ids, and other issues with stale components. This is using a c:foreach (cannot use a repeat tag, see example link) tag which is used in the build phase.

我的理解是可以强制进行重建,但是我无法找到发生在何处或如何发生.我愿意从客户端或服务器上启动解决方案.

My understanding is that it is possible to force a rebuild, but I haven't been able to find where or how that occurs. I am open to solutions that start on the client or in the server.

有关我正在使用的代码的示例,请参考Richfaces中动态选项卡上的此页面. http://in.relation.to/Bloggers/UsingDynamicallyCreatedRichFacesTabPanelForSearchResults

For an example of the code I am using refer to this page on dynamic tabs in Richfaces. http://in.relation.to/Bloggers/UsingDynamicallyCreatedRichFacesTabPanelForSearchResults

注意:使用ui:repeat或a4j:repeat是不可行的.有关详细信息,请参见示例页面.

其他注意:应用Bean是在会话范围内定义的,它们中的数据必须是,而不是组件树状态.

更新:该问题直接与

Update This question is directly to the issue raised in this article and the first comment. I didn't know how to actually do the workaround in the first comment and the accepted answer led me to it.

推荐答案

我认为不是过时的组件.特别是重复的ID是使用<c:forEach>标记的副作用.这是因为<c:forEach>将多次将任何子组件添加到组件树,并且每次它将尝试使用相同的ID(与<ui:repeat>不同).显然,这会导致ID重复(在链接到的示例中,您会注意到它们没有在<c:forEach>标记内指定任何ID).

I don't think stale components are the issue. The duplicate IDs especially are a side effect of using the <c:forEach> tag. This is because <c:forEach> will add any child componenets to the component tree multiple times and each time it will attempt to use the same ID (unlike <ui:repeat>). This obviously results in duplicate IDs (you will notice in the example you linked to they did not specify any IDs within the <c:forEach> tags).

我不确定视图构建阶段"的含义.如果您查看 JSF文档,您会发现那里没有这样的阶段.无论如何,当您使用<ui:repeat>时,只要用于执行搜索的AJAX调用重新呈现rich:tabPanel,它就应该起作用.

I'm not sure what they mean by the 'view build phase'. If you look at the JSF documentation, you will see that there is no such phase. In any case, when you use <ui:repeat>, as long as the AJAX call you use to perform the search re-renders the rich:tabPanel then it should work.

他们引用<ui:repeat>无效的原因是:

The reason they cited for <ui:repeat> not working was:

您不能为此使用重复组件(ui:repeat或a4j:repeat),因为它们在页面渲染时间内起作用,并且不能在JSF树中创建组件,而只能迭代同一实例.

You could not use repeat components(neither ui:repeat nor a4j:repeat) for that because they work during page render time and do not create components in JSF tree but just iterate the same instance.

在他们的示例中,他们使用了:

And in their example they used:

...
<a4j:commandButton action="#{capitalsBean.search}" value="Search" reRender="output" id="search"/>
...
<a4j:outputPanel id="output">
    <rich:tabPanel id="tapPanel" width="700" rendered="#{not empty capitalsBean.foundCapitals}">
        <c:forEach items="#{capitalsBean.foundCapitals}" var="cap">
        ...

如果您在搜索的a4j:commandButton中指定reRender="output"tapPanel怎么不会出现页面渲染时间" ??

If you are specifying reRender="output" on the search's a4j:commandButton how does 'page render time' not occur for tapPanel??

总而言之,使用<ui:repeat>,JSTL和JSF通常不是很好的伙伴.

In summary, use <ui:repeat>, JSTL and JSF are typically not very good bedfellows.

编辑:我应该先做此操作,因为我没有使用rich:tabPanel的经验,但是<ui:repeat>似乎不能与rich:tabPanel一起使用(但出于某些原因)在您链接到的示例中进行了说明,因此我感到困惑).不过,请不要使用<c:forEach>,而应使用绑定到rich:tabPanel的组件.

I should have done this first since I don't have experience with rich:tabPanel but <ui:repeat>, it appears, cannot be used with rich:tabPanel (but not for the reasons stated in the example you link to, hence my confusion). Don't use <c:forEach> though, use a component binding to the rich:tabPanel.

这篇关于如何使用JSTL在JSF 1.2页面中强制构建阶段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆