Home Struts Struts2 Struts2controltags Action Tag (Data Tag) Example
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Action Tag (Data Tag) Example

Advertisement
In this section, we are going to describe the action tag . 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.

Action Tag (Data Tag) Example

     

In this section, we are going to describe the action tag. 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.roseindia.actionTag">
   <result name="success">/pages/genericTags/success.jsp</result>
</action>

Create an action class as shown below:

actionTag.java

package net.roseindia;
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. 

success.jsp

<%taglib prefix="s" uri="/struts-tags" %>

<html>
  <head>
  <title>Action Tag Example!</title>
  </head>
  <body>
  <h1><span style="background-color: #FFFFcc">Action Tag 
  (
Data TagsExample!</span></h1>
  <s:action name="success">
  <b><i>The action tag will execute the result and include 
  it in 
this page.</i></b></div>
  </s:action>
  </body>
</html>

Output of the success.jsp

     

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: July 19, 2007

Related Tutorials

Ask Questions?    Discuss: Action Tag (Data Tag) Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
Oai Nguyen
June 1, 2011
what is the purposeof the post-action tag?

Dear sir/Madam, I am not good in XML, please tell me what is the purpose of the post -action tag in xml (please see below code). <post-action> <entity-field value="value"> Risk_Profile</entity-field> </post-action>
DMCA.com