|
Struts2 Tags |
|
SubsetTag.java
package net.javajazzup;
import
com.opensymphony.xwork2.ActionSupport;
import java.util.*;
public class SubsetTag extends ActionSupport
{
private List list;
public String execute() throws Exception{
list = new ArrayList();
list.add(new Integer(100));
list.add(new Integer(200));
list.add(new Integer(300));
list.add(new Integer(150));
list.add(new Integer(400));
return SUCCESS;
}
public List getList(){
return list;
}
}
Now create a jsp page using <s:subset> and <s:iterator> tags as shown in the
SubsetTag.jsp page. The subset tag takes an
iterator and outputs a subset of it. The
parameter start is of integer type and it
indicates the starting index (eg. first entry is
0) of entries in the source (needed to make
available as the first entry in the resulting
subset iterator).
|
|
SubsetTagStartWith.jsp
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Subset Tag Example</title>
</head>
<body>
<h2>Subset Tag Example</h2>
<s:subset source=”list” count=”3"
start=”2">
<s:iterator>
<s:property /><br>
</s:iterator>
</s:subset>
</body>
</html>
Output:
Here the items displayed are 300, 150, 400.
Items displayed starts from 2nd index of the
List.
|
|
Dec 2007 | Java Jazz Up | 50 |
|
|
|
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 ,
73 ,
74 ,
75 ,
76 ,
77 ,
78 ,
79 ,
80 ,
81 ,
82 , Download PDF |
|
|
|
|
|
|
|
|
|