Guest User

Untitled

a guest
Aug 28th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. retreive value in selectbox in struts2
  2. private String userName;
  3.  
  4. private String password;
  5.  
  6. private String gender;
  7.  
  8. private String about;
  9.  
  10. private String country;
  11.  
  12.  
  13.  
  14.  
  15. private ArrayList<Country> countryList;
  16.  
  17. private String[] community;
  18.  
  19. private ArrayList<String> communityList;
  20.  
  21. private Boolean mailingList;
  22.  
  23. public String populate() {
  24.  
  25. countryList = new ArrayList<Country>();
  26. countryList.add(new Country(1, "India"));
  27. countryList.add(new Country(2, "USA"));
  28. countryList.add(new Country(3, "France"));
  29.  
  30. communityList = new ArrayList<String>();
  31. communityList.add("Java");
  32. communityList.add(".Net");
  33. communityList.add("SOA");
  34.  
  35. community = new String[]{"Java",".Net"};
  36. mailingList = true;
  37.  
  38. return "populate";
  39. }
  40.  
  41. @Override
  42. public String execute() {
  43. return SUCCESS;
  44. }
  45.  
  46. public String getUserName() {
  47. return userName;
  48. }
  49.  
  50. public void setUserName(String userName) {
  51. this.userName = userName;
  52. }
  53.  
  54. public String getPassword() {
  55. return password;
  56. }
  57.  
  58. public void setPassword(String password) {
  59. this.password = password;
  60. }
  61.  
  62. public String getGender() {
  63. return gender;
  64. }
  65.  
  66. public void setGender(String gender) {
  67. this.gender = gender;
  68. }
  69.  
  70. public String getAbout() {
  71. return about;
  72. }
  73.  
  74. public void setAbout(String about) {
  75. this.about = about;
  76. }
  77.  
  78. public String getCountry() {
  79. return country;
  80. }
  81.  
  82. public void setCountry(String country) {
  83. this.country = country;
  84. }
  85.  
  86. public ArrayList<Country> getCountryList() {
  87. return countryList;
  88. }
  89.  
  90. public void setCountryList(ArrayList<Country> countryList) {
  91. this.countryList = countryList;
  92. }
  93.  
  94. public String[] getCommunity() {
  95. return community;
  96. }
  97.  
  98. public void setCommunity(String[] community) {
  99. this.community = community;
  100. }
  101.  
  102. public ArrayList<String> getCommunityList() {
  103. return communityList;
  104. }
  105.  
  106. public void setCommunityList(ArrayList<String> communityList) {
  107. this.communityList = communityList;
  108. }
  109.  
  110. public Boolean getMailingList() {
  111. return mailingList;
  112. }
  113.  
  114. public void setMailingList(Boolean mailingList) {
  115. this.mailingList = mailingList;
  116. }
  117.  
  118. <s:select name="country" list="countryList" listKey="countryId"
  119. listValue="countryName" headerKey="0" headerValue="Country"
  120. label="Select a country" />
  121.  
  122. Country: <s:property value="country" /><br>
  123.  
  124. private ArrayList<Country> communityList;
  125.  
  126. <s:iterator value="countryList"> <!-- here myList contains the list of objects -
  127. <s:property value="countryName" /><br/>
  128. <s:property value="countryId" /><br/>
  129. </s:iterator>
  130.  
  131. <s:select name="country" list="countryList" listKey="countryName" listValue="countryName" headerKey="0" headerValue="Country" label="Select country" />
Add Comment
Please, Sign In to add comment