aspose file tools*
The moose likes JSP and the fly likes Custom JSTL Tag (extending BodyTagSupport) to generate javascript array when pass  a java list Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Custom JSTL Tag (extending BodyTagSupport) to generate javascript array when pass  a java list" Watch "Custom JSTL Tag (extending BodyTagSupport) to generate javascript array when pass  a java list" New topic
Author

Custom JSTL Tag (extending BodyTagSupport) to generate javascript array when pass a java list

Micale Raj
Ranch Hand

Joined: Jul 01, 2009
Posts: 30

Dear Friends,

I want to create a custom JSTL tag ( extending BodyTagSupport ) to generate javascript array when pass a java list. I'm new to JSTL and don't know how to start this. I want this new javascript variable to accessed by java script functions.
I think this is possible. How to do this ?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

Micale Raj wrote:I want to create a custom JSTL tag


There's no such thing as a "custom JSTL tag". The JSTL is a predefined tag library. I assume you mean a "custom tag"?

extending BodyTagSupport


You don't want to use BodyTagSupport -- that's JSP 1. You want to use JSP 2's SimpleTagSupport.

I'm new to JSTL and don't know how to start this.


That doesn't matter because this has nothing to do with the JSTL.

I want this new javascript variable to accessed by java script functions. I think this is possible. How to do this ?


You can emit any output you want, including JavaScript markup.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Micale Raj
Ranch Hand

Joined: Jul 01, 2009
Posts: 30

Thanks for the reply. It should be custom tag. I can't use SimpleTagSupport since my project using JSP 1 . I'm trying to do this as following. But I'm getting error : No property editor found for the bean "java.util.List"



The taglib.tld


in Jsp Page,



Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61198
    
  66

JSP 1? That's over 10 years old. There is no excuse for using something so old. What is the reason for this?
Stefan Evans
Bartender

Joined: Jul 06, 2005
Posts: 1018
Extend your tld file to define the attribute of type list
That should look something like:



Looking at your usage in the JSP page. How do you expect "a,b,c" to become a List?
That looks like a comma separated string to me...
# <custom:listToJavaScriptArray list="a,b,c"/>
Micale Raj
Ranch Hand

Joined: Jul 01, 2009
Posts: 30

Stefan Evans wrote:Extend your tld file to define the attribute of type list
That should look something like:



Looking at your usage in the JSP page. How do you expect "a,b,c" to become a List?
That looks like a comma separated string to me...
# <custom:listToJavaScriptArray list="a,b,c"/>


Thanks for the help.
I tried it and it worked. :)
You are right about jsp part. It's a comma separated string. I used a java.util.List from request build the array. Now it's working. Thank you very much ! :)
 
Consider Paul's rocket mass heater.
 
subject: Custom JSTL Tag (extending BodyTagSupport) to generate javascript array when pass a java list