Magazine
 
Struts2 Tags
state.add(“Louisiana”);
state.add(“Maine”);
state.add(“Maryland”);
state.add(“Massachusetts”);
state.add(“Michigan”);
state.add(“Minnesota”);
state.add(“Mississippi”);
state.add(“Missouri”);
state.add(“Montana”);
state.add(“Nebraska”);
state.add(“Nevada”);
state.add(“New Hampshire”);
state.add(“New Jersey”);
state.add(“New Mexico”);
state.add(“New York”);
state.add(“North Carolina”);
state.add(“North Dakota”);
state.add(“Ohio”);
state.add(“Oklahoma”);
state.add(“Oregon”);
state.add(“Pennsylvania”);
state.add(“Rhode Island”);
state.add(“South Carolina”);
state.add(“South Dakota”);
state.add(“Tennessee”);
state.add(“Texas”);
state.add(“Utah”);
state.add(“Vermont”);
state.add(“Virginia”);
state.add(“Washington”);
state.add(“West Virginia”);
state.add(“Wisconsin”);
state.add(“Wyoming”);
return SUCCESS;
}
public List getState(){
return state;
}
}

<s:autocompleter theme=”simple” list=”state” StateName/> creates a autocompleter list with the name of U.S. states.

autocompleter.jsp

<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Struts 2 Autocompleter Example</
title>
 
<s:head theme=”ajax” />
</head>
<body>
<h2>Autocompleter Example</h2>
<s:label name=”stateName” value=”Select
State Name:” />
<s:autocompleter theme=”simple”
list=”state” name=”StateName”/>
</body>
</html>

Output of the autocompleter.jsp:

2. Checkbox Tag (Form Tag) Example

The checkbox tag is a UI tag that is used to render an HTML input element of type checkbox, populated by the specified property from the ValueStack.

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

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

Create a jsp using the tag <s:checkbox> It Renders an HTML input element of type checkbox.

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