Jakarta Project: Input Tag library

Version: 1.0

Table of Contents

Overview

The "input" tag extension library lets you present HTML <form> elements that are tied to the ServletRequest that caused the current JSP page to run, or to a JavaBean. That is, using this library, you can easily prepopulate form elements with prior values that the user has chosen -- or with default values for the first time a user hits a web page. This is useful when you need to present the same page to the user several times (e.g., for server-side validation).

You can also automatically build up <select> boxes, making it easier to build data-driven forms. And even if you don't present the same page multiple times, you may want form elements that have default values; this library lets you do that without writing excessive logic.

What is the "Input" tag library? Read more.

Requirements

This custom tag library requires no software other than a servlet container that supports the JavaServer Pages Specification, version 1.1 or higher. Plus any requirements for additional API packages.

Configuration

Follow these steps to configure your web application with this tag library:

To use the tags from this library in your JSP pages, add the following directive at the top of each page:

<%@ taglib uri="http://jakarta.apache.org/taglibs/input-1.0" prefix="input" %>

where "input" is the tag name prefix you wish to use for tags from this library. You can change this value to any prefix you like.

Tag Summary

Input Tags
formCreates a form tag
textDisplays a one-line text-entry box
password Displays a one-line password-entry box
textareaDisplays a multiline textarea
hiddenCreates a hidden form field
selectDisplays a select list
optionDisplays a select option
radioDisplays a radio button
checkboxDisplays a checkbox
 

Tag Reference

form Availability: 1.1

Creates a form tag. See Usage page.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  No   Yes  1.1
 

form name

 attributes  No   Yes  1.1
 

extra form attributes

 attributesText  No   Yes  1.1
 

extra form attributes as text

 bean  No   Yes  1.1
 

id of the bean to use as the default bean for input elements in the form

 method  No   Yes  1.1
 

form method

 action  No   Yes  1.1
 

form action. The url will be passed through response.encodeURL(String) to add session tracking if necessary.

 encType  No   Yes  1.1
 

form encoding type

VariablesNone
ExamplesNone
text Availability: 1.0

Displays a one-line text-entry box. See Usage page.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   Yes  1.0
 

text box name

 default  No   Yes  1.0
 

text box default value

 attributes  No   Yes  1.0
 

extra text box attributes

 attributesText  No   Yes  1.1
 

extra text box attributes as text

 bean  No   Yes  1.1
 

id of the bean to get default value from. Empty string means no bean (not even the default from the form tag, if supplied)

 size  No   Yes  1.1
 

size of the text box

VariablesNone
ExamplesNone
password Availability: 1.1

Displays a one-line password-entry box. See Usage page.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   Yes  1.1
 

password box name

 default  No   Yes  1.1
 

password box default value

 attributes  No   Yes  1.1
 

extra password box attributes

 attributesText  No   Yes  1.1
 

extra text box attributes as text

 bean  No   Yes  1.1
 

id of the bean to get default value from. Empty string means no bean (not even the default from the form tag, if supplied)

 size  No   Yes  1.1
 

size of the password box

VariablesNone
ExamplesNone
textarea Availability: 1.0

Displays a multi-line text-entry box. The body of the textarea tag will be used as the default value if the default attribute is not provided. See Usage page.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   Yes  1.0
 

textarea name

 default  No   Yes  1.0
 

textarea default value

 attributes  No   Yes  1.0
 

extra textarea attributes

 attributesText  No   Yes  1.1
 

extra text box attributes as text

 bean  No   Yes  1.1
 

id of the bean to get default value from. Empty string means no bean (not even the default from the form tag, if supplied)

 cols  No   Yes  1.1
 

the number of columns in the text area

 rows  No   Yes  1.1
 

the number of rows in the text area

VariablesNone
ExamplesNone
hidden Availability: 1.1

Creates a hidden form field. See Usage page.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   Yes  1.1
 

hidden field name

 default  No   Yes  1.1
 

hidden field default value

 attributes  No   Yes  1.1
 

extra hidden field attributes

 attributesText  No   Yes  1.1
 

extra hidden field attributes as text

 bean  No   Yes  1.1
 

id of the bean to get default value from. Empty string means no bean (not even the default from the form tag, if supplied)

VariablesNone
ExamplesNone
select Availability: 1.0

Displays a select list. See Usage page.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   Yes  1.0
 

select name

 default  No   Yes  1.0
 

select default value

 defaults  No   Yes  1.0
 

The default and defaults attributes for select are concatenated together (if they are both specified). The defaults attribute may be a String[], Map or Collection.

 attributes  No   Yes  1.0
 

extra select attributes

 attributesText  No   Yes  1.1
 

extra radio button attributes as text

 bean  No   Yes  1.1
 

id of the bean to get default value from. Empty string means no bean (not even the default from the form tag, if supplied)

 multiple  No   Yes  1.1
 

whether multiple choices are permitted by the select box (true|false)

 size  No   Yes  1.1
 

select box size

 options  No   Yes  1.0
 

options map for select. The key is the option label and the value is the option value.

 optionLabels  No   Yes  1.1
 

options labels for select

 optionValues  No   Yes  1.1
 

options values for select

VariablesNone
ExamplesNone
option Availability: 1.1

Displays a select option. The body of the option tag becomes the label of the option. If the value attribute is not provided then the body also becomes the value of the option. See Usage page.

Tag BodyJSP    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 value  No   Yes  1.1
 

the option value

 attributes  No   Yes  1.1
 

extra option attributes

 attributesText  No   Yes  1.1
 

extra option attributes as text

VariablesNone
ExamplesNone
radio Availability: 1.0

Displays a radio button. See Usage page.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   Yes  1.0
 

radio button name

 default  No   Yes  1.0
 

radio button default value.

 value  Yes   Yes  1.0
 

value can be empty, but it must be present

 attributes  No   Yes  1.0
 

extra radio button attributes

 attributesText  No   Yes  1.1
 

extra radio button attributes as text

 bean  No   Yes  1.1
 

id of the bean to get default value from. Empty string means no bean (not even the default from the form tag, if supplied)

VariablesNone
ExamplesNone
checkbox Availability: 1.0

Displays a checkbox. See Usage page.

Tag Bodyempty    
Restrictions

None

AttributesNameRequired Runtime Expression Evaluation Availability
 name  Yes   Yes  1.0
 

checkbox name

 default  No   Yes  1.0
 

The two "defaults" for checkbox are concatenated together to form an array of size (defaults.length + 1), or 1 if defaults.length is null or isn't present

 defaults  No   Yes  1.0
 

The two "defaults" for checkbox are concatenated together to form an array of size (defaults.length + 1), or 1 if defaults.length is null or isn't present

 value  Yes   Yes  1.0
 

value can be explicitly empty, or it can be absent, in which case it defaults to "on"

 attributes  No   Yes  1.0
 

extra checkbox attributes

 attributesText  No   Yes  1.1
 

extra check box attributes as text

 bean  No   Yes  1.1
 

id of the bean to get default value from. Empty string means no bean (not even the default from the form tag, if supplied)

VariablesNone
ExamplesNone

Examples

See the example application input-examples.war for examples of the usage of the tags from this custom tag library.

Java Docs

Java programmers can view the java class documentation for this tag library as javadocs.

Revision History

Review the complete revision history of this tag library.