使用jstl读取bean列表并在facelets中分配javascript变量 [英] Reading bean list using jstl and assigning to javascript variable in facelets

查看:128
本文介绍了使用jstl读取bean列表并在facelets中分配javascript变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用facelet和draw函数有jstl标签:

I am using facelet and draw function has jstl tag:

               <ui:define name="content" >
                <h:outputScript name="js/graphics/paths.js"/> 
                <h:outputScript name="js/graphics/draw.js"/> 



调用函数时要评估的标记(可能)?



Tag to be evaluated when function is called(is that possible)?

function showMap(){

 var data = {
        <c:forEach items="${list.KPI}" var="ctag" varStatus="loop">        
            '${ctag.USTER}': ${ctag.Value}
            ${!loop.last ? ',' : ''}
        </c:forEach>
    }     
}



错误:



Error:

是否可以将jstl与facelets一起使用?为什么我会收到此错误?我在那里使用链接:

Is it possible to use jstl with facelets? Why am i getting this error? I am using there links:

1) javascript是否可以从cforeach标记中提取值

2) populating-javascript-array-from-jsp-list

推荐答案

肯定JSTL在Facelets中工作。只有一些技术含义只有真正了解Facelets生命周期才能理解: JSF2 Facelets中的JSTL ......有意义吗?

Surely JSTL works in Facelets. There are only some technical implications which can only be understood by really understanding the Facelets lifecycle: JSTL in JSF2 Facelets... makes sense?

关于你的具体问题,你很可能忘了申报JSTL taglib XML命名空间。

As to your concrete problem, you most likely forgot to declare the JSTL taglib in the XML namespace.

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

不执行此操作会导致JSTL标记完全无法解释并结束在生成的HTML / JS代码中出现语法错误,因为Web浏览器无法将JSTL标记识别为有效的HTML / JS代码。右键单击webbrowser中的页面并执行查看源。你应该在那里看到任何未解析/普通的JSTL标签。

Not doing so would cause the JSTL tags not being interpreted at all and end up in a syntax error in the generated HTML/JS code because JSTL tags are not recognizeable by the webbrowser as valid HTML/JS code. Rightclick page in webbrowser and do View Source. You should not see any unparsed/plain JSTL tags in there.

这篇关于使用jstl读取bean列表并在facelets中分配javascript变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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