Results 1 to 8 of 8
- 05-05-2011, 10:29 AM #1
Member
- Join Date
- May 2011
- Posts
- 4
- Rep Power
- 0
Unable to get values of form fields using FormBean using Struts
Hi,
I am new to Struts 1.2.x wish to have immediate 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="createCity()" />
-----------
On submit following javascript function is called :
<script> function createCity(){ alert("create City - submit is called") var is = validatePage(); if(is==0){ // var goToServlet='<%=PageMappings.CITY_MASTER_SUBMIT_CI TY_ACTION%>'; //window.location=goToServlet; document.form2.submit(); } } </script>
----------------------------------------
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;
}
}
- 05-05-2011, 11:04 AM #2
- 05-05-2011, 11:09 AM #3
And with Code Tags next time around?
Java Is A Funny Language... Really!.gif)
Click on * and add to member reputation, if you find their advices/solutions effective.
- 05-05-2011, 11:22 AM #4
Member
- Join Date
- May 2011
- Posts
- 4
- Rep Power
- 0
even without Javascript i.e. submit() called from input type submitt button also resulted in the same way.
Following is the partial error log printed in my console.
/Buhariwalas/CityAction.do
2011-05-05 16:06:49,921 [http-8080-2] INFO org.apache.struts.chain.ComposableRequestProcessor -Initializing composable request processor for module prefix ''
2011-05-05 16:06:50,109 [http-8080-2] INFO org.apache.struts.chain.commands.servlet.CreateAct ion -Initialize action of type: com.buhariwalas.app.action.cityMaster.CityAction
entered in City action -> submitCityMasterData ActionForward method
SubmitCityAction:createCity():starts
hm : {Create=1}
City Form Values =
city = null,
state = null,
country = null,
desc = null,
trid = null,
create date = null
City Master TM Started
City Master Sets Values in Form Bean Started
Transaction id : [201105051665027206]
TRID testing=
201105051665027206
tm.getCurrentConnection= entring
add new Entry in City by Maroof
java.lang.NullPointerException
at com.varahi.frameworks.db.StatementBuilder.buildSta tement(StatementBuilder.java:26)
at com.varahi.frameworks.metadata.RSMetaData.getTable MetaData(RSMetaData.java:43)
at com.varahi.frameworks.metadata.RSMetaData.getField MetaData(RSMetaData.java:66)
at com.varahi.frameworks.db.StatementQueryBuilder.bui ldInsertQuery(StatementQueryBuilder.java:41)
at com.varahi.frameworks.helper.InsertHelper.insertNe wRecords(InsertHelper.java:26)
at com.buhariwalas.app.dao.cityMaster.CityMasterDao.a ddNewEntry(CityMasterDao.java:108)
at com.buhariwalas.app.action.cityMaster.SubmitCityAc tion.submitCityMasterData(SubmitCityAction.java:18 4)
at com.buhariwalas.app.action.cityMaster.CityAction.s ubmitCityMasterData(CityAction.java:18)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.struts.actions.DispatchAction.dispatchM ethod(DispatchAction.java:269)
at org.apache.struts.actions.DispatchAction.execute(D ispatchAction.java:170)
at org.apache.struts.chain.commands.servlet.ExecuteAc tion.execute(ExecuteAction.java:58)
at org.apache.struts.chain.commands.AbstractExecuteAc tion.execute(AbstractExecuteAction.java:67)
at org.apache.struts.chain.commands.ActionCommandBase .execute(ActionCommandBase.java:51)
at org.apache.commons.chain.impl.ChainBase.execute(Ch ainBase.java:191)
at org.apache.commons.chain.generic.LookupCommand.exe cute(LookupCommand.java:305)
at org.apache.commons.chain.impl.ChainBase.execute(Ch ainBase.java:191)
at org.apache.struts.chain.ComposableRequestProcessor .process(ComposableRequestProcessor.java:283)
at org.apache.struts.action.ActionServlet.process(Act ionServlet.java:1913)
at org.apache.struts.action.ActionServlet.doPost(Acti onServlet.java:462)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:710)
at javax.servlet.http.HttpServlet.service(HttpServlet .java:803)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at com.buhariwalas.app.filters.LoginCheck.doFilter(Lo ginCheck.java:63)
at org.apache.catalina.core.ApplicationFilterChain.in ternalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.do Filter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invo ke(StandardWrapperValve.java:230)
at org.apache.catalina.core.StandardContextValve.invo ke(StandardContextValve.java:175)
at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke (ErrorReportValve.java:104)
at org.apache.catalina.core.StandardEngineValve.invok e(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.servic e(CoyoteAdapter.java:261)
at org.apache.coyote.http11.Http11Processor.process(H ttp11Processor.java:844)
at org.apache.coyote.http11.Http11Protocol$Http11Conn ectionHandler.process(Http11Protocol.java:581)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run( JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
- 05-05-2011, 11:52 AM #5
There are snippets, which you posted is correct. Hence can you show the full code? That we can testing it.
Skype: petrarsentev
http://TrackStudio.com
- 05-05-2011, 12:16 PM #6
Member
- Join Date
- May 2011
- Posts
- 4
- Rep Power
- 0
required code files are attached in the ZIP file
Please find all the code as files mentioned below in ZIP file attached.
SubmitCityAction.java
CityAction.java
CityMasterFormBean.java
CityMaster_Create.jsp
struts-config.xml
CityMasterDao.javaLast edited by advan; 05-05-2011 at 12:47 PM. Reason: forgot to attach CityMasterDao.java file in ZIP
- 05-05-2011, 12:48 PM #7
Member
- Join Date
- May 2011
- Posts
- 4
- Rep Power
- 0
Is I am missing in DAO file ???
- 05-05-2011, 01:30 PM #8
)) How you think how Struts need understand what variables from jsp to due with variables from form bean?
Skype: petrarsentev
http://TrackStudio.com
Similar Threads
-
Using Editable Pdf form fields in Application
By jiten.mistry in forum Advanced JavaReplies: 5Last Post: 09-21-2011, 08:37 PM -
<html:form> struts form not working if it is inside a jsp under WEB-INF
By dariusaron in forum Web FrameworksReplies: 6Last Post: 04-06-2011, 12:39 PM -
Populating the values in text fields
By Inaam in forum Web FrameworksReplies: 2Last Post: 07-26-2010, 08:55 AM -
Dynamic fields in form using Form Bean
By janu.c in forum Java SoftwareReplies: 1Last Post: 09-23-2009, 04:26 AM -
declaring fields without assigning values to them
By diggitydoggz in forum New To JavaReplies: 12Last Post: 01-03-2009, 08:22 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks