3-optionTransferAction.java
package roseindia.action; import java.util.ArrayList; import java.util.List;ADS_TO_REPLACE_1 import com.opensymphony.xwork2.ActionSupport; public class optionTransferAction extends ActionSupport { private List<String> indianCityName;ADS_TO_REPLACE_2 private List<String> americanCityName; private String IndiaCity; private String americanCity;ADS_TO_REPLACE_3 public List<String> getIndianCityName() { return indianCityName; }ADS_TO_REPLACE_4 public void setIndianCityName(List<String> indianCityName) { this.indianCityName = indianCityName; }ADS_TO_REPLACE_5 public List<String> getAmericanCityName() { return americanCityName; }ADS_TO_REPLACE_6 public void setAmericanCityName(List<String> americanCityName) { this.americanCityName = americanCityName; }ADS_TO_REPLACE_7 public optionTransferAction() { /*----- Add India City in list------*/ADS_TO_REPLACE_8 indianCityName=new ArrayList<String>(); indianCityName.add("Bengaluru"); indianCityName.add("Delhi");ADS_TO_REPLACE_9 indianCityName.add("Mumbai"); indianCityName.add("Lucknow"); /*----- Add American City in list------*/ADS_TO_REPLACE_10 americanCityName=new ArrayList<String>(); americanCityName.add("New York"); americanCityName.add("Green Bay");ADS_TO_REPLACE_11 americanCityName.add("RichMond"); americanCityName.add("West Jordan"); americanCityName.add("CamBridge");ADS_TO_REPLACE_12 americanCityName.add("Bareilly"); } public String getIndiaCity() {ADS_TO_REPLACE_13 return IndiaCity; } public void setIndiaCity(String indiaCity) {ADS_TO_REPLACE_14 IndiaCity = indiaCity; } public String getAmericanCity() {ADS_TO_REPLACE_15 return americanCity; } public void setAmericanCity(String americanCity) {ADS_TO_REPLACE_16 this.americanCity = americanCity; } public String execute() throws Exception {ADS_TO_REPLACE_17 return SUCCESS; } public String display() throws Exception {ADS_TO_REPLACE_18 return NONE;} } |
4_struts.xml
<struts> <package name="roseindia" extends="struts-default" namespace="/">ADS_TO_REPLACE_19 <action name="optionTransfer" class="roseindia.action.optionTransferAction" method="display"> <result name="none" >jsppages/optionTransfer.jsp</result> </action>ADS_TO_REPLACE_20 <action name="resultAction" class="roseindia.action.optionTransferAction"> <result name="success" >jsppages/outputoptionTransfer.jsp</result> </action>ADS_TO_REPLACE_21 </package> </struts> |
5_outputoptionTransfer.jsp
<%@taglib uri="/struts-tags" prefix="s" %> <html><head>ADS_TO_REPLACE_22 <title>Struts2.2.1_Optiontransferselect_Example1</title> </head><body> <h2>Struts2.2.1_Optiontransferselect_Example1</h2><hr>ADS_TO_REPLACE_23 <h4>City selected by client......</h4> IndiaCity : <s:property value="IndiaCity"/><br/> AmericanCity : <s:property value="americanCity"/>ADS_TO_REPLACE_24 </body></html> |
index.gif
optiontransferTag.gifADS_TO_REPLACE_25
SelectCityFortransfer.gif
ADS_TO_REPLACE_26
Aftertransfer.gif In this, we are transferring Bareilly from list of American city to Indian city.
SelectCities.gifADS_TO_REPLACE_27
CitySelectedByU.gif
ADS_TO_REPLACE_28
Advertisements
Ads
Ads