|
|
|
GeneratorTagCountAttribute.jsp
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<html>
<head>
<title> Generator Tag Example </title>
</head>
<body>
<h2>Generator Tag Example</h2>
<h3> Generates an Iterator With Count
Arrtibute</h3>
<s:generator
val=”%{‘JAVA,HTML,CSS,AJAX,JAVA
SCRIPT’}” count=”3" separator=”,”>
<s:iterator>
<s:property /><br/>
</s:iterator>
</s:generator>
</body>
</html>
Output:
7. Generator Tag (Control Tags) Using
an Iterator with Id Attributes
In this section, we are going to describe the generator tag using the id attribute.
Output
| |
GeneratorTag.java
package net.javajazzup;
import
com.opensymphony.xwork2.ActionSupport;
import
org.apache.struts2.util.IteratorGenerator.Converter;
public class GeneratorTag extends
ActionSupport {
public String excute() throws Exception{
returnSUCCESS;
}
}
Create a jsp page where the generator tag <s:generator> generates an iterator with “id”
attribute and <s:iterator> tag prints it out
using the <s:property /> tag. The separator
attribute separates the val into entries of the
iterator.
The scriplet as shown below generates an
iterator and put it in the PageContext under
the key as specified by the id attribute.
<%
Iterator i = (Iterator)
pageContext.getAttribute(“myAtt”);
while(i.hasNext()) {
String s = (String) i.next(); %>
<%=s%> <br/>
<% }
%>
GeneratorTagIdAttribute.jsp
<%@ taglib prefix=”s” uri=”/struts-tags” %>
<%@page language=”java”
import=”java.util.*”%>
<html>
<head>
<title> Generator Tag Example </title>
</head>
<body>
<h2>Generator Tag Example</h2>
<h3> Generates an Iterator With Id
|
|
Dec 2007 | Java Jazz Up | 47 |
|
|
|
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 |
|
|
|
|
|
|
|
|
|