Hi
I am trying to get a dynamically generated excel report to be streamed back to the browser. How should i write my java method so that i can use the HTTPServletResponze and org.ofbiz.base.util.UtilHttp.streamContentToBrowser(HttpServletResponse response, byte[] bytes, java.lang.String contentType) to return data. My request-response map is as below: <request-map uri="createReport"> <security https="true" auth="true"/> <event type="service" invoke="crmsfa.createReport"/> <response name="success" type="view" value="showReport"/> <response name="error" type="request-redirect" value="viewReport"/> </request-map> What changes should i make to the following method . public static Map createReport(DispatchContext dctx, Map context) { -------- -------- } How can i make the HTTPServletResponse object available in my java service method Can anyone give any sample java file using HTTPServletResponse object in the service method Thanks Tanzeem |
If you look at the Apache OFBiz Development - The Beginner book, it says
the following in the Java Events section:- ----------------------- The Java method thus invoked must comply with a convention, an exact signature comprising: a static keyword that makes it a class method, not an instance method a return of type java.lang.String two parameters of type javax.servlet.http.HttpServletRequest and javax.servlet.http.HttpServletResponse ------------------------- So, you get HttpServletResponse as a parameter to the Java service method. -Aswath On Tue, May 5, 2009 at 2:16 PM, tanzeem.mb <[hidden email]> wrote: > > Hi > > I am trying to get a dynamically generated excel report to be streamed back > to the browser. > How should i write my java method so that i can use the HTTPServletResponze > and org.ofbiz.base.util.UtilHttp.streamContentToBrowser(HttpServletResponse > response, byte[] bytes, java.lang.String contentType) to return data. > > My request-response map is as below: > > <request-map uri="createReport"> > <security https="true" auth="true"/> > <event type="service" invoke="crmsfa.createReport"/> > <response name="success" type="view" value="showReport"/> > > <response name="error" type="request-redirect" value="viewReport"/> > </request-map> > > What changes should i make to the following method . > public static Map createReport(DispatchContext dctx, Map context) { > -------- > -------- > } > > How can i make the HTTPServletResponse object available in my java service > method > > Can anyone give any sample java file using HTTPServletResponse object in > the > service method > > Thanks > Tanzeem > -- > View this message in context: > http://www.nabble.com/Generating-excel-report-tp23383400p23383400.html > Sent from the OFBiz - User mailing list archive at Nabble.com. > > |
In reply to this post by tanzeem.mb
The other option is to map the data then send it to a view that is ftl
that will generate the excel as a mime. you can even do this as a mini lanquage script, instead of java to pull the data then send the map in context to the ftl. tanzeem.mb sent the following on 5/5/2009 1:46 AM: > Hi > > I am trying to get a dynamically generated excel report to be streamed back > to the browser. > How should i write my java method so that i can use the HTTPServletResponze > and org.ofbiz.base.util.UtilHttp.streamContentToBrowser(HttpServletResponse > response, byte[] bytes, java.lang.String contentType) to return data. > > My request-response map is as below: > > <request-map uri="createReport"> > <security https="true" auth="true"/> > <event type="service" invoke="crmsfa.createReport"/> > <response name="success" type="view" value="showReport"/> > > <response name="error" type="request-redirect" value="viewReport"/> > </request-map> > > What changes should i make to the following method . > public static Map createReport(DispatchContext dctx, Map context) { > -------- > -------- > } > > How can i make the HTTPServletResponse object available in my java service > method > > Can anyone give any sample java file using HTTPServletResponse object in the > service method > > Thanks > Tanzeem -- BJ Freeman http://www.businessesnetwork.com/automation http://bjfreeman.elance.com http://www.linkedin.com/profile?viewProfile=&key=1237480&locale=en_US&trk=tab_pro Systems Integrator. |
In reply to this post by aswath narayana
Hi aswath
thanks. I can now generate the reports using servlet and setting the mimetype.But I still got a problem with getting parameters using request.getParameter("attributename") My service definition is as below <service name="crmsfa.reportServlet" engine="java" location="com.path.to.ReportServices" invoke="reportServlet"> <description>Views a report </description> <attribute name="reportType" type="String" mode="IN" optional="false"/> <attribute name="dateFrom" type="String" mode="IN" optional="false"/> <attribute name="dateTo" type="String" mode="IN" optional="false"/> <attribute name="request" type="javax.servlet.http.HttpServletRequest" mode="IN" optional="false"/> <attribute name="response" type="javax.servlet.http.HttpServletResponse" mode="OUT" optional="false"/> </service> Following is part of my servlet code trying to access the date parameters. reportType=(String)request.getParameter("reportType"); dateTo=(String) request.getParameter("dateTo"); dateFrom=(String) request.getParameter("dateFrom"); My problem is getting the value of parameters dateTo and dateFrom which are being defined in my entry form as below field name="dateFrom" title="From Date"> <date-time type="timestamp" input-method="time-dropdown" /> </field> <field name="dateTo" title="To Date"> <date-time type="timestamp" input-method="time-dropdown" /> </field> with regards and Thanks - Tanzeem
|
If i am correct, I think you have to use
request.getAttribute("attributename"); On Thu, May 7, 2009 at 2:56 PM, tanzeem.mb <[hidden email]> wrote: > > Hi aswath > thanks. I can now generate the reports using servlet and setting the > mimetype.But I still got a problem with getting parameters using > request.getParameter("attributename") > > My service definition is as below > > <service name="crmsfa.reportServlet" engine="java" > location="com.path.to.ReportServices" invoke="reportServlet"> > <description>Views a report </description> > <attribute name="reportType" type="String" mode="IN" > optional="false"/> > <attribute name="dateFrom" type="String" mode="IN" > optional="false"/> > <attribute name="dateTo" type="String" mode="IN" optional="false"/> > <attribute name="request" > type="javax.servlet.http.HttpServletRequest" mode="IN" optional="false"/> > <attribute name="response" > type="javax.servlet.http.HttpServletResponse" mode="OUT" optional="false"/> > > </service> > > Following is part of my servlet code trying to access the date parameters. > > reportType=(String)request.getParameter("reportType"); > > dateTo=(String) request.getParameter("dateTo"); > dateFrom=(String) request.getParameter("dateFrom"); > > My problem is getting the value of parameters dateTo and dateFrom > which are being defined in my entry form as below > > field name="dateFrom" title="From Date"> > <date-time type="timestamp" input-method="time-dropdown" /> > > </field> > <field name="dateTo" title="To Date"> > <date-time type="timestamp" input-method="time-dropdown" /> > > </field> > > with regards and Thanks > - Tanzeem > > aswath wrote: > > > > If you look at the Apache OFBiz Development - The Beginner book, it says > > the following in the Java Events section:- > > ----------------------- > > The Java method thus invoked must comply with a convention, an exact > > signature comprising: > > a static keyword that makes it a class method, not an instance method > > a return of type java.lang.String > > two parameters of type javax.servlet.http.HttpServletRequest and > > javax.servlet.http.HttpServletResponse > > ------------------------- > > > > So, you get HttpServletResponse as a parameter to the Java service > method. > > > > -Aswath > > > > On Tue, May 5, 2009 at 2:16 PM, tanzeem.mb <[hidden email]> > wrote: > > > >> > >> Hi > >> > >> I am trying to get a dynamically generated excel report to be streamed > >> back > >> to the browser. > >> How should i write my java method so that i can use the > >> HTTPServletResponze > >> and > >> org.ofbiz.base.util.UtilHttp.streamContentToBrowser(HttpServletResponse > >> response, byte[] bytes, java.lang.String contentType) to return data. > >> > >> My request-response map is as below: > >> > >> <request-map uri="createReport"> > >> <security https="true" auth="true"/> > >> <event type="service" invoke="crmsfa.createReport"/> > >> <response name="success" type="view" value="showReport"/> > >> > >> <response name="error" type="request-redirect" > >> value="viewReport"/> > >> </request-map> > >> > >> What changes should i make to the following method . > >> public static Map createReport(DispatchContext dctx, Map context) { > >> -------- > >> -------- > >> } > >> > >> How can i make the HTTPServletResponse object available in my java > >> service > >> method > >> > >> Can anyone give any sample java file using HTTPServletResponse object in > >> the > >> service method > >> > >> Thanks > >> Tanzeem > >> -- > >> View this message in context: > >> http://www.nabble.com/Generating-excel-report-tp23383400p23383400.html > >> Sent from the OFBiz - User mailing list archive at Nabble.com. > >> > >> > > > > > > -- > View this message in context: > http://www.nabble.com/Generating-excel-report-tp23383400p23423114.html > Sent from the OFBiz - User mailing list archive at Nabble.com. > > |
I am still getting null value
|
Free forum by Nabble | Edit this page |