|
Struts2 Data Tags |
|
Struts2 Data Tags
Apache Struts is an open-source framework
used to develop Java web applications. We
started introducing struts generic tags in the
November issue. In this section, we will continue
further with the data tags (generic tags)
provided with struts 2 framework and the rest
will be included in the subsequent issues of
the magazine.
Just download the zip file
“struts2datatags.zip” from any link given below
of each page of this article, unzip it and copy
this application to the webapps directory of
Tomcat. Start tomcat and write http://
localhost:8080/struts2datatags/index.jsp to
the address bar. You can examine the result of
each tag from this page.
|
|
1. Action Tag (Data Tag) Example
The action tag is a generic tag that is used to
call actions directly from a JSP page by specifying
the action name and an optional namespace.
The body content of the tag is used to render
the results from the Action. Any result
processor defined for this action in struts.xml
will be ignored, unless the executeResult
parameter is specified.
Add the following code snippet into the
struts.xml file.
struts.xml
<action name=”actionTag”
class=”net.javajazzup.actionTag”>
<result name=”success”>/pages/dataTags/
success.jsp</result>
</action>
Create an action class as shown below:
actionTag.java
package net.javajazzup;
import
com.opensymphony.xwork2.ActionSupport;
public class actionTag extends ActionSupport
{
public String execute() throws Exception{
return SUCCESS;
}
}
Now create a jsp page using <s:action> tag
as shown in the success.jsp page. The action
tag is used to call actions directly from a JSP
page by specifying the action name and an
optional namespace.
|
|
Jan 2008 | Java Jazz Up | 42 |
|
|
|
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 ,
83,
84 ,
85 ,
86,
87 ,
88,
89 ,
90 ,
91 ,
92 ,
93 ,
94 ,
95 ,
96 ,
97 ,
98 ,
99 ,
100 ,
101 ,
102 ,
103,
104 ,
105 ,
106,
107,
Download PDF |
|
|
|
|
|
|
|