0

I'm working with JSF and EXT js. I have a JSONArray created in the server-side and I want to pass it to client-side. I used to get the array and put it in javascript var. But this tag adds a html tag (span) which make an error in javascript var.

This is the code I wrote:

var data1 = <h:outputFormat value="#{actorBean.newactors}" />

And this is the code of my page after running:

var data1 =<span>[[&quot;aaaaaaa&quot;,&quot;bbbbbbb&quot;]]</span>

so do u have any idea how to get the array without all the tags added ? thanks

1 Answer 1

1

Use

<h:outputText value="#{actorBean.newactors}" escape="false">

The h:outputFormat is only interesting if you want to format your messages. The escape attribute of the h:outputText will disable escaping of HTML entities like " into &quot;.

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

6 Comments

I want to escape the whole html tag :) my data should be this like this : var data1= [["aaa","bbb"]] so the problem persists with the "span" tag how can I strip this tag ?
Then leave the escape attribute away. Only ensure that you don't give it any id or styleClass or consorts, it would indeed otherwise render a <span> (with the id, class, etc).
I put it without these params and still get the span tag :( No id... no Style class Im desperate
Note: <h:outputText escape="false">#{actorBean.newactors}</h:outputText> doesn't work (in JSF1)
@Topera: I've also never mentioned that. The value has to go in value attribute instead. EL in template text is indeed only supported in Facelets 2.x.
|

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.