sunlabs.brazil.template

Class FormTemplate

public class FormTemplate extends Template

Template class for substituting default values into html forms. This class is used by the TemplateHandler. The default values in form elements are replaced by the request property that matches the field name. The following field elements are processed: In all cases, the value attribute must be present. additional information is provided below.

If the enclosing <form> tag has the attribute "prepend", then "prepend" is tacked on the front of each variable name before its value is looked-up. The "prepend" attribute is then removed from the form tag.

Version: @(#)FormTemplate.java 2.4

Author: Stephen Uhler

Method Summary
booleandone(RewriteContext hr)
This is for debugging only !
booleaninit(RewriteContext hr)
Save a reference to our request properties.
voidtag_form(RewriteContext hr)
Look for a "prepend" attrubute, remember its value, then remove it from the tag.
voidtag_input(RewriteContext hr)
Look for <input name=[x] value=[v]> and replace the value with the entry in the request properties.
voidtag_option(RewriteContext hr)
Look at the option tag, set the "selected" attribute as needed.
voidtag_select(RewriteContext hr)
Remember the variable name for the next group of option tags.
voidtag_slash_form(RewriteContext hr)
Forget about the "prepend" value
voidtag_slash_select(RewriteContext hr)
Forget the variable name for the next group of option tags

Method Detail

done

public boolean done(RewriteContext hr)
This is for debugging only !!

init

public boolean init(RewriteContext hr)
Save a reference to our request properties.

tag_form

public void tag_form(RewriteContext hr)
Look for a "prepend" attrubute, remember its value, then remove it from the tag.

tag_input

public void tag_input(RewriteContext hr)
Look for <input name=[x] value=[v]> and replace the value with the entry in the request properties. If no value is supplied, no substitution is done. If value contains any ${..} constructs, the substituted value is used instead of the value in the corrosponding request property.

tag_option

public void tag_option(RewriteContext hr)
Look at the option tag, set the "selected" attribute as needed. In order for this to work, the VALUE tag *must* be used Do ${...} substitutions on the value.

tag_select

public void tag_select(RewriteContext hr)
Remember the variable name for the next group of option tags.

tag_slash_form

public void tag_slash_form(RewriteContext hr)
Forget about the "prepend" value

tag_slash_select

public void tag_slash_select(RewriteContext hr)
Forget the variable name for the next group of option tags