|
Struts2 Tags |
|
MergeTag.java
package net.javajazzup;
import
Struts2 Tags
Dec-07 Java Jazz Up 45
com.opensymphony.xwork2.ActionSupport;
import java.util.*;
public class MergeTag extends ActionSupport
{
private List list1;
private List list2;
public String execute() throws Exception{
list1 = new ArrayList();
list1.add(“JAVA”);
list1.add(“HTML”);
list1.add(“CSS”);
list1.add(“AJAX”);
list1.add(“JAVA SCRIPT”);
list2 = new ArrayList();
list2.add(“Soft. Engg.”);
list2.add(“Sr. Soft. Engg.”);
list2.add(“Team Leader”);
list2.add(“Project Manager”);
list2.add(“Managing Director”);
return SUCCESS;
}
public List getList1(){
return list1;
}
public List getList2(){
return list2;
}
}
Now create a jsp page using <s:merge> and<s:param value> tags as shown in the
mergeTag.jsp page. The merge tag is used to
merge iterators. The “id” parameter keeps the
resultant iterator stored under in the stack’s
context and the “value” parameter in the<s:iterator> is used to get the values
contained within the respective iterators.
MergeTag.jsp
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Merge Tage Example</title>
</head>
<body>
|
|
<h2>Merge Tag Example</h2>
<s:merge id=”mergeId”>
<s:param value=”%{list1}” />
<s:param value=”%{list2}” />
</s:merge>
<s:iterator value=”%{#mergeId}”>
<s:property /><br>
</s:iterator>
</body>
</html>
Output:
5. Generator Tag (Control Tags) Example
The generator tag is a generic tag that is
used to generate iterators based on different
attributes passed. Here we will not pass any
attribute.
|
|
Dec 2007 | Java Jazz Up | 45 |
|
|
|
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 |
|
|
|
|
|
|
|
|
|