• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Passing parameters to a reused table in the same definition page

 
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is an extension to the question that I've posted at this previous posting..

I have a page which is a tile definition, that reuses a contained pagelet several times within that one page.

Pictures tell a thousand words, so below is my clumsy attempt to do so:


Now, all my pagelets are of different JSPs, each doing their own getting different attribute of different Collections. All the Collections contain elements of the same object. That is, all the lists displayed in all the pagelets have the same fields.

I want <B>a single JSP</B> instead of the many that I currently have to display the different Collections as the same code are being used.

But how could I do that ? Can I pass parameters to the same JSP to achive that result ? If I can, how ?

Any suggestion would be very much appreciated.
[ February 25, 2005: Message edited by: Ken Loh ]
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ken Loh:

Now, all my pagelets are of different JSPs, each doing their own getting different attribute of different Collections. All the Collections contain elements of the same object. That is, all the lists displayed in all the pagelets have the same fields.



Set up all your collections into a single list before setting the list to a request attribute. That way your list can use the same key each time and your jsp doesn't have to care about how many Collections it should display or specific names for each one.

Your page logic now:
// get Collection
// iterate through Collection
-- // display item

// get anotherCollection
// iterate through another Collection
-- // display item

// get anotherCollection
// iterate through another Collection
-- // display item

Your page logic with the change:
// get list
// iterate through list
-- // iterate through Collection
-- -- // display item
 
Ken Loh
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The example that I've given was a simplified one. My actual page actually displays the instances of the pagelets in 2 columns and multiple rows, with each instance displaying objects of the same class but of different business categories.

My next question would be: how do I ensure the sequence of which instance of the pagelet executes first ? The example that you've given requires that a particular sequence of execution is known. Does Struts Tiles follow a particular order, such as left-right, then down ?

Originally posted by Marc Peabody:


Set up all your collections into a single list before setting the list to a request attribute. That way your list can use the same key each time and your jsp doesn't have to care about how many Collections it should display or specific names for each one.

Your page logic now:
// get Collection
// iterate through Collection
-- // display item

// get anotherCollection
// iterate through another Collection
-- // display item

// get anotherCollection
// iterate through another Collection
-- // display item

Your page logic with the change:
// get list
// iterate through list
-- // iterate through Collection
-- -- // display item

 
Marc Peabody
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Ken Loh:
My next question would be: how do I ensure the sequence of which instance of the pagelet executes first ? The example that you've given requires that a particular sequence of execution is known. Does Struts Tiles follow a particular order, such as left-right, then down ?



Ah, but you're not using multiple tiles anymore. You said you wanted the whole thing in one JSP. That one JSP will define how to display the data. The sequence = the order of the Collections in your List. The first Collection in the list is rendered first, the second next, and so on.
 
Ken Loh
Ranch Hand
Posts: 190
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am still using multiple tiles as mentioned in my original post. All the child pagelets are in one big struts definition page. All tiles are instances of the same JSP.

When the JSP is used to render the first pagelet, it gets and then removes the list from the collection. If the sequence of this rendering is predictable, then all pagelets should be able to get their list correctly.

Therefore, what I would like to ascertain is: is this pagelet rendering/creation sequence predictable. If yes, e.g. pagelets are rendered from left to right, and then from top to bottom, then the Action object that prepares the sequence of the lists in the collection can do the job correctly. Otherwise, a pagelet may get other pagelet's list instead.

The above question leads to another question, what if one or more of these pagelets contains instances of the same JSP as all other tiles within them ? How to predict the sequence then ?

Originally posted by Marc Peabody:


Ah, but you're not using multiple tiles anymore. You said you wanted the whole thing in one JSP. That one JSP will define how to display the data. The sequence = the order of the Collections in your List. The first Collection in the list is rendered first, the second next, and so on.


[ March 05, 2005: Message edited by: Ken Loh ]
 
You showed up just in time for the waffles! And this tiny ad:
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
reply
    Bookmark Topic Watch Topic
  • New Topic