Bug 29223 - [PROPOSAL] Tag turns a collection into a javascript function to populate select.
Summary: [PROPOSAL] Tag turns a collection into a javascript function to populate select.
Alias: None
Product: Taglibs
Classification: Unclassified
Component: Unknown Taglib (show other bugs)
Version: 1.0
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL: http://jakarta.apache.org/taglibs/new...
Depends on:
Reported: 2004-05-26 11:54 UTC by Edgar Dollin
Modified: 2006-11-06 13:03 UTC (History)
0 users

Tag to emit a collection as a JS Function (3.06 KB, text/plain)
2004-05-26 11:57 UTC, Edgar Dollin
Javascript to find a field in an html form. (2.01 KB, text/plain)
2004-05-26 11:58 UTC, Edgar Dollin
Updated to use commons libraries. (3.48 KB, text/plain)
2004-06-07 12:25 UTC, Edgar Dollin

Note You need to log in before you can comment on or make changes to this bug.
Description Edgar Dollin 2004-05-26 11:54:51 UTC
One performance problem with dynamic web pages is selects, which repeat the 
same set of options.  I am using this in my applications with great success and 
thought it might be a nice addition to struts.  I don't keep a buildable copy 
of struts so there would be a small amount of integration to apply this code so 
my apologies in advance.

This can be used in apps with and without javascript but it would be up to the 
individual programmer to keep flags around as to the status of javascript on 
his clients.

First we need a tag  [JavaScriptCollection] which takes a collection in any 
scope populated with label value pairs, and turn it into a javascript function 
to populate an html:select statement.  One enhancement to this would be to add 
a label and value attribute so any collection could be used.  Additionally, in 
this I have used a js search function [Struts_eval.js] which I include as a 
standard bit of js but could be worked around, either in the emitted js or by 
someone who knows js better than I.  This has been used in both IE 5.0 and 
higher and current releases of Mozilla.

The html:select needs an additional attribute jsPopulate, which emits the 
following js:

<script type="text/javascript">[valueOf jsPopulate]

An example of the select tag utilizing the features above

<jsp:useBean id="myCollection" class="MyCollectionClass"/>
<bean:jsCollection id="myCollection" function="getMyCollection" />
<html:select property="mySelectProp" jsPopulate="getMyCollection" />

Again, my apologies for not integrating this code into the existing tags.

Comment 1 Edgar Dollin 2004-05-26 11:57:15 UTC
Created attachment 11675 [details]
Tag to emit a collection as a JS Function
Comment 2 Edgar Dollin 2004-05-26 11:58:35 UTC
Created attachment 11676 [details]
Javascript to find a field in an html form.
Comment 3 David Graham 2004-05-26 13:13:24 UTC
Looks like this is suited for the Taglibs project.  It doesn't interact with
Struts' core so there's no reason to limit its usage to Struts projects.
Comment 4 Felipe Leme 2004-06-06 14:35:42 UTC
Hi David,

Please, change the 'Assigned To:' field to taglibs-dev@jakarta.apache.org when
you re-assign us a bug, otherwise we won't be immediatly notified of the change.

Comment 5 Felipe Leme 2004-06-06 14:40:40 UTC
Hi Edgar,

You tag seems interesting, although it doesn't seems to fit on any of our
current taglibs (see the whole list at http://jakarta.apache.org/taglibs/).
That's not a really problem, as we could add it to the Unstandard taglib. But if
we do so, it would be better if you could replace the following classes by
something similar on  other Apache components (like Jakarta Commons Lang),
otherwise it will be a little bit harder to build the component:



Comment 6 Edgar Dollin 2004-06-07 12:24:24 UTC
Here is a version where I used the commons versions of my custom code.  They 
are probably better versions anyway.  I also allowed the label and value pairs 
to be named.

One thing I hope happens in Struts, is that the html:select tag adds the option 
to use this collection population script so that it can be really useful in 

Comment 7 Edgar Dollin 2004-06-07 12:25:31 UTC
Created attachment 11777 [details]
Updated to use commons libraries.
Comment 8 Martin Cooper 2004-06-11 04:44:43 UTC
IMHO, this particular case is too specialised. On the other hand, I think there 
is definitely room for a more general JavaScript-centric tag library that could 
ultimately solve the same problem, and many more to boot.

Essentially, what this is about is serialising Java collections to JavaScript 
source code. While that may sound esoteric, it's actually something I'm deeply 
involved with at my "day job" right now. Anyone who has tried to build highly 
interactive web apps can probably see where this is going, too...

Despite the fact that I'm responding in Bugzilla, I think it would be better if 
we take this discussion to the taglibs-dev list and brainstorm about what a 
comprehensive JavaScript-focussed taglib might look like, as opposed to 
individual special-purpose tags.
Comment 9 Edgar Dollin 2004-06-11 15:10:20 UTC
I am interested in exploiting the client server aspects of the browser so if I 
can be of any help let me know.

Some of the javascript enhancements things that are of interest to me are true 
checkboxes with negative request parameters, true numeric input, javascript 
awareness of application security for functions and menus (w/o view 
specification).  I would like to see struts tags with specific data formats and 
validator javascript (not server side validator), built into type specific tags.

Comment 10 Felipe Leme 2004-06-11 16:37:19 UTC

What about proposing a new taglib for javascript support then?


PS: I set this bug URL to the "New project submission" document
Comment 11 Henri Yandell 2006-11-06 13:03:24 UTC
2 years later - I think it's unlikely this is going to happen. Marking as WONTFIX.