Home Struts Struts Struts2.2.1 Tags Example of struts2.2.1 bean tag.

Ask Questions?

View Latest Questions


 
 

Example of struts2.2.1 bean tag.
Posted on: January 3, 2011 at 12:00 AM
Advertisement
In this section, you will see the use of bean tag of struts2.

Example of struts2.2.1 bean tag.

In this tutorial, you will see the use of bean tag of struts2.2.1 tag. The Bean tag is a generic tag that is used to instantiates a class that confirms to the JavaBeans specification. This tag has a body which can contain a number of Parma elements to set any mutator methods on that class.

Directory structure of anchor tag example.

 1- index.jsp  

<html>

<head><title>Insert title here</title></head>

<body>

<h1>Example of bean tag.....</h1>

<a href="beanAction.action"> Convert Paisa into Rupees..</a>

</body>

</html>

2-beanActionClass.java

package roseindia.action ;

import com.opensymphony.xwork2.ActionSupport;

public class beanActionClass extends ActionSupport {

public String execute() throws Exception{

return SUCCESS;}

}

4_beanActionClass.java

package roseindia.action ;

import com.opensymphony.xwork2.ActionSupport;

public class beanActionClass extends ActionSupport {

public String execute() throws Exception{

return SUCCESS;}

}

5_ConvetPaisaIntoRupees.java

package roseindia.javabean;

public class ConvetPaisaIntoRupees {

private float paisa; private float rupees;

public float getPaisa()

{

return (rupees*100);

}

public void setPaisa(float paisa)

{

this.paisa = paisa;

}

public float getRupees()

{

return (paisa/100);

}

public void setRupees(float rupees)

{

this.rupees = rupees;}

}

 6_struts.xml

<package name="roseindia" extends="struts-default" namespace="/">

<action name="beanAction" class="roseindia.action.beanActionClass">

<result name="success">/welcome.jsp</result>

</action>

</package>

3_ welcome.jsp

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

<html>

<head><title>Insert title here</title></head>

<body><h1>Value of paisa into rupee </h1>

<s:bean name="roseindia.javabean.ConvetPaisaIntoRupees">

<s:param name="paisa" value="100" />

100 Paisa = <s:property value="rupees" /> Rupees

</s:bean></body>

</html> 

index.jsp

ValueofPaisaInRupee.jsp

Download Select Source Code


Related Tags for Example of struts2.2.1 bean tag.:


DMCA.com