Home Struts Struts Struts2.2.1 Tags Struts2.2.1 doubleselect tag example.

Ask Questions?

View Latest Questions


 
 

Struts2.2.1 doubleselect tag example.
Posted on: January 15, 2011 at 12:00 AM
Advertisement
In this tutorial, you will see the use of doubleselect tag of struts2.2.1.

Struts2.2.1 doubleselect tag example.

In this tutorial, you will see the use of doubleselect tag of struts2.2.1. the <s:doubleselect> tag is used to create two HTML drop down boxes, 
once the first drop down list is selected, the second drop down list will be change accordingly. In this example ?Degree? and ?Diploma? drop down selection, where different ?Degree? lists are depending on the selected ?Degree? or "Diploma".

Directory structure of doubleselect tag example.

 1- index.jsp

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>DoubleSelect Tag Example</title>

</head>

<body>

<a href="DoubleSelectTag.action">DoubleSelect Tag Example</a>

</body>

</html>

2-DoubleSelectTag.jsp

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

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>DoubleSelect Tag Example</title>

</head>

<body>

<s:form action="DoubleSelectResult">

<s:textfield name="name" key="Name"></s:textfield>

<table>

<tr>

<td>Select your Qualification: <s:doubleselect

label="Qualification" name="list1"

doubleList="top == 'Degree' ? {'MCA', 'MBA','MTech','BTech','MSc(IT)'} :

{'PGDCA', 'PGDM','PGDBM','PGDSM'}"

list="{'Degree','Diploma'}" doubleName="list2" /></td>

</tr>

<tr>

<td>Select your Experience: <s:doubleselect label="Experience"

name="list3"

doubleList="top == 'Fresher' ? {'2009', '2010','2011'} :

{'6 months','6+months','1 year','1+year','2+year'}"

list="{'Fresher','Experience'}" doubleName="list4" /></td>

</tr>

<tr>

<td><s:submit></s:submit></td>

</tr>

</table>

</s:form>

</body>

</html>

 3-DoubleSelectTag.java

package roseindia;

import com.opensymphony.xwork2.ActionSupport;

public class DoubleSelectTag extends ActionSupport {

private String list1;

private String list2;

private String list3;

private String list4;

private String name;

public String execute() throws Exception {

return SUCCESS;

}

public String getList1() {

return list1;

}

public void setList1(String list1) {

this.list1 = list1;

}

public String getList2() {

return list2;

}

public void setList2(String list2) {

this.list2 = list2;

}

public String getList3() {

return list3;

}

public void setList3(String list3) {

this.list3 = list3;

}

public String getList4() {

return list4;

}

public void setList4(String list4) {

this.list4 = list4;

}

public String display() {

return NONE;

}

public String getName() {

return name;

}

public void setName(String name) {

this.name = name;

}

}

4_struts.xml

<struts>

<constant name="struts.enable.DynamicMethodInvocation" value="false" />

<constant name="struts.devMode" value="false" />

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

<action name="DoubleSelectTag" class="roseindia.DoubleSelectTag"

method="display">

<result name="none">/DoubleSelectTag.jsp</result>

</action>

<action name="DoubleSelectResult" class="roseindia.DoubleSelectTag">

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

</action>

</package>

</struts>

5_result.jsp

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

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>DoubleSelect Tag Example</title>

</head>

<body>Welcome Dear <s:property value="name"/><br>

Your Qualification is : <s:property value="list2"/><br>

Your Experience is : <s:property value="list4"/>

</body>

</html>

Download Select Source Code


Related Tags for Struts2.2.1 doubleselect tag example.:


DMCA.com