|
Struts2 Tags |
|
Animals and Creates a series of checkboxes
from animals list of the action class “checkboxlistTag”.
checkboxlistTag.jsp
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Checkboxlist (Form Tag) Tag
Example!</title>
</head>
<body>
<h2>Checkboxlist Tag Example</h2>
<b>Fruits</b><br>
<s:checkboxlist name=”Fruits-name”
list=”fruits” /><br>
<b>Animals</b><br>
<s:checkboxlist name=”Animals-name”
list=”animals” /><br>
</body>
</html> |
Output of the checkboxlistTag.jsp:
4. Combobox Tag (Form Tag) Example
The combo box is basically an HTML INPUT of
type text and HTML SELECT grouped together
to give you a combo box functionality. You can
place text in the INPUT control by using the
SELECT control or type it in directly in the text
field.
|
|
Add the following code snippet into the struts.xml file.
<action name=”comboboxTag”
class=”net.javajazzup.comboboxTag”>
<result>/pages/formTags/
comboboxTag.jsp</result>
</action> |
Create a list in the action class and populate it
with various items as shown in the“ comboboxTag” class.
comboboxTag.java
package net.javajazzup;
import
com.opensymphony.xwork2.ActionSupport;
import java.util.*;
public class comboboxTag extends
ActionSupport{
private List fruits;
public String execute()throws Exception{
fruits = new ArrayList();
fruits.add(“Apple”);
fruits.add(“Mango”);
fruits.add(“Orange”);
fruits.add(“Pine Apple”);
return SUCCESS;
}
public List getFruits(){
return fruits;
}
} |
Create a jsp using the tags <s:combobox>
The tag <s:combobox label=”Colors Name”
name=”colorNames” headerValue=”— Please
S e l e c t — ” h e a d e r K e y = ” 1 "
list=”{‘Black’,’Green’,’White’,’Yellow’,’Red’,’Pink’}”
/> prints a combobox with name color Name
and an HTML INPUT of type text and HTML
SELECT grouped together created using the
list. |
|
|
Feb 2008 | Java Jazz Up | 40 |
|
|
|
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 |
|
|
|
|
|
|
|