Magazine
 
Struts2 Tags

list1.add(“Logitech”);
list2 = new ArrayList();
list2.add(“Monitor”);
list2.add(“Hard Disk”);
list2.add(“Moterboard”);
list2.add(“CD Drive”);
list2.add(“Keyboard”);
return SUCCESS;
}
public List getList1(){
return list1;
}
public List getList2(){
return list2;
}
}

The following example retrieves the value of the getMyList() method of the current object on the value stack and uses it to iterate over. The <s:property/> tag prints out the current value of the iterator.

IteratorTag.jsp

<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title>Iterator Tag Example</title>
</head>
<body>
<h2>Iterator Tag Example</h2>
<b>Company:</b><br>
<s:iterator value=”list1" >
<s:property /><br>
</s:iterator>
<br>
<b>Product:</b><br>
<s:iterator value=”list2">
<s:property /><br>
</s:iterator>
</body>
</html>

 

.

4. Merge Tag (Control Tags) Example
The merge tag is a generic tag that is used to merge iterators. The successive call to the merge iterator causes each merge iterator to have a chance to expose its element, subsequently next call allows the next iterator
to expose its element. Once the last iterator is done exposing its element, the first iterator is allowed to do so again (unless it is exhausted of entries). In the current example, 2 lists being merged where each list have 5 entries.

Dec 2007 | 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 , 73 , 74 , 75 , 76 , 77 , 78 , 79 , 80 , 81 , 82 ,

Download PDF