So I was able to get it working by using the following code inside of
SiteIndex, but this does not seem very reusable.

@InjectComponent
    private Layout layout;

void onShowLoginRegister() {
        layout.onShowLoginRegister();
    }

So is this the correct way to do this for this scenario?

My next question which I think is a little bit more complicating is
how do I use my void onShowLoginRegister event handler to refresh
multiple zones in different components and still keep the code
reusable? Is that possible?

On Mon, Oct 13, 2014 at 8:27 PM, George Christman
<gchrist...@cardaddy.com> wrote:
> John I'm a little confused with step 2.
>>
>> 1) componentA - trigger event
>> onSuccessFromLogin() {
>>     componentResources.triggerEvent("LoginComplete"...
>>
>> 2) container of both A and B components - handover event
>> onLoginComplete(Object[] ctxValues) {
>>     componentB.onLoginComplete(ctxValues)
> I don't understand this method, where does it belong? I thought the
> idea was not to couple these so tightly together?
>> ...
>> }
>>
>> 3) componentB - handle event
>> onLoginComplete(Object[] ctxValues) {
>>     ajaxResponseRenderer.addRender(zone);
>> }
>
> Also, can componentResources.triggerEvent("LoginComplete", null, null)
> be called from any component and fire the event handler within the
> layout component?
>
> I have an example where I have layout, page, component and I'm trying
> to trigger logginComplete from the component to the layout and can't
> seem to get it to work.
>
>
> looks kinda like this
>
> @Events({Create.LOGINREGISTER})
> public class Create {
>
>     public static final String LOGINREGISTER = "showLoginRegister";
>
> public void onValidateFromForm() {
>         setVehicleData();
>
>         if (form.isValid() && userProfile == null) {
>             System.out.println("onValidate");
>             componentResources.triggerEvent(LOGINREGISTER, null, null);
>         }
>
>     }
> }
>
> public class Layout {
>
> void onShowLoginRegister() {
>         function = Function.LOGIN;
>
>         if (request.isXHR()) {
>             ajaxResponseRenderer.addRender(loginRegisterModalZone);
>         }
>
>     }
> }
>
> SellIndex calls Layout component and also calls Create component. The
> login exist in the layout and I'm trying to fire it from the Create
> component.
>
> <html t:type="layout">
>     <t:create/>
> </html>
>
>
>
>
>>
>> This is a little clumsy, looks boilerplate and should be done in the 
>> background with a publisher-subscriber annotation provided by the framework 
>> IMO. But it is completely decoupled with respect to the components. :)
>>
>> regards,
>> John



-- 
George Christman
www.CarDaddy.com
P.O. Box 735
Johnstown, New York

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to