0

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:

enter image description here

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

1) is it possible for javascript to extract value from cforeach tag

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

Community
  • 1
  • 1
kinkajou
  • 3,664
  • 25
  • 75
  • 128

1 Answers1

1

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?

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"

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.

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
  • Thanks. Is this method only one time process i.e js is evaluated once. Now if I would like to call the js function then it would return same result as it was first loaded with it was not useful for variable result am I right? Should I make switch to gson? – kinkajou Jul 31 '12 at 23:17
  • I'm not sure what you're concretely asking, but I believe that this has nothing to do with the initial question. Feel free to ask a new question wherein you elaborate the concrete functional requirement in more detail. – BalusC Jul 31 '12 at 23:23
  • Thank you ! I opened more detailed query http://stackoverflow.com/questions/11753112/gson-with-servlet . – kinkajou Aug 01 '12 at 05:41