Results 1 to 8 of 8
  1. #1
    advan is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Angry 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;
    }
    }

  2. #2
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    Can you try to make it without java script?
    Skype: petrarsentev
    http://TrackStudio.com

  3. #3
    goldest's Avatar
    goldest is offline Senior Member
    Join Date
    Oct 2009
    Location
    Pune, India
    Posts
    469
    Rep Power
    6

    Wink

    Quote Originally Posted by Petr View Post
    Can you try to make it without java script?
    And with Code Tags next time around?
    Java Is A Funny Language... Really!
    Click on * and add to member reputation, if you find their advices/solutions effective.

  4. #4
    advan is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    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)

  5. #5
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    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

  6. #6
    advan is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Question 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.java
    Attached Files Attached Files
    Last edited by advan; 05-05-2011 at 01:47 PM. Reason: forgot to attach CityMasterDao.java file in ZIP

  7. #7
    advan is offline Member
    Join Date
    May 2011
    Posts
    4
    Rep Power
    0

    Default

    Is I am missing in DAO file ???

  8. #8
    Petr's Avatar
    Petr is offline Senior Member
    Join Date
    Jan 2011
    Location
    Russia
    Posts
    620
    Rep Power
    4

    Default

    )) 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

  1. Using Editable Pdf form fields in Application
    By jiten.mistry in forum Advanced Java
    Replies: 5
    Last Post: 09-21-2011, 09:37 PM
  2. Replies: 6
    Last Post: 04-06-2011, 01:39 PM
  3. Populating the values in text fields
    By Inaam in forum Web Frameworks
    Replies: 2
    Last Post: 07-26-2010, 09:55 AM
  4. Dynamic fields in form using Form Bean
    By janu.c in forum Java Software
    Replies: 1
    Last Post: 09-23-2009, 05:26 AM
  5. declaring fields without assigning values to them
    By diggitydoggz in forum New To Java
    Replies: 12
    Last Post: 01-03-2009, 09:22 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •