IMHO, a better technique is to bubble up an event. It's better because it 
doesn't require the component to know anything about its container.

In the example below, PersonUpdate bubbles up UPDATED like this...

        componentResources.triggerEvent(UPDATED, new Object[] { person }, null);

...which the page catches with...

        void onUpdatedFromPersonUpdate(Person person) {...}

...and refreshes the zone.

        
http://jumpstart.doublenegative.com.au/jumpstart7/examples/javascript/reusablemodal/1

On 13 Oct 2014, at 4:55 pm, George Christman <gchrist...@cardaddy.com> wrote:

> Nvm, After all these years, I was still completely unaware of
> @InjectContainer. Thanks.
> 
> On Mon, Oct 13, 2014 at 1:38 AM, George Christman <gchrist...@cardaddy.com>
> wrote:
> 
>> I have a modal login box. When a user logs in through the login box, I
>> would like to reload a zone in the nav bar containing the user name which
>> is contained within the layout component.  I've tried to use
>> @InjectComponent and call a method from within the layout component, but I
>> get
>> 
>> *Unable to attach page sell/Index: Unable to inject component into field
>> layout of class com.cardaddy.auto.components.LoginRegister: Component
>> sell/Index:layout.loginregister does not contain embedded component
>> 'layout'.*
>> 
>> 
>> The code looks something like
>> 
>> //html is the layout component
>> <html>
>>    <t:zone t:id="loginNavZone>Hi ${name}</t:zone>
>> 
>>    <t:modaldialog>
>>           <loginregister/>
>>    </t:modaldialog>
>> </html>
>> 
>> 
>> public class LoginRegister {
>> 
>>   @InjectComponent
>>   private Layout layout;
>> 
>>   public void onValidateFromLoginForm() {
>>        layout.getLoginNavZone();
>>    }
>> }
>> 
>> public class Layout {
>>    public void getLoginNavZone() {
>>        ajaxResponseRenderer.addRender("loginNavZone", loginNavZone);
>>    }
>> }
>> 
>> I know how to access a page using @PageInject from a component, but I can
>> not seem to access a component from within a component unless I declare the
>> component within the tml. Anybody know how to accomplish this?
>> --
>> George Christman
>> www.CarDaddy.com
>> P.O. Box 735
>> Johnstown, New York
>> 
>> 
> 
> 
> -- 
> George Christman
> www.CarDaddy.com
> P.O. Box 735
> Johnstown, New York

Reply via email to