On Mon, Oct 13, 2014 at 9:52 PM, Geoff Callender <
geoff.callender.jumpst...@gmail.com> wrote:

> On 14 Oct 2014, at 1:14 pm, George Christman <gchrist...@cardaddy.com>
> wrote:
> > 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?
> Reuse?
> Let SiteIndex decide which components/zones to refresh based on the events
> that bubble up and their origin. Only SiteIndex should know what SiteIndex
> contains, so it's the right guy to make these decisions. It sounds like
> you're still trying to make components command their containers. If you let
> go of that idea then the rest will fall into place, elegantly delegated and
> decoupled.
>

Well, security is a classic cross-cutting concern. Geoff's advice regarding
sending events is valid but still, every (possibly highly specialized)
child component would need to know about the notAuthenticated event and
send it up in the hopes that the container would handle it properly. If
instead, you'd cause a security exception at onValidateFromForm(), you'd
technically be able write an ExceptionHandlerAssistant that would return a
suitable json response to trigger showing the right login block, althrough
obviously that would still require help from the layout component. On top
of it, you might still want to keep the results of the original form submit
around somewhere. I haven't attempted at implementing support for it
end-to-end but if anybody has made a specific implementation along these
lines, I'd be totally willing to try and generalize the concept.

Kalle



>
> > 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
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>
>

Reply via email to