Package nl.gx.webmanager.taglib
Class FormTag
- java.lang.Object
-
- javax.servlet.jsp.tagext.SimpleTagSupport
-
- nl.gx.webmanager.taglib.FormTag
-
- All Implemented Interfaces:
javax.servlet.jsp.tagext.DynamicAttributes
,javax.servlet.jsp.tagext.JspTag
,javax.servlet.jsp.tagext.SimpleTag
public class FormTag extends javax.servlet.jsp.tagext.SimpleTagSupport implements javax.servlet.jsp.tagext.DynamicAttributes
Implements the < wm:form > tag. Returns an HTML form tag and a (number of) hidden input tags enclosed in it. Additional inputs can be defined in the body of the < wm:form > tag. The < wm:form > tag is a very complicated piece of functionality that is mostly used to render various types of forms such as the forms defined in the forms module. All these forms are processed by the FormHandler which runs on the frontend and processes forms submitted by users. This FormHandler expects several inputs in the form. The < wm:form > tag automatically generates these. What exactly is generated, depends on the handle. Currently the following builtin handles are supported in the < wm:form > tag:- form: this handle indicates that the form should be processed using the FormHandler.
- formback: go back one page in the form flow.
- search: generates a search form: generates a form for the search functionality.
- forum: generates a form for the forum functionality.
NOTE: The submission of forms generated by this tag requires that the /web/js/form/csrfprotection.js Javascript file has been loaded in the page. Example of usage (1):< wm:form handle="search" onSubmit="doSearch();" > < input type="text" name="keyword" /> < /wm:form >
The example above displays a search form (handle="search"). A search form should specify a keyword, therefore an input is included to set the keyword (using the HTML input tag). Also some javascript should be executed if the form is submitted. The onSubmit parameter takes care of that.
The rendering of the formparts is delegated using the < wm:render > tag (which is also part of the WebManager tag library). This tag renders the form object of the formelement.
Example of usage (2):< wm:form handle="form" onSubmit="return checkForm${formElementId}();" > < input name="dummybutton" type="image" value="" alt="" src="${presentationcontext.website.emptyImage}" style="position: absolute; border-style: none; padding: 0; spacing: 0; text-indent: 0;" height="0" width="0" /> < wm:render object="${formElement.form}" /> < /wm:form >
This prints the back button in a form.
-
-
Constructor Summary
Constructors Constructor Description FormTag()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
doTag()
protected String
getExtraPassOn()
Return a comma-separated list of extra parameters to be used in generating the URL in the form or null if it is not set.protected String
getFrame()
Return frame name or null if it is not set.protected String
getHandle()
Return the name of the handle that should be used.protected String
getOnSubmit()
Return the name of the Javascript function to be used in the 'onSubmit=?...?' attribute of the resulting HTML form tag or null if it is not set.protected String
getTarget()
Return the name of the HTML frame to be used in the 'target=?...?' attribute of the resulting HTML form tag or null if the target attribute is not set.protected boolean
isWebGuidelinesCompliant()
Returns webGuidelinesCompliant is requestedtrue
orfalse
,false
if it is not set.void
setDynamicAttribute(String uri, String localName, Object value)
void
setExtraPassOn(String extraPassOn)
Specifies a comma-separated list of extra parameters to be used in generating the URL in the form.void
setFrame(String frame)
Setter for optional attribute frame.void
setHandle(String handle)
Sets the name of the handle that should be used.void
setOnSubmit(String onSubmit)
Specifies the name of the Javascript function to be used in the 'onSubmit=?...?' attribute of the resulting HTML form tag.void
setTarget(String target)
Specifies the name of the HTML frame to be used in the 'target=?...?' attribute of the resulting HTML form tag.void
setWebGuidelinesCompliant(boolean webGuidelinesCompliant)
Sets the optional attribute webGuidelinesCompliant.
-
-
-
Method Detail
-
setHandle
public void setHandle(String handle)
Sets the name of the handle that should be used. Valid values: see FormTag class description.- Parameters:
handle
- the name of the handle that should be used.
-
getHandle
protected String getHandle()
Return the name of the handle that should be used.- Returns:
- the name of the handle that should be used.
-
setDynamicAttribute
public void setDynamicAttribute(String uri, String localName, Object value)
- Specified by:
setDynamicAttribute
in interfacejavax.servlet.jsp.tagext.DynamicAttributes
-
setExtraPassOn
public void setExtraPassOn(String extraPassOn)
Specifies a comma-separated list of extra parameters to be used in generating the URL in the form. This is the URL of the page to display when an action is performed in the form. By default the following values are already passed on: contentid,dbid,typeofpage,step,orgurl,cfe,forum- Parameters:
extraPassOn
- Comma-separated list of extra passOn-parameters for the URL in the form- See Also:
UrlBuilder
-
getExtraPassOn
protected String getExtraPassOn()
Return a comma-separated list of extra parameters to be used in generating the URL in the form or null if it is not set.- Returns:
- extra passon request parameters
-
setOnSubmit
public void setOnSubmit(String onSubmit)
Specifies the name of the Javascript function to be used in the 'onSubmit=?...?' attribute of the resulting HTML form tag. This JS function can be used e.g. to do some error checking on the form data. Default value is empty (no JS function).- Parameters:
onSubmit
- javascript function name
-
getOnSubmit
protected String getOnSubmit()
Return the name of the Javascript function to be used in the 'onSubmit=?...?' attribute of the resulting HTML form tag or null if it is not set.- Returns:
- onSubmit javascript function name or null if it is not set
-
setTarget
public void setTarget(String target)
Specifies the name of the HTML frame to be used in the 'target=?...?' attribute of the resulting HTML form tag. The response to the form is displayed in the target frame. If the specified frame does not exist, the response is shown in a new window.- Parameters:
target
- , for example _self, _blank, _parent, _top or the name of a frame.
-
getTarget
protected String getTarget()
Return the name of the HTML frame to be used in the 'target=?...?' attribute of the resulting HTML form tag or null if the target attribute is not set.- Returns:
- target or null if it is not set.
-
setFrame
public void setFrame(String frame)
Setter for optional attribute frame. If a value (e.g. OUTP) for this attribute is specified, an HTML input tag is created as follows in the body of the form tag:
< input type="hidden" name="frame" value="OUTP" />
This attribute may be used in conjunction with the attribute "target" to specify the frame to load in the response to the form.- Parameters:
frame
- name of a frame as specified in the layout descriptor
-
getFrame
protected String getFrame()
Return frame name or null if it is not set.- Returns:
- frame name or null if it is not set.
-
setWebGuidelinesCompliant
public final void setWebGuidelinesCompliant(boolean webGuidelinesCompliant)
Sets the optional attribute webGuidelinesCompliant. If a value "true" for this attribute is specified, an HTML button tag is created (in order to meet with Webrichtlijnen article R-pd.13.4). < input type="submit" value="Submit" class="buttonSubmitHidden" />
This attribute only is read if the attribute "handle" equals "formback".- Parameters:
webGuidelinesCompliant
- indicates web-guidelines compliance
-
isWebGuidelinesCompliant
protected final boolean isWebGuidelinesCompliant()
Returns webGuidelinesCompliant is requestedtrue
orfalse
,false
if it is not set.- Returns:
true
orfalse
,false
if it is not set.
-
doTag
public void doTag() throws javax.servlet.jsp.JspException, IOException
- Specified by:
doTag
in interfacejavax.servlet.jsp.tagext.SimpleTag
- Overrides:
doTag
in classjavax.servlet.jsp.tagext.SimpleTagSupport
- Throws:
javax.servlet.jsp.JspException
IOException
-
-