You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Erik Putrycz <er...@apption.com> on 2009/08/24 23:21:04 UTC

Create actionlinks in components with page context

I started an app based on trails and T5.1. On my layout component, I want to
have a button to toggle the locale from french to english for any page. This
works fine, however if the page has a context, that context is lost for the
action link. Is there any way to access the page context, or create action
links with the current context?

Erik.

-----
Apption Software
-- 
View this message in context: http://www.nabble.com/Create-actionlinks-in-components-with-page-context-tp25123666p25123666.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Create actionlinks in components with page context

Posted by DH <ni...@gmail.com>.
Sure, there must be a passivate method. Action link in tmeplate is fairly simple: <a href="#" t:type="actionlink" t:id="english">English</a>.


DH
http://www.gaonline.com.cn

----- Original Message ----- 
From: "Erik Putrycz" 
To: <us...@tapestry.apache.org>
Sent: Wednesday, August 26, 2009 4:44 AM
Subject: Re: Create actionlinks in components with page context


> 
> How is your template looking like for the action link?
> I just looked at the action link code and there doesn't seem to be any magic
> to add the current page context.
> And does your page class has a passivate method?

Re: Create actionlinks in components with page context

Posted by Erik Putrycz <er...@apption.com>.
How is your template looking like for the action link?
I just looked at the action link code and there doesn't seem to be any magic
to add the current page context.
And does your page class has a passivate method?



DH-14 wrote:
> 
> My action handler is inside a component, for example, the layout
> component.
> 
> If there is context, url for the action link is like
> /app/pagename.layout.english?t:ac=1 (1 is context), after link is clicked,
> the redirect url is like /app/pagename/1
> 
> 


-----
Apption Software
-- 
View this message in context: http://www.nabble.com/Create-actionlinks-in-components-with-page-context-tp25123666p25141737.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Create actionlinks in components with page context

Posted by ningdh <ni...@gmail.com>.
My action handler is inside a component, for example, the layout component.

If there is context, url for the action link is like /app/pagename.layout.english?t:ac=1 (1 is context), after link is clicked, the redirect url is like /app/pagename/1

Thanks,
DH

----- Original Message ----- 
From: "Erik Putrycz" 
To: <us...@tapestry.apache.org>
Sent: Tuesday, August 25, 2009 10:44 PM
Subject: Re: Create actionlinks in components with page context


> 
> This is my action handler
>    void onActionFromToggleLocale()
>    {
>    Locale current = locale.get();
>    if (current == null || current.getDisplayLanguage().equals("en"))
>    locale.set(Locale.CANADA_FRENCH);
>    else
>    locale.set(Locale.CANADA);
>    }
> 
> btw, is your action handler inside a component or in the page class?
> How are the urls generated looking like?

Re: Create actionlinks in components with page context

Posted by Erik Putrycz <er...@apption.com>.
This is my action handler
    void onActionFromToggleLocale()
    {
    	Locale current = locale.get();
    	if (current == null || current.getDisplayLanguage().equals("en"))
    		locale.set(Locale.CANADA_FRENCH);
    	else
    		locale.set(Locale.CANADA);
    }

btw, is your action handler inside a component or in the page class?
How are the urls generated looking like?




DH-14 wrote:
> 
> Since my action handler returns Void, so in my case T5 will return current
> page(with context) and redirects, here T5 will carry the context again
> without any work of mine.
> 
> What about your action handler?
> 
> DH
> http://www.gaonline.com.cn
> 
> ----- Original Message ----- 
> From: "Erik Putrycz" <er...@apption.com>
> To: <us...@tapestry.apache.org>
> Sent: Tuesday, August 25, 2009 11:19 AM
> Subject: Re: Create actionlinks in components with page context
> 
> 
>> 
>> 
>> 
>> DH-14 wrote:
>>> 
>>> I don't quite understand your case.
>>> The page activation context has been handled by Tapestry itself, we
>>> don't
>>> need handle it in our action link.
>>> I have finished something similar to your case. I just set the correct
>>> locale to PersistentLocale and everything works perfectly.
>>> 
>> 
>> when I have a page with a url like http://localhost:8080/myapp/modules/1
>> (1
>> is the context), the actionlink doesn't carry the 1 and the action id is
>> lost after clicking on my actionlink. The action in the code happens but
>> after it tries to redirect to http://localhost:8080/myapp/modules which
>> doesn't work because it requires an activation parameter.
>> Is this working differently for you?
>> 
>> -----
>> Apption Software
>> -- 
>> View this message in context:
>> http://www.nabble.com/Create-actionlinks-in-components-with-page-context-tp25123666p25127643.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>> 
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>>
> 


-----
Apption Software
-- 
View this message in context: http://www.nabble.com/Create-actionlinks-in-components-with-page-context-tp25123666p25135763.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Create actionlinks in components with page context

Posted by DH <ni...@gmail.com>.
Since my action handler returns Void, so in my case T5 will return current page(with context) and redirects, here T5 will carry the context again without any work of mine.

What about your action handler?

DH
http://www.gaonline.com.cn

----- Original Message ----- 
From: "Erik Putrycz" <er...@apption.com>
To: <us...@tapestry.apache.org>
Sent: Tuesday, August 25, 2009 11:19 AM
Subject: Re: Create actionlinks in components with page context


> 
> 
> 
> DH-14 wrote:
>> 
>> I don't quite understand your case.
>> The page activation context has been handled by Tapestry itself, we don't
>> need handle it in our action link.
>> I have finished something similar to your case. I just set the correct
>> locale to PersistentLocale and everything works perfectly.
>> 
> 
> when I have a page with a url like http://localhost:8080/myapp/modules/1 (1
> is the context), the actionlink doesn't carry the 1 and the action id is
> lost after clicking on my actionlink. The action in the code happens but
> after it tries to redirect to http://localhost:8080/myapp/modules which
> doesn't work because it requires an activation parameter.
> Is this working differently for you?
> 
> -----
> Apption Software
> -- 
> View this message in context: http://www.nabble.com/Create-actionlinks-in-components-with-page-context-tp25123666p25127643.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
>

Re: Create actionlinks in components with page context

Posted by Erik Putrycz <er...@apption.com>.


DH-14 wrote:
> 
> I don't quite understand your case.
> The page activation context has been handled by Tapestry itself, we don't
> need handle it in our action link.
> I have finished something similar to your case. I just set the correct
> locale to PersistentLocale and everything works perfectly.
> 

when I have a page with a url like http://localhost:8080/myapp/modules/1 (1
is the context), the actionlink doesn't carry the 1 and the action id is
lost after clicking on my actionlink. The action in the code happens but
after it tries to redirect to http://localhost:8080/myapp/modules which
doesn't work because it requires an activation parameter.
Is this working differently for you?

-----
Apption Software
-- 
View this message in context: http://www.nabble.com/Create-actionlinks-in-components-with-page-context-tp25123666p25127643.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


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


Re: Create actionlinks in components with page context

Posted by DH <ni...@gmail.com>.
I don't quite understand your case.
The page activation context has been handled by Tapestry itself, we don't need handle it in our action link.
I have finished something similar to your case. I just set the correct locale to PersistentLocale and everything works perfectly.
Like:
public void onActionFromEnglish() {
        persistentLocale.set(Locale.ENGLISH);
}


DH
http://www.gaonline.com.cn

----- Original Message ----- 
From: "Erik Putrycz" <er...@apption.com>
To: <us...@tapestry.apache.org>
Sent: Tuesday, August 25, 2009 5:21 AM
Subject: Create actionlinks in components with page context


> 
> I started an app based on trails and T5.1. On my layout component, I want to
> have a button to toggle the locale from french to english for any page. This
> works fine, however if the page has a context, that context is lost for the
> action link. Is there any way to access the page context, or create action
> links with the current context?
> 
> Erik.
> 
> -----
> Apption Software
> -- 
> View this message in context: http://www.nabble.com/Create-actionlinks-in-components-with-page-context-tp25123666p25123666.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
>