|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.samskivert.velocity.FormTool
public class FormTool
The form tool can be placed into an invocation context and used by the template to create form elements which automatically inherit form values which were provided to the page at request time. For example:
Please enter your name: $form.text("name", 40) $form.submit("submit")
If the servlet was invoked with a value for "name", it will be
automatically filled into the "name" form field when it is requested.
| Field Summary | |
|---|---|
protected javax.servlet.http.HttpServletRequest |
_req
A reference to the servlet request in use by this form tool. |
protected boolean |
_useXHTML
Whether or not we should aim to generate XHTML or HTML. |
| Constructor Summary | |
|---|---|
FormTool(javax.servlet.http.HttpServletRequest req)
Constructs a form tool that will use the supplied HTTP servlet request object to prefetch form values. |
|
| Method Summary | |
|---|---|
String |
action(String value)
Generates a hidden form field named action with the
specified value. |
String |
button(String name,
String text,
String extra)
Constructs a button input element with the specified parameter name, the specified button text, and the specified extra text. |
String |
checkbox(String name,
boolean defaultValue)
Constructs a checkbox input field with the specified name and default value. |
String |
fixedCheckbox(String name,
boolean value)
Constructs a checkbox input field with the specified name and value. |
String |
fixedHidden(String name,
Object value)
Constructs a fixed hidden element with the specified parameter name and value. |
protected String |
fixedInput(String type,
String name,
Object value,
String extra)
Generates an input form field with the specified type, name, value and extra attributes. |
String |
fixedOption(String name,
String value,
String item,
Object selectedValue)
Constructs an option entry for a select menu with the specified name, value, item, and selected value. |
String |
fixedText(String name,
String extra,
Object value)
Creates a text input field with the specified name and the specified extra arguments and the specified value. |
String |
fixedTextarea(String name,
String extra,
Object value)
Construct a text area with the specified name, optional extra parameters and the specified text. |
protected String |
getCloseBrace()
Returns the string used to close unmatched tags. |
protected String |
getParameter(String name)
Returns value of the specified query parameter or null if it is not set. |
protected String |
getValue(String name,
Object defaultValue)
Fetches the requested value from the servlet request and entifies it appropriately. |
String |
hidden(String name)
Constructs a hidden element with the specified parameter name where the value is extracted from the appropriate request parameter. |
String |
hidden(String name,
Object defaultValue)
Constructs a hidden element with the specified parameter name where the value is extracted from the appropriate request parameter unless there is no value in which case the supplied default value is used. |
String |
imageSubmit(String name,
String imagePath)
Constructs a image submit element with the specified parameter name and image path. |
String |
imageSubmit(String name,
String value,
String imagePath)
Constructs a image submit element with the specified parameter name and image path. |
String |
imageSubmit(String name,
String value,
String imagePath,
String altText)
Constructs a image submit element with the specified parameter name and image path. |
protected String |
input(String type,
String name,
String extra,
Object defaultValue)
Generates an input form field with the specified type, name, defaultValue and extra attributes. |
String |
option(String name,
String value,
String item,
Object defaultValue)
Constructs an option entry for a select menu with the specified name, value, item, and default selected value. |
String |
password(String name)
Creates a password input field with the specified name and no extra arguments or default value. |
String |
password(String name,
String extra)
Creates a password input field with the specified name and the specified extra arguments with no default value. |
String |
password(String name,
String extra,
Object defaultValue)
Creates a password input field with the specified name, extra arguments and default value. |
String |
radio(String name,
String value)
Creates a radio button with the specified name and value. |
String |
radio(String name,
String value,
String defaultValue)
Creates a radio button with the specified name and value. |
String |
reset(String name,
String value)
Creates a reset form element. |
void |
setUseXHTML(boolean useXHTML)
Used to deactivate XHTML generation for "old skool" Java HTML viewer. |
String |
submit(String text)
Constructs a submit element with the name submit and
the specified button text. |
String |
submit(String name,
String text)
Constructs a submit element with the specified parameter name and the specified button text. |
String |
submitExtra(String text,
String extra)
Constructs a submit element with the name submit and
the specified button text with the specified extra text. |
String |
submitExtra(String name,
String text,
String extra)
Constructs a submit element with the specified parameter name and the specified button text with the specified extra text. |
String |
text(String name)
Creates a text input field with the specified name and no extra arguments or default value. |
String |
text(String name,
String extra)
Creates a text input field with the specified name and the specified extra arguments with no default value. |
String |
text(String name,
String extra,
Object defaultValue)
Creates a text input field with the specified name, extra arguments and default value. |
String |
textarea(String name,
String extra,
Object defaultValue)
Constructs a text area with the specified name, optional extra parameters, and default text. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected javax.servlet.http.HttpServletRequest _req
protected boolean _useXHTML
| Constructor Detail |
|---|
public FormTool(javax.servlet.http.HttpServletRequest req)
| Method Detail |
|---|
public void setUseXHTML(boolean useXHTML)
public String text(String name)
text(String,String,Object)
public String text(String name,
String extra)
text(String,String,Object)
public String text(String name,
String extra,
Object defaultValue)
text("foo",
"size=\"5\" maxLength=\"8\"", "bar") would result in an
input field looking like:
<input type="text" name="foo" value="bar" size="5" maxLength="8"/>Assuming the
foo parameter had no pre-existing value.
public String fixedText(String name,
String extra,
Object value)
public String reset(String name,
String value)
name - the name of the form element (used by JavaScript).value - the name that will appear on the button.public String password(String name)
password(String,String,Object)
public String password(String name,
String extra)
password(String,String,Object)
public String password(String name,
String extra,
Object defaultValue)
password("foo",
"size=\"5\"", "bar") would result in an
input field looking like:
<input type="password" name="foo" value="bar" size="5">Assuming the
foo parameter had no pre-existing value.
public String submit(String text)
submit and
the specified button text.
public String submitExtra(String text,
String extra)
submit and
the specified button text with the specified extra text.
public String submit(String name,
String text)
public String submitExtra(String name,
String text,
String extra)
public String imageSubmit(String name,
String imagePath)
public String imageSubmit(String name,
String value,
String imagePath)
public String imageSubmit(String name,
String value,
String imagePath,
String altText)
public String button(String name,
String text,
String extra)
public String hidden(String name)
public String hidden(String name,
Object defaultValue)
public String fixedHidden(String name,
Object value)
public String action(String value)
action with the
specified value. This is handy when you have multiple forms
submitting to the same servlet and you need to distinguist the
action desired by the user.
public String checkbox(String name,
boolean defaultValue)
public String fixedCheckbox(String name,
boolean value)
public String option(String name,
String value,
String item,
Object defaultValue)
public String fixedOption(String name,
String value,
String item,
Object selectedValue)
public String radio(String name,
String value)
public String radio(String name,
String value,
String defaultValue)
public String textarea(String name,
String extra,
Object defaultValue)
public String fixedTextarea(String name,
String extra,
Object value)
protected String input(String type,
String name,
String extra,
Object defaultValue)
protected String fixedInput(String type,
String name,
Object value,
String extra)
protected String getValue(String name,
Object defaultValue)
protected String getParameter(String name)
protected String getCloseBrace()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||