Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to pass json formated string from custom tag to javascript

813274Nov 11 2010 — edited Nov 12 2010
Hi All,

I have one custom tag with one attribute which take the name of the javascript function as a value. I want to pass the string(json data) to this javascript function. I am getting this data from session as my controller generates this data and put it in the session and forward the response to jsp page where I have custom tag. Now when the page loads, it executes the custom tag and utlimately javascipt function provided in the attribute. Some this like below

function jsFunction(jData)
{
var jsonData = eval(jData);
return jsonData;
}

<tag1:customTag id="id1" styleClass="cssClass">

<tag1:subTag id="holiday" startupJsonEventsFunction="jsFunction('this needs to be string object from http session')" />
</tag1:customTag>

Now the string I want to pass in the javascript function is actully json formatted data. But in the javascript function i am creating the json object out of it using "eval(jsonString)". So once this function creates the json object it returns is back to custom tag and it will be used to generate chart.

Can some one tell me how can I grab the string object from session and pass it inside the jsFunction()?

I tried something like this but it is not working????

<tag1:customTag id="id1" styleClass="cssClass">

<tag1:subTag id="holiday" startupJsonEventsFunction="jsFunction(' <%= request.getSession().getAttribute("jsonString")%>')" />
</tag1:customTag>
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 10 2010
Added on Nov 11 2010
1 comment
636 views