< c:forEach>从JSF 1.2迁移到JSF 2.2后不再被识别 [英] <c:forEach> not recognized anymore after migration JSF 1.2 to JSF 2.2

查看:99
本文介绍了< c:forEach>从JSF 1.2迁移到JSF 2.2后不再被识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将应用程序从JSF 1.2升级到JSF 2.

I am upgrading my application from JSF 1.2 to JSF 2.

我正在尝试使用下面的简单forEach标记,但循环内未显示任何内容.

I am trying a below simple forEach tag but it not showing anything inside the loop.

<table 
    id="tab${sectionId}"
    border="0" 
    cellpadding="0" 
    cellspacing="0" 
    width="100%"
    class="listingTable"
>
    <c:forEach
        var="row" 
        rowStatus="index"
        items="#{bean.department.userActivities}"
    >
        <tr>
            <td>
                test
            </td>
         </tr>
    </c:forEach>
</table>

未显示值测试. c:forEach实施是否已更改?

The value test is not showing up. Has the c:forEach implementaion changed?

我尝试用替换,但还有其他问题.它正在渲染其中的内容.但是,如果我内部有一个组件,则无法将支持Bean值分配为该组件的ID.示例如下

I tried replacing with but has some other issue. It is rendering the content inside it. But if I have a component inside , I am not able to assign a backing bean value as ID of the component. Example is as below

<table 
    id="tab${sectionId}"
    border="0" 
    class="listingTable"
>
    <t:dataList
        var="row" 
        rowIndexVar="index"
        value="#{bean.department.userActivities}"
    >
        <h:column>
            <h:outputText id="#{row.activityCode}">test1</h:outputText>
        </h:column>
    </t:dataList>
</table>

因此,用.我无法将支持bean属性分配为组件的ID.我收到错误"java.lang.IllegalArgumentException:组件标识符不能为零长度的字符串"

So, with . I am not able to assign backing bean property as ID of the component. I am receiving the error "java.lang.IllegalArgumentException: component identifier must not be a zero-length String "

任何人都可以帮助我了解c:forEach标记为何不起作用的原因.我有大量的代码正在使用forEach标签.升级后,如果JSF2中不再支持每个forEach,我将不得不删除它们:(

Can anyone please help me in understanding as to why the c:forEach tag is not working. I have huge code which is using forEach tag. With upgrade, I will have to remove every forEach if it is no more supported in JSF2 :(

推荐答案

JSTL taglib/XML名称空间URI在JSTL/JSF/Facelets版本之间来回更改.

JSTL taglib/XML namespace URI has changed forth and back across JSTL/JSF/Facelets versions.

对于具有JSTL 1.0的JSP上的JSF,它是

For JSF on JSP with JSTL 1.0, it is

<%@taglib prefix="c" uri="http://java.sun.com/jstl/core"%>

对于,它是

For JSF on JSP with JSTL 1.1+, it is

<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>

对于 Facelets上的JSF 1.x 使用JSTL 1.1+,它是

For JSF 1.x on Facelets with JSTL 1.1+, it is

<xxx xmlns:c="http://java.sun.com/jstl/core">

对于 JSF 2 .x on Facelets (具有JSTL 1.2+),它是

For JSF 2.x on Facelets with JSTL 1.2+, it is

<xxx xmlns:c="http://java.sun.com/jsp/jstl/core">

对于带有JSTL 1.2+的Facelets上的JSF 2.2+

<xxx xmlns:c="http://xmlns.jcp.org/jsp/jstl/core">

确保选择正确的一个.

无关,对于您实际上最终要解决的基本功能要求,请思考以下相关问题:

Unrelated to the concrete problem, as to the underlying functional requirement which you're actually ultimately trying to solve, head to the following related questions for a thought:

  • Using id="#{...}" causes java.lang.IllegalArgumentException: Empty id attribute is not allowed
  • How to use EL with <ui:repeat var> in id attribute of a JSF component

这篇关于&lt; c:forEach&gt;从JSF 1.2迁移到JSF 2.2后不再被识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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