You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2004/05/26 13:54:51 UTC

DO NOT REPLY [Bug 29223] New: - Tag turns a collection into a javascript function to populate select.

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29223>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29223

Tag turns a collection into a javascript function to populate select.

           Summary: Tag turns a collection into a javascript function to
                    populate select.
           Product: Struts
           Version: Unknown
          Platform: All
               URL: http://www.blue-moose.net
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Custom Tags
        AssignedTo: dev@struts.apache.org
        ReportedBy: edgar@blue-moose.net


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]
('[property]','[value]');</script>

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.

Edgar

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@struts.apache.org
For additional commands, e-mail: dev-help@struts.apache.org