What I am doing here is as under.
I have a commandButton on screen to which I have attached an actionListener. When the button is clicked the action Listener invoked and the following lines executes
PortletResponse portletResponse = (PortletResponse)externalContext.getResponse(); HttpServletResponse httpResponse = PortalUtil.getHttpServletResponse(portletResponse);
generateReport(httpResponse.getOutputStream());
generateReport after some business logic executed the following lines.
context.put(...);
...
...
BufferedWriter writer = writer = new BufferedWriter(
new OutputStreamWriter(fos));//where fos is outputstream
if (t != null){// t is Velocity template
t.merge(context, writer);//context is VelocityContext
}
writer.flush();
writer.close();
there is no other call after generateReport method. The request finishes after generatReport returns and I expect that it should show me the dialog box but it isn't.
Hope you will get the idea.
Edit:
Thanks for your response Olaf
1) First of all I know very well that portlet dont have any notion of button or actionlisteners. Definitly I amd using a framework named Icefaces or whichever it is.
2) It was just my idea to generate document, as initially i donot know about the fact that portlet only display markup and nothjing else. My mistake :).
3) Well I think i already mentioned that I have to use the method and even I cant change it at all. So whatever the code may be, I have to implement the functionality and the code sample I have given is sufficient in that case.
4) I did some research on portlets and found that in JSR 268 'Resource Serving' functionality has been provided but in JSR 168 there is no such support. But the important thing is that the solutions I have found are all JSP dependant and m using xhtml format for UI rendering.
5) What m doing is that I have a portlet displayed transactions and I've got a requirement to provide a 'Print Transactions' button on portlet which will actually print what is displayed on that page. And for that purpose I've provided a method named 'generateReport' which is currently used in old JSP environment i.e having called this method from JSP.
6) I know that the code seems to be fundamentally wrong but having implementing a seperate servlet is another wrong that I will do with the code. I have done research for that and m 85 % close to solution. M thinking about resource serving solution and I dont think that a seperate servlet is much elegant solution.
I will really appreciate any help from your side and I hope that you got some idea what m doing and you should.
Thanks and Regards,