Form taglib ver. 1.5

    Custom JSP taglib. Provides a JSP based replacement for standard HTML <form> tag with several useful enhancements. Also this taglib serves as an ancestor for other GUI-related tags from Coldtags suite like submission protection and client based validation.

For example:
 


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

<html:form method="post" action="http://host/cgi-bin/script">
   ...
   ...
</html:form>

Tag form automatically encodes URL in action in order to support URL-rewriting.

Body tag parameter lets you add parameters for your form (hidden fields):
 


<html:form method="post" action="http://host/cgi-bin/script">
   <html:parameter name="var1">value for var1</html:parameter>
   <input type=text name=User>
   ...
</html:form>

Also you may modify your existing forms to some MVC framework. Body tag controller lets you describe a real target URL for actions. In this case value for action field will be passed as a parameter for request. For example:
 


<html:form method="post" action="http://host/cgi-bin/script">
   <html:controller name="oldURL">http://host/servlet/OneEntry</html:controller>
   ...
</html:form>

Here data will be actually posted to http://host/servlet/OneEntry and value for action field (http://host/cgi-bin/script) will be passed as a parameter oldURL. So with the very limited changes (replace old form tag with html:form and add controller) you may convert existing web application into MVC-based stuff.

Also you can automatically set target to the hidden iframe (attribute iframe). It lets you easily implement remote scripting with forms.

Tags are:

form

Body tag. Provides a replacement for HTML form tag. Parameters are:

1) name Form's name.
2) action Describes action for your form
3) method Optional parameter. Possible values are GET or POST.
4) target Optional parameter. Describes a target frame.
5) onsubmit Optional parameter. Describes an JavaScript procedure.
5) enctype Optional parameter. Describes an encoding.
6) iframe Optional parameter. Possible values are true or false. If this value is true that target will be set to the automatically created hidden iframe. Default value is false.

parameter

Body tag. Defines a hidden field for your form. Tag's body describes a value. Parameters are:

1) name Describes a name for your field

controller

Body tag. Describes a replacement for action. Old value will be passed as a parameter for request. Parameters are:

1) name Optional parameter. Describes a name for new variable in your request. Default value is targetURL.

for downloading:

Library: formtag.jar    Description: taglib.tld

© Coldbeans      Comments?

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

Also in Coldtags: