No way to find out the triggering component that I'm aware of.

Incidentally, the original poster is incorrect regarding changing onSuccessFromXXX to onSuccess. In T5, events only ever bubble up, never back down. So it's true that onSuccess within the layout component will handle any forms contained in the layout component or it's subcomponent. But it won't handle any events contained in the pages thaht include layout, or any of those sub-components. This is probably easiest to understand with an example:

Page.tml:
<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd";>
  <t:layout>
       <t:form t:id="pageform">
           ...
       </t:form>
        <t:customcomponent t:id="pagecustom"/>
  </t:layout>
</html>

layout.tml:
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd ">
    <t:form t:id="layoutform">
        ...
    </t:form>
    <t:customcomponent t:id="layoutcustom"/>
</t:container>

customcomponent.tml:
<t:container xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd ">
    <t:form t:id="customform">
        ...
    </t:form>
</t:container>

layout.java:
...
  public void onSuccess() {
        System.out.pritnln("Layout handled a form submission");
  }
...


So, when will we see "Layout handled a form submission" printed to the console? * We will see it when the layoutform is submitted; in this case, the originating event will be from layoutform. * We will also see it when the customform in customcomponent that is included in layout.tml (layoutcustom) is submitted. In this case, the originating event as layout sees it will be layoutcustom, so for a specific handler, you would have onSuccessFromLayoutcustom.
* We will NOT see it when pageform is submitted.
* We will NOT see it when customform, included via the customcomponent on the page (pagecustom) is submitted. The reason is because the container of pagecustom isn't layout, it's Page. So assuming your layout only has the single login form, you can just as well right onSuccess as you can onSuccessFromXYZ.

This behavior is critical for ensuring that components can be dropped into any page and "Just Work". Imagine if you used a third party component on your page and suddenly your forms stopped working!

Anyway, hth. Btw, Inge is right... modify your code slowly and find out when it starts working. You'll find the solution to your problem faster that way. :)

Robert

On Jan 5, 2010, at 1/55:42 AM , Inge Solvoll wrote:

I don't know. What I DO know is this:

Trying hard to explain why your problem doesn't make sense is not a very good way of solving it. I do that very often, and I'm always corrected by
someone who asks the obvious questions ;)

The best way is to "binary search" your way through this, by modifying your code step by step in order to find out when the event handler will actually be called on the page where the problem is. Then you can step back and you
will most likely find that your problem was a rather trivial one.

To the other guys: Is there a way in an event handler like onSuccess to find
out which component triggered the event?

On Tue, Jan 5, 2010 at 11:38 AM, lebenski <be...@gamesys.co.uk> wrote:


Ok I think I'm missing something because I don't understand why this would
happen.

If I have two pages:

Page1.tml

<t:layout>
Page 1 Goes Here
</t:layout>

Page2.tml

<t:layout>
Page 2 Goes Here
</t:layout>

And a layout...

Layout.tml (simplified)
<html>
<body>
<t:form t:id="hello">
...form content
</t:form>
</body>
</html>

Layout.java

...

void onSuccessFromHelloForm() {
  System.out.println("Hello called");
}

Page 1 is accessed using a normal pagelink:

<t:pagelink page="Page1">Page1</pagelink>

But Page 2 is returned from a method call on some other page and injected
using InjectPage:

SomeOtherPage.java

@InjectPage
private Page2 page2;

Object doSomething() {

//something happens

return page2;

}

How come the onSuccessFromHelloForm() is called when I submit the hello
form
contained in the layout on page1, but not when I submit the hello form contained in the layout on page 2? Why has the origin changed in this
case?


Inge Solvoll-2 wrote:

I only suggested it for testing to see if it gets called. If it gets
called,
it means that the origin changed, and your "FromXXX" must be changed.

On Tue, Jan 5, 2010 at 11:23 AM, lebenski <be...@gamesys.co.uk> wrote:


This isn't the form I'm having trouble with. The "Submit a Question"
form
works fine.

The form that is not working is the LoginForm in the layout.  Using
onSuccessFromLoginForm works in all other pages except the confirmation page. Are you suggesting that I should change the method in my layout
class
to "onSuccess"? this won't work as this method will get called for all
forms
on the site (as it resides in the layout).


Inge Solvoll-2 wrote:

I think what Howard said was that your "FromQuestionForm" part won't
work,
since the origin changes when the event bubbles up. Change the name to
"onSuccess" and see if gets called then.

On Tue, Jan 5, 2010 at 10:47 AM, lebenski <be...@gamesys.co.uk>
wrote:


Hi Igor,

I thought i'd spelled out this issue fairly clearly, but here goes
again.
All of my pages use a layout along these lines:

http://tapestry.apache.org/tapestry5/guide/layout.html

Inside this component I have a login form. This login form works on
all
pages, except for a specific page called 'Confirmation'. I use this
page
slightly differently to the others by injecting it using @InjectPage,
setting a couple of properties on it, and then returning it:

@InjectPage
private Confirmation confirmation;

Object onSuccessFromQuestionForm() {
     //processing
      confirmation.setType(ConfirmationType.SUCCESS);
     confirmation.setMessage(Messages.get("question-submit"));

     return confirmation;
}

For some reason, the login form does not work on the Confirmation
page,
the
onSuccessFromLoginForm method that resides within my layout is simply
never
called. My hunch is that this issue is something to do with a nuance
of
the
@InjectPage annotation that causes the page to behave differently,
but
I'm
really not sure.

I hope this is clearer.


Igor Drobiazko wrote:

Your explanation is unclear. This way you never get an answer.
Please
be
more precise and post more of your code.

On Mon, Jan 4, 2010 at 11:07 AM, lebenski <be...@gamesys.co.uk>
wrote:


I have a layout component that contains a login form:

<t:form t:id="loginForm">
<t:textfield t:id="loginUsernameField" t:value="memberName"
height="30"/>
      <t:passwordfield t:id="loginPasswordField"
t:value="password"
/>
      <t:submit id="loginSubmit" value="message:login"/>
</t:form>

Page Class:

Object onSuccessFromLoginForm() {
      try{
          loggedInMember = loginManager.logUserIn(new
Login(memberName,
password));
      } catch(LoginException e) {
          //Login Error Processing
      }

      return Index.class;
}

I also have a generic confirmation page which I use for page flows
where
I
need to present some message to the user. For example "Thanks for
submitting a question"

SubmitQuestion.java

@InjectPage
private Confirmation confirmation;

Object onSuccessFromQuestionForm() {
      //processing
      confirmation.setType(ConfirmationType.SUCCESS);
      confirmation.setMessage(Messages.get("question-submit"));

      return confirmation;
}

The confirmation template itself is inside the layout:

<t:layout
xmlns:t="http://tapestry.apache.org/schema/tapestry_5_1_0.xsd
">
      ${type}<br/>
      ${message}
</t:layout>

However, for some reason I don't seem to have access to the layout
from
this
confirmation page. If I try to use the login form, the Index page
is
loaded
but the user is not logged in.  In fact as far as I can see
(through
debugging), the onSuccessFromLoginForm() method in the Layout is
never
called.

I'm at a bit of a loss as to why this is happening, as this is
working
on
all other pages in my application. Is there some specific nuance
of
using
@InjectPage that could be causing this issue?
--
View this message in context:



http://old.nabble.com/-T5.0.18--%40InjectedPage-does-not-have-access-to-it%27s-own-layout-tp27010913p27010913.html
Sent from the Tapestry - User mailing list archive at Nabble.com.



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




--
Best regards,

Igor Drobiazko
http://tapestry5.de/blog



--
View this message in context:


http://old.nabble.com/-T5.0.18--%40InjectedPage-does-not-have-access-to-it%27s-own-layout-tp27010913p27025941.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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





--
View this message in context:

http://old.nabble.com/-T5.0.18--%40InjectedPage-does-not-have-access-to-it%27s-own-layout-tp27010913p27026345.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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





--
View this message in context:
http://old.nabble.com/-T5.0.18--%40InjectedPage-does-not-have-access-to-it%27s-own-layout-tp27010913p27026479.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
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