You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Danny Mandel <dm...@tolweb.org> on 2004/06/17 19:15:37 UTC

passing parameters to one component that will be used in a result component

Hello all. 

I have an image search component (a form that has fields that allow a 
user to search for images) that I would like to reuse.  It will always 
look and act the same wherever it is used.  The difference, however, 
lies in the results page that the form directs to.  I would like to pass 
two parameters to that page once the user has performed a search: an 
instructions string, and a listener that will perform some action once 
the user selects an image from the search results page.

I've struggled with the best way to solve this problem, and the only way 
I can think of at the moment is to subclass the search component every 
time I want to use it and provide a custom listener that will set these 
values on the search results page.  This has the drawback of having to 
provide a (mostly) duplicate .html and .jwc each time I use it.  If it 
were just the 1 string parameter, I could have an additional hidden form 
field that stored that instructions String so it was available at form 
submission, but then I wouldn't know how to do the same thing for the 
listener object.

Does anyone have any suggestions?  Complete trashing/rethinking of the 
current implementation isn't a problem, I'm mainly looking for an 
elegant solution to this problem and to learn new  things about Tapestry.

Thank you for your time.

Sincerely,
Danny Mandel

---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org


Re: passing parameters to one component that will be used in a result component

Posted by Erik Hatcher <er...@ehatchersolutions.com>.
Yo Danny!

I may not fully understand what you're doing, but I'll give it a shot...

On Jun 17, 2004, at 1:15 PM, Danny Mandel wrote:
>
> I have an image search component (a form that has fields that allow a 
> user to search for images) that I would like to reuse.  It will always 
> look and act the same wherever it is used.  The difference, however, 
> lies in the results page that the form directs to.  I would like to 
> pass two parameters to that page once the user has performed a search: 
> an instructions string, and a listener that will perform some action 
> once the user selects an image from the search results page.

Alrighty...

> I've struggled with the best way to solve this problem, and the only 
> way I can think of at the moment is to subclass the search component 
> every time I want to use it and provide a custom listener that will 
> set these values on the search results page.  This has the drawback of 
> having to provide a (mostly) duplicate .html and .jwc each time I use 
> it.  If it were just the 1 string parameter, I could have an 
> additional hidden form field that stored that instructions String so 
> it was available at form submission, but then I wouldn't know how to 
> do the same thing for the listener object.
>
> Does anyone have any suggestions?  Complete trashing/rethinking of the 
> current implementation isn't a problem, I'm mainly looking for an 
> elegant solution to this problem and to learn new  things about 
> Tapestry.

So the form submit listener is directing to a different page than the 
current one.  How is the results page determined?  I'll toss out some 
ideas:

- Pass the results page name to the search form component.  Before 
activating the results page, set the instructions and a listener on it. 
  Then bind that listener on the results page to the image.  I'm not 
sure if this will work or not.  But the next idea should...

- Check out ICallback.  Have your image listener be on the results 
page, but in that listener perform the callback.  A callback can be 
like a page link, external link, or whatever you like.  ICallback is a 
fun and handy way to do some nice indirection.

	Erik


---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org