File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes Struts-layouts Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts-layouts" Watch "Struts-layouts" New topic
Author

Struts-layouts

rajesh v
Greenhorn

Joined: Aug 01, 2008
Posts: 3
Hi,
I am trying to add,edit,update the data present in my jsp using struts-layout datagrid tag.
The following is my code:
Methods to edit and update in action class are:



This is my Action form:





I am getting datagrid correctly. The problem is when i press Add button new row is added to the grid but when i click on save button that row is not saved.
As mentioned above i am using getAddedData() to get the added data which returns collection. But iam getting empty collection.
I am not getting the values from the

[AG: added code tags]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60991
    
  65

"user test", please check your private messages for an important administrative matter.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bala Ranch
Greenhorn

Joined: Jul 29, 2008
Posts: 9
Hi Rajesh,

I am trying to display Data Grid in my JSP but i am getting following error

exception org.apache.jasper.JasperException: An exception occurred processing JSP page /FinanceJSPs/datagrid.jsp at line 12 9: <layout:html> 10: <layout:form action="/datagrid.do" width="60%" align="center" reqCode="update" styleClass="PANEL"> 11: <layout:row> 12: <layout:datagrid property="datagrid" selectionAllowed="true" multipleSelectionAllowed="false" model="datagrid"> 13: <layout:datagridColumn title="Student Name" property="stuname"/> 14: <layout:datagridColumn title="Father Name" property="fathername"/> 15: <layout:datagridColumn title="Application Number" property="appno"/> Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:505) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:416) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390) root cause java.lang.NullPointerException fr.improve.struts.taglib.layout.collection.CollectionsIterator.<init>(CollectionsIterator.java:35) fr.improve.struts.taglib.layout.collection.BaseCollectionTag.doStartLayoutTag(BaseCollectionTag.java:994) fr.improve.struts.taglib.layout.datagrid.DatagridTag.doStartLayoutTag(DatagridTag.java:57) fr.improve.struts.taglib.layout.BodyLayoutTagSupport.doStartTag(BodyLayoutTagSupport.java:36) org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005fdatagrid_005f0(datagrid_jsp.java:232) org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005frow_005f0(datagrid_jsp.java:199) org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005fform_005f0(datagrid_jsp.java:162) org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005fhtml_005f0(datagrid_jsp.java:122) org.apache.jsp.FinanceJSPs.datagrid_jsp._jspService(datagrid_jsp.java:93) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267) javax.servlet.http.HttpServlet.service(HttpServlet.java:717) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)

This is my JSP:
.
I am having urgent requirement about this.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Rajesh V, please check your private messages for some administrative matter.

SCJP 6 | SCWCD 5 | Javaranch SCJP FAQ | SCWCD Links
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Rajesh, have you looked at this tutorial which might help you in understanding what you are doing wrong. Showing us the JSP page might also be a good idea as you might have done a mistake somewhere in there. Bala try to start a different topic for your problems in the future. I can see a root cause java.lang.NullPointerException in the stack trace. Can you check if the list you are trying to iterate over is null...
Bala Ranch
Greenhorn

Joined: Jul 29, 2008
Posts: 9
Hi Ankit,
I thought Rajesh is going to give the JSP file what he developed but he never responded.
I am able to fetch the data from the database into the vector object then after I am doing all the datagrid values setup and DAO class setup
then also i am getting the same error.
This is my Tomcat log file Error log
Sep 2, 2009 11:27:22 AM org.apache.catalina.core.StandardWrapperValve invoke
SEVERE: Servlet.service() for servlet jsp threw exception
java.lang.NullPointerException
at fr.improve.struts.taglib.layout.collection.CollectionsIterator.<init>(CollectionsIterator.java:35)
at fr.improve.struts.taglib.layout.collection.BaseCollectionTag.doStartLayoutTag(BaseCollectionTag.java:994)
at fr.improve.struts.taglib.layout.datagrid.DatagridTag.doStartLayoutTag(DatagridTag.java:57)
at fr.improve.struts.taglib.layout.BodyLayoutTagSupport.doStartTag(BodyLayoutTagSupport.java:36)
at org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005fdatagrid_005f0(datagrid_jsp.java:229)
at org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005frow_005f0(datagrid_jsp.java:196)
at org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005fform_005f0(datagrid_jsp.java:159)
at org.apache.jsp.FinanceJSPs.datagrid_jsp._jspx_meth_layout_005fhtml_005f0(datagrid_jsp.java:119)
at org.apache.jsp.FinanceJSPs.datagrid_jsp._jspService(datagrid_jsp.java:90)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:374)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:342)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:267)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:390)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:128)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:286)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:845)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:583)
at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:447)
at java.lang.Thread.run(Thread.java:619)
.

This is my Action where i am fetching the data from the database and setting into datagrid.


Waiting for your response.
Thanks in advance.
Ankit Garg
Sheriff

Joined: Aug 03, 2008
Posts: 9293
    
  17

Bala are you sure this is the correct code for your action. In the loop you are setting admdao to null, so you'll get a NullPointerException during the second iteration. Also I'm a little confused about NewAdmissionDao class, is it a POJO and DAO at the same time?? Does it have the stuname, fathername and appno properties??
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Struts-layouts