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

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

3 Comments

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?
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.
Thank you ! I opened more detailed query stackoverflow.com/questions/11753112/gson-with-servlet .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.