Magazine
 
Struts2 Tags

Add the following code snippet into the struts.xml file

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

Create a jsp using the tag <s:form>.It renders HTML as an input form

formTag.jsp

<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Form Tag Example</title>
</head>
<body>
<h2>Form Tag Example</h2>
<s:form>
<s:textfield name=”username”
label=”Login name”/>
<s:password name=”password”
label=”Password”/>
<s:submit value=”Login” align=”center”/>
</s:form>
</body>
</html>


Output of the formTag.jsp:

9. Label Tag (Form Tag) Example The label tag is a UI tag that is used to render

 

an HTML LABEL that allow to output label:name type of combinations that has the same format treatment as the rest of UI controls.

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

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

Create a jsp using the tag <s:label> It renders an HTML LABEL that allow to output <s: label name=” “ value=” “ /> combination that has the same format treatment as the rest of UI controls.

labelTag.jsp

<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Label Tag Example</title>
</head>
<body>
<h2>Label Tag Example</h2>
<s:form>
<s:label name=”name” value= “Name” />
<s:label name=”roll” value= “Roll” />
<s:label name=”address” value=
“Address: “ />
</s:form>
</body>
</html>

 
Feb 2008 | Java Jazz Up | 44
 
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