No, the two country and state fields are part of the same form which is renedered upon successful login. They have to be available throughtout the session , the actions that get triggered from the top nav on this form need these values. This is what I have now:
HomeForm : countryName,stateName -
String values
countryList,stateList - arrayLists
HomeAction.execute(): HomeForm welcomeForm = (HomeForm)form;
String ctryName = welcomeForm.getCountryName();
String stateName = welcomeForm.getStateName();
ArrayList ctryList = welcomeForm.getCountryList();
ctryList.add(ctryName);
ArrayList stateList = welcomeForm.getStateList();
stateList.add(stateName);
request.getSession().setAttribute("welcomeForm",welcomeForm);
return mapping.findForward("homePage");
In LoginAction: execute():
ValueObject vo = new ValueObject();
HomeForm welcomeForm= new HomeForm();
ArrayList<ValueObject> CtryStateLList = DAO.getStateAndCountryList();
Iterator it = CtryStateList.iterator();
ArrayList<String> stateList = new ArrayList();
ArrayList<String> countryList = new ArrayList();
while(it.hasNext()){
vo = (ValueObject)it.next();
stateList.add(vo.getState());
countryList.add(vo.getCountry());
}
welcomeForm.setStateList(stateList);
welcomeForm.setCountryList(countryList);
request.getSession().setAttribute("welcomeForm", welcomeForm);
return mapping.findForward("homePage");
home.jsp:
<script language="JavaScript" type="text/javascript">
function submitForm(fieldValue1,fieldValue2) {
document.welcomeForm.franchiseName.value=fieldValue1;
document.welcomeForm.countryName.value = fieldValue2;
document.welcomeForm.submit;
}
</script>
<html:form method=" post" action="welcome" >
<input type="hidden" name="stateName" >
<input type="hidden" name="countryName">
<input type="submit" onselect="javascript:submitForm('stateName','countryName');">
<br/><br/><br/>
<div class="form-holder">
<b>Select State</b>
<span>
<!--Select Name-->
<h6>Select Participant Name</h6>
<html:select property="stateList">
<html:optionsCollection name="welcomeForm" property="stateList" label="stateName" />
</html:select>
<!--Select Country-->
<br />
<h6>Select Participant Country</h6>
<select name="" title="Click to select country">
<option value="france">France</option>
<option value="two">two</option>
<option value="three">three</option>
<option value="tour">four</option>
</select>