List filling taglib ver. 1.5

    Custom JSP tag. Lets you create JavaScript code that fills HTML select control. You can use this component with our JSP JavaScript integration taglib for example. Integration taglib lets you call JSP files right from JavaScript. Your called JSP file must produce JavaScript. And List filling taglib is just a very often required practical case - it helps you fill on the fly select controls.

For example:
 


<%@ taglib uri="taglib.tld" prefix="f" %>

<form>

<select id="s1">

</select>

<f:listfill id="s1" script="true">
   <f:option value="1">Java</f:option>
   <f:option value="2">C#</f:option>
</f:listfill>
...
</form>

and you will get this:

You may obtain options through some array (collection, iterator etc.) and use this object for building your control:
 


<%
   java.util.Vector v=new java.util.Vector();
   v.addElement("Java");
   ...
%>

<f:listfill source="<%=v%>" id="s1" script="true"/>

In this example (our collection contains Strings) tag iterates over elements and creates the control. You can pass a collection of beans also and describe how to get the value and text for options. Attribute option specifies what getXXX method is called on each item in your source for getting options. Attribute value does the same for values. E.g. option="name" means that that getName() call is used for getting options etc.

See also our tips page for some examples (dependent lists).

Tags are:

listfill

Body tag. Creates JavaScript code that will fill the given HTML select control. Parameters are:

1) id describes DHTML id for your HTML select control
2) script Optional parameter. Possible values are true or false. If this value is true than the generated code will be wrapped with <script> tag. Default value is false.
3) source Optional parameter. Describes collection, iterator, enumeration or array with elements (options) for the selection.
4) option Optional parameter. Describes a name for property used for getting options
5) value Optional parameter. Describes a name for property used for getting values

option

Body tag. Describes an option for your control (as tag's body). Parameters are:

1) value Optional parameter. Describes a value for this option.
2) selected Optional parameter. Defines a current status for this option. Possible values are true or false. Default value is false (not selected).

for downloading:

Library: listfilltag.jar    Description: taglib.tld

© Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.