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

Reply via email to