Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

How to access RenderRequest in a custom Tag?

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I've mentioned this problem in a previous posting - I can't seem to get a working example of Struts with JSR-168 portlets. Someone suggested the MVCPortlet framework, but then it's got it's own learning curve. The result is that I'm having to work on the JSP bit without the wonderful Struts tags. I'm having to use for loops and whatnot inside the JSPs - messy. I'm not familiar with JSF and I'm not sure if I should start learning that in an effort to get pre-defined tag libraries for use in portlet JSPs.

So the option I considered was to make my own custom tags and use them for the various dynamic stuff we have on JSPs. A problem crops up: My javabean object with all my form-field values and success/error messages is in the PortletSession object which can be accessed through the 'renderRequest' object on the JSP which is available after placing the <portlet efineObjects/> tag.

I can access renderRequest on the JSP - but how do I access it in the custom tag? Am I on the right track? Is it even possible to use portlet JSPs
with custom tags that need to access portlet-driven information thru the renderRequest object?

Rohit Lal
 
Author
Posts: 121
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rohit,

just a few ideas:

1) I would recommend to use JSTL tags instead of implementing your own custom tags for loops etc. they work quite well in conjunction with JSR 168 and JSP, and you may use them within Struts WebApps, too (learning effort).

2) A quite easy way to offer your Java objects in the JSP, if stored in the portlet session (portlet scope), is to put them as an attribute in the render request as well (in your doView etc. method, before including the JSP). This way you can get them as an attribute from the normal implicit object "request" in the JSP, and you do not need renderRequest for that.
Another advantage is that you can access them easily from JSTL tags with its EL-expressions.

3) It is possible to access the render request from within a custom tag class. I am not sure whether I should recommend to do so in your case(see 1 + 2) but you can. See Java Portlet Specification PLT.16.3.2 for details (it is advertised as request attribute with standardized key).

Greetings,
Stefan
 
Rohit Lal
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephan,

I'll work on your tips and let you know as soon as I achieve some milestone.

Thanks for your advice.

Best regards,

Rohit
 
Eat that pie! EAT IT! Now read this tiny ad. READ IT!
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic