You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Patrick Casey <pa...@adelphia.net> on 2005/09/04 00:49:16 UTC

Awkward Component/Parent Communication Problem

 

            Hi Folks,

 

            I seem to have painted myself into something of a design corner
here, and I was hoping somebody could suggest a way out.

 

            I have a page.

            Upon this page is a form.

            Within this form is a component that renders a list of email
addresses and includes three blank lines for "newAddress1", "newAddress2",
newAddress3 and a button marked "add new addresses".

            This add button is bound to a listener on the component.

 

            Since you really can't do anything safely in a listener during a
rewind, I want to set a flag here and have the page's listener (the one
bound to the form), actually do all the work. The question is though, is
there a recommended, loosely coupled way for a component's listener to
"bubble up" to its containing form's listener?

 

            I mean I can do:

 

            MyPage page = (MyPage) page();

            page.setFlag(COMPONENT_FLAG);

 

            But then, not only do I have a component which will only work on
a MyPage, but I have to add handler code actually *on* the page, so I don't
really have an encapsulated component :-(.

 

            Any suggestions?

 

            --- Pat


Re: Awkward Component/Parent Communication Problem

Posted by Shing Hing Man <ma...@yahoo.com>.
I have encounter a similar problem as yours recently.
(I am using Tapestry 3).

My solution is to wrap around the orginal address
component 
in an 'outer component'. The java class
associated with this outer component extends 
BaseComponent.
In the java class of the outer component,
override the  renderComponent method like this :

   
  super.renderComponent(iMarkupWriter, iRequestCycle);

  if (rewind is done) {
     // By the time you reach here, your address
(inner) component
     // would have rewinded.
     // In the listener method asscoiated  with the
add button, just
     // set a flag to indicate if it has been pressed.
     // Here you can test the value of that flag, and
act accordingly. 
  }

 
Shing
--- Patrick Casey <pa...@adelphia.net> wrote:

>  
> 
>             Hi Folks,
> 
>  
> 
>             I seem to have painted myself into
> something of a design corner
> here, and I was hoping somebody could suggest a way
> out.
> 
>  
> 
>             I have a page.
> 
>             Upon this page is a form.
> 
>             Within this form is a component that
> renders a list of email
> addresses and includes three blank lines for
> "newAddress1", "newAddress2",
> newAddress3 and a button marked "add new addresses".
> 
>             This add button is bound to a listener
> on the component.
> 
>  
> 
>             Since you really can't do anything
> safely in a listener during a
> rewind, I want to set a flag here and have the
> page's listener (the one
> bound to the form), actually do all the work. The
> question is though, is
> there a recommended, loosely coupled way for a
> component's listener to
> "bubble up" to its containing form's listener?
> 
>  
> 
>             I mean I can do:
> 
>  
> 
>             MyPage page = (MyPage) page();
> 
>             page.setFlag(COMPONENT_FLAG);
> 
>  
> 
>             But then, not only do I have a component
> which will only work on
> a MyPage, but I have to add handler code actually
> *on* the page, so I don't
> really have an encapsulated component :-(.
> 
>  
> 
>             Any suggestions?
> 
>  
> 
>             --- Pat
> 
> 


Home page :
  http://uk.geocities.com/matmsh/index.html


	
	
		
___________________________________________________________ 
Yahoo! Messenger - NEW crystal clear PC to PC calling worldwide with voicemail http://uk.messenger.yahoo.com

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