aspose file tools*
The moose likes JSP and the fly likes Componentized logic in views - what to use. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Componentized logic in views - what to use." Watch "Componentized logic in views - what to use." New topic
Author

Componentized logic in views - what to use.

Ari Kovak
Greenhorn

Joined: Nov 02, 2009
Posts: 3
I'm redesigning a few related views to reuse common components. Currently (in experimental phase) I'm using include actions, and passing pages parameters with request-scoped variables (so far: collections, strings and booleans). I'm not exactly happy with this, because it feels dirty.

A stripped example:
Because the parameters are request scoped, there's a chance of similarly named variables being contaminated or inadvertently re-used. So basically, I want to do it another way. After reading the Struts Tiles taglib documentation I couldn't find a way to pass collections as a parameter. Am I wrong? It appears you can pass pages, strings and definitions, but so far I haven't found a way to pass objects of other types. I suppose this goes beyong templating, which is what Tiles is trying to do. Even if it's misusing Tiles, it would have solved the scope issue.

I'm considering the include directive which would let me keep variables within the page scope and take away the need to pass them.

Also, custom tags. I personally don't want to develop custom tags to contain the limited logic that the components have. However, it is the cleanest solution I can think of.

Is there a method I'm missing? I welcome any advice as to which way to go.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

Tag files.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Ari Kovak
Greenhorn

Joined: Nov 02, 2009
Posts: 3
*googles*
Thanks, that's exactly what I was looking for. I didn't realize I could make custom tags using JSP fragments.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60057
    
  65

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Componentized logic in views - what to use.
 
Similar Threads
jsp include nested in a foreach loop makes me crazy
JSP:Include question
how to print values on jsp page fetched from servlet
JSTL Question about c:set ... scope="request"
Confusion about "scope" attribute