Magazine
 
Struts2 Tags
 

Add the following code snippet into the struts.xml file.

<action name=”submitTag”>
<result>/pages/formTags/submitTag.jsp</
result>
</action>

Create a jsp using the tag <s:submit> This tag renders a submit button. This tag contains various parameters:
The value parameter presets the value of input
element. In our 1st case we have set it to “Submit”.
The type parameter sets the types of submit to use. Valid values are input, button and image. In our case we have set it to “image” The src supply an image src for image type submit button. It will have no effect for types
input and button. In our case we have set it
to:”/ struts2UIformtags /pages/ formTags / submit.gif”
The align sets HTML align attribute. In our case we have set it to:”center”

submitTag.jsp

<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Submit Tag Example</title>
</head>
<body>
<h2>Submit Tag Example</h2>
<s:form>
<s:textfield name=”username” label=”User
Name” size=”15" maxlength=”10" />
<s:textfield name=”password”
label=”Password” size=”15" maxlength=”10" /
>
<s:submit value=”Submit” />
<!— To use gif image on button —>
<s:submit type=”image” src=”/
struts2UIformtags/pages/formTags/
submit.gif” align=”center” />
</s:form>
</body>
</html>

 

Output of the submitTag.jsp:

 

17. Textarea Tag (Form Tag) Example

The textarea tag is a UI tag that is used to render HTML textarea. Add the following code snippet into the
struts.xml file.

<action name=”textareaTag”>
<result>/pages/formTags/textareaTag.jsp</
result>
</action>

Create a jsp using the tag <s:textarea > This tag renders HTML textarea tag. <s:textarea label=”Description”
name=”description” cols=”15" rows=”10" /> tag displays a HTML textarea with label equal to Description, column value=15 and row value=10.

Feb 2008 | Java Jazz Up | 51
previous
index
next
 
View All Topics
All Pages of this Issue
Pages: 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,

30
, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53 , 54, 55, 56, 57,

58
, 59, 60, 61, 62, 63 , 64, 65 , 66 , 67 , 68 , 69 , 70 , 71 , 72 ,

Download PDF