You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jonathan Glanz <jo...@hotmail.com> on 2007/05/28 04:13:21 UTC

Redirect Question

In my setup function I need to be able to redirect to another page, any
ideas?

 

-thx, Jon


Re: Redirect Question

Posted by Hilco Wijbenga <hi...@gmail.com>.
Ok, you managed to confuse me now. :-)

On 5/28/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> What is "/app"?  Is it a page?  Tapestry 5 doesn't use a mapping to a
> servlet named "/app".  T5 should see that URL, identify it as a page render
> request and see that there's no such page, and let the servlet container
> send a normal 404 error result.

I followed the T5 tutorial and it uses

http://localhost:8080/hilo (so app=hilo, or at least that's what I
intended to refer to).

Using onActivate() works for

http://localhost:8080/hilo/start (redirects to
http://localhost:8080/hilo/new_page

but not for

http://localhost:8080/hilo (just gives me an empty page).

Is the tutorial outdated? I got the impression it was working quite well.

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


Re: Redirect Question

Posted by Howard Lewis Ship <hl...@gmail.com>.
What is "/app"?  Is it a page?  Tapestry 5 doesn't use a mapping to a
servlet named "/app".  T5 should see that URL, identify it as a page render
request and see that there's no such page, and let the servlet container
send a normal 404 error result.

On 5/28/07, Hilco Wijbenga <hi...@gmail.com> wrote:
>
> On 5/28/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> > It's easy if you do it from activate event handler method
> (onActivate()),
> > just return the page name or page instance to redirect to.  Once you
> > progress as far as the SetupRender phase, you are committed to rendering
> a
> > response.
>
> Yes, that's what I'd found on the mailinglist. It doesn't seem to
> work, though, when the Start page is implied (www.example.com/app)
> instead of explicit (www.example.com/app/start)?
>
> www.example.com/app --> blank page
> www.example.com/app/start --> redirects as expected
>
> What do I need to do to get www.example.com/app to redirect as well?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: Redirect Question

Posted by Hilco Wijbenga <hi...@gmail.com>.
On 5/28/07, Howard Lewis Ship <hl...@gmail.com> wrote:
> It's easy if you do it from activate event handler method (onActivate()),
> just return the page name or page instance to redirect to.  Once you
> progress as far as the SetupRender phase, you are committed to rendering a
> response.

Yes, that's what I'd found on the mailinglist. It doesn't seem to
work, though, when the Start page is implied (www.example.com/app)
instead of explicit (www.example.com/app/start)?

www.example.com/app --> blank page
www.example.com/app/start --> redirects as expected

What do I need to do to get www.example.com/app to redirect as well?

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


Re: Redirect Question

Posted by Howard Lewis Ship <hl...@gmail.com>.
It's easy if you do it from activate event handler method (onActivate()),
just return the page name or page instance to redirect to.  Once you
progress as far as the SetupRender phase, you are committed to rendering a
response.

On 5/27/07, Hilco Wijbenga <hi...@gmail.com> wrote:
>
> On 5/27/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> > void setup()
> > {
> >    throw new PageRedirectException("YourPageName");
> > }
>
> So what about T5? I found "onActivate()" in the mailinglist and that
> works ... partially.
>
> Requesting www.example.com/app/start redirects as expected
> [onActivate() is in Start.java] but requesting www.example.com/app
> just yields a blank page?
>
> I can get it to work using
>
> @Inject private Response response;
> public void onActivate() throws IOException {
>   response.sendRedirect("PageName");
> }
>
> but that seems a bit ugly. What is the proper Tapestry (5) way to
> redirect?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

Re: Redirect Question

Posted by Hilco Wijbenga <hi...@gmail.com>.
On 5/27/07, Jesse Kuhnert <jk...@gmail.com> wrote:
> void setup()
> {
>    throw new PageRedirectException("YourPageName");
> }

So what about T5? I found "onActivate()" in the mailinglist and that
works ... partially.

Requesting www.example.com/app/start redirects as expected
[onActivate() is in Start.java] but requesting www.example.com/app
just yields a blank page?

I can get it to work using

@Inject private Response response;
public void onActivate() throws IOException {
  response.sendRedirect("PageName");
}

but that seems a bit ugly. What is the proper Tapestry (5) way to redirect?

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


RE: Redirect Question

Posted by Jonathan Glanz <jo...@hotmail.com>.
Thx a mil mate...

-----Original Message-----
From: Jesse Kuhnert [mailto:jkuhnert@gmail.com] 
Sent: Sunday, May 27, 2007 9:23 PM
To: Tapestry users
Subject: Re: Redirect Question

void setup()
{
   throw new PageRedirectException("YourPageName");
}

?

On 5/27/07, Jonathan Glanz <jo...@hotmail.com> wrote:
>
> In my setup function I need to be able to redirect to another page, any
> ideas?
>
>
>
> -thx, Jon
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com


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


Re: Redirect Question

Posted by Jesse Kuhnert <jk...@gmail.com>.
void setup()
{
   throw new PageRedirectException("YourPageName");
}

?

On 5/27/07, Jonathan Glanz <jo...@hotmail.com> wrote:
>
> In my setup function I need to be able to redirect to another page, any
> ideas?
>
>
>
> -thx, Jon
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

Re: @EventListener Question

Posted by Jesse Kuhnert <jk...@gmail.com>.
It behaves exactly the same way as a normal listener method - the only
difference being what causes it be invoked.   So, in your example I'm not
sure what would happen but probably an error of some kind.

If you want to update a component you can use ResponseBuilder (grabbed via
IRequestCycle or hivemind autowired if you define a public abstract
ResponseBuilder getResponseBuilder() property )

http://tapestry.apache.org/tapestry4.1/ajax/responsebuilder.html

On 5/28/07, Janos Mucsi <ja...@verne.us> wrote:
>
> Hi
> Thanks, Jesse, for your answer.
> What if I want to return values from the listener method? Instead of
>
> @EventListener(elements = "myFavoriteDiv", events = "onmouseover")
>     public void watchText(BrowserEvent event)
>     {
>         System.out.println("watch text entered"+event);
>     }
>
> I want something like
>
> @EventListener(elements = "myFavoriteDiv", events = "onmouseover")
>     public List<State> watchText(BrowserEvent event)
>     {
>          // get country id from event
>          // String countryId = ...;
>          List<State> states = someService.getStates(countryId);
>          return states;
>     }
>
> (Of course, probably it would be a <select> and onChange.) Is there a
> way to do this?
>
> Thanks.
> Janos
>
> Jesse Kuhnert wrote:
> > I'm not sure what you mean, the asynchronous portion should happen
> > automatically.
> >
> > It should also behave exactly the same way as your listener method
> > would if
> > it were say a @Submit component listener or @DirectLink listener.  The
> > major
> > difference is that it automatically submits your form if you happen to
> be
> > targeting a component that implements IFormComponent. (which most form
> > based
> > Tapestry components do)
> >
> > http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html
> >
> > On 5/27/07, Janos Mucsi <ja...@verne.us> wrote:
> >>
> >> Hi
> >>
> >> I am new to Tapestry, so excuse my basic question. I am reading
> >> http://tapestry.apache.org/tapestry4.1/tapestry-annotations/index.html
> >>
> >> and was wondering how @EventListener implements asynchronous calls.
> Does
> >> anybody have a sample that behaves like the example:
> >>
> >> @EventListener(events = "selectOption", targets = "projectChoose",
> >> submitForm = "taskForm", async=true)
> >> public void projectSelected(IRequestCycle cycle)
> >> {
> >>
> >> cycle.getResponseBuilder().updateComponent("projectDescription");
> >>         cycle.getResponseBuilder().updateComponent("feedbackBlock");
> >> }
> >>
> >>
> >> Thanks!
> >>
> >> --
> >> Janos Mucsi
> >>
> >>
> >>
> >
> >
>
>
> --
> Janos Mucsi
> 209-346-4294
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

@EventListener Question

Posted by Janos Mucsi <ja...@verne.us>.
Hi
Thanks, Jesse, for your answer.
What if I want to return values from the listener method? Instead of

@EventListener(elements = "myFavoriteDiv", events = "onmouseover")
    public void watchText(BrowserEvent event)
    {
        System.out.println("watch text entered"+event);
    }

I want something like

@EventListener(elements = "myFavoriteDiv", events = "onmouseover")
    public List<State> watchText(BrowserEvent event)
    {
         // get country id from event
         // String countryId = ...;
         List<State> states = someService.getStates(countryId);
         return states;
    }

(Of course, probably it would be a <select> and onChange.) Is there a 
way to do this?

Thanks.
Janos

Jesse Kuhnert wrote:
> I'm not sure what you mean, the asynchronous portion should happen
> automatically.
>
> It should also behave exactly the same way as your listener method 
> would if
> it were say a @Submit component listener or @DirectLink listener.  The 
> major
> difference is that it automatically submits your form if you happen to be
> targeting a component that implements IFormComponent. (which most form 
> based
> Tapestry components do)
>
> http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html
>
> On 5/27/07, Janos Mucsi <ja...@verne.us> wrote:
>>
>> Hi
>>
>> I am new to Tapestry, so excuse my basic question. I am reading
>> http://tapestry.apache.org/tapestry4.1/tapestry-annotations/index.html
>>
>> and was wondering how @EventListener implements asynchronous calls. Does
>> anybody have a sample that behaves like the example:
>>
>> @EventListener(events = "selectOption", targets = "projectChoose",
>> submitForm = "taskForm", async=true)
>> public void projectSelected(IRequestCycle cycle)
>> {
>>         
>> cycle.getResponseBuilder().updateComponent("projectDescription");
>>         cycle.getResponseBuilder().updateComponent("feedbackBlock");
>> }
>>
>>
>> Thanks!
>>
>> -- 
>> Janos Mucsi
>>
>>
>>
>
>


-- 
Janos Mucsi
209-346-4294


Re: @EventListener Question

Posted by Jesse Kuhnert <jk...@gmail.com>.
I'm not sure what you mean, the asynchronous portion should happen
automatically.

It should also behave exactly the same way as your listener method would if
it were say a @Submit component listener or @DirectLink listener.  The major
difference is that it automatically submits your form if you happen to be
targeting a component that implements IFormComponent. (which most form based
Tapestry components do)

http://tapestry.apache.org/tapestry4.1/ajax/eventlistener.html

On 5/27/07, Janos Mucsi <ja...@verne.us> wrote:
>
> Hi
>
> I am new to Tapestry, so excuse my basic question. I am reading
> http://tapestry.apache.org/tapestry4.1/tapestry-annotations/index.html
>
> and was wondering how @EventListener implements asynchronous calls. Does
> anybody have a sample that behaves like the example:
>
> @EventListener(events = "selectOption", targets = "projectChoose",
> submitForm = "taskForm", async=true)
> public void projectSelected(IRequestCycle cycle)
> {
>         cycle.getResponseBuilder().updateComponent("projectDescription");
>         cycle.getResponseBuilder().updateComponent("feedbackBlock");
> }
>
>
> Thanks!
>
> --
> Janos Mucsi
>
>
>


-- 
Jesse Kuhnert
Tapestry/Dojo team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind. http://blog.opencomponentry.com

@EventListener Question

Posted by Janos Mucsi <ja...@verne.us>.
Hi

I am new to Tapestry, so excuse my basic question. I am reading
http://tapestry.apache.org/tapestry4.1/tapestry-annotations/index.html

and was wondering how @EventListener implements asynchronous calls. Does 
anybody have a sample that behaves like the example:

@EventListener(events = "selectOption", targets = "projectChoose",
submitForm = "taskForm", async=true)
public void projectSelected(IRequestCycle cycle)
{
        cycle.getResponseBuilder().updateComponent("projectDescription");
        cycle.getResponseBuilder().updateComponent("feedbackBlock");
}


Thanks!

-- 
Janos Mucsi