MyEclipse: Unable to get values of form fields using FormBean-Struts

ajaym - May 05, 2011 - 12:08 PM
Post subject: Unable to get values of form fields using FormBean-Struts
Hi,
I am using Struts 1.2.x and wish have mmediate help on the following issue.

Issue : Unable to get values of form fields using FormBean using Struts

Details :
----> JSP page having 3 fields Cityname, state name and country name. having HTML tags as follows :

<form action=""../CityAction.do?action=submitCityMasterData"" name="form2" method="post">

------> Input type line
<input type="button" value="Submit" class="g_button" onclick="submit()" />

----------------------------------------
struts-config.xml file has following entries for beans and mappings :

<form-beans>
<form-bean name="cityMasterFormBean" type="com.buhariwalas.app.form.cityMaster.CityMast erFormBean"/>
</form-beans>

<action-mappings>
</action>
<action path="/CityAction"
type="com.buhariwalas.app.action.cityMaster.CityAc tion"
parameter="action"
scope="request"
name="cityMasterFormBean">
</action>

--------------------------

can anyone tell me why the following code in SubmitCityAction.java prints null values :

public class SubmitCityAction {
private ActionForward nextPage = null;
private CityMasterFormBean cityForm = null;
/*-----------------------------------------------------------------------*/
public ActionForward submitCityMasterData(ActionMapping mapping, ActionForm form,
HttpServletRequest request,HttpServletResponse response){

private CityMasterFormBean cityForm = null;

cityForm = (CityMasterFormBean)form ;

System.out.println("City Form Values = "+
"\ncity = "+cityForm.getCity_name()+","+
"\nstate = "+cityForm.getState_name()+","+
"\ncountry = "+cityForm.getCountry_name() );


nextPage = mapping.findForward("mainPage");

return nextPage;
}
}
support-joy - May 06, 2011 - 11:48 AM
Post subject:
ajaym,

Below is the link to the tutorial where you can refer to struts 1.2.x

http://www.roseindia.net/struts/strutsActionForms.shtml

Thanks
All times are GMT - 6 Hours
Powered by PNphpBB2 © 2003-2004 The PNphpBB Group
Credits