You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by armhold <ar...@gmail.com> on 2012/03/23 01:04:46 UTC

inferring locale from URL in 1.5

What's the cleanest way to set a user's locale based on the domainname of the
URL of the request in 1.5?  

https://cwiki.apache.org/WICKET/wicket-and-localized-urls.html This guide 
relies on overriding newRequestCycleProcessor(). Would a proper 1.5 analog
be to add a custom AbstractRequestCycleListener like this?

		RequestCycleListenerCollection listeners = new
RequestCycleListenerCollection();
		application.getRequestCycleListeners().add(listeners);
                listeners.add(new AbstractRequestCycleListener() {
                        public void onBeginRequest(RequestCycle cycle) {
                               Session.get().setLocale(...);
                        }
    
               });

BTW, I've been asked to use the domainname for the locale (vs the
context/servlet path), so my URLs will look like: fr.example.com/somepage.  

I'm planning to use (HttpServletRequest)
getContainerRequest()).getServerName()) for this, unless there is something
nicer.

Thank you.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4497412.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: inferring locale from URL in 1.5

Posted by Martijn Dashorst <ma...@gmail.com>.
You could try http://wicket-examples.herokuapp.com but that is not an
officially supported deployment.

Martijn

On Mon, Mar 26, 2012 at 3:17 PM, armhold <ar...@gmail.com> wrote:
> Try clicking the "source code" links from wicket-library.com. Always times
> out for me.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4505742.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com

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


Re: inferring locale from URL in 1.5

Posted by armhold <ar...@gmail.com>.
Hmm, I was actually planning to use that code (LazyHttpsConfig)
myself. Looked like a nice way to avoid hard-coding port numbers for
dev vs prod use.  Maybe not now. :-)


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4505931.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: inferring locale from URL in 1.5

Posted by Martin Grigorov <mg...@apache.org>.
Nice!
It is just RequestMappers application. Somehow it extracts the
internal port of Tomcat instead of using the external (Apache HTTPD)
port.
Viewing sources of any other demo app works OK.

On Mon, Mar 26, 2012 at 3:17 PM, armhold <ar...@gmail.com> wrote:
> Try clicking the "source code" links from wicket-library.com. Always times
> out for me.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4505742.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: inferring locale from URL in 1.5

Posted by armhold <ar...@gmail.com>.
Try clicking the "source code" links from wicket-library.com. Always times
out for me. 

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4505742.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: inferring locale from URL in 1.5

Posted by Martin Grigorov <mg...@apache.org>.
wicketstuff.org is the one that is down most of the time.
wicket-library.com is OK, I've never had problems with it.

On Sun, Mar 25, 2012 at 7:39 PM, armhold <ar...@gmail.com> wrote:
> Martin,
>
> The wicket-examples site rarely works for me (server under-resourced?) but I
> found the code in the examples section of the Wicket source from git.
>
> LocaleFirstMapper was a huge help; I'm fairly sure I wouldn't have gotten it
> working without that reference, so thank you very much.  Here's what I came
> up with:
>
> https://gist.github.com/2198074

This shows that the new IRequestMapper/IRequestHandler impls are very
flexible :-)

>
> I suspect that stripping the locale from the hostname (vs path segment) is
> not needed, since you were probably doing that in your example so that the
> locale doesn't show up as a parameter to the page. I'm still experimenting
> with it.
>
> Thanks again for your help.

Have fun! :-)

>
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4503485.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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


Re: inferring locale from URL in 1.5

Posted by armhold <ar...@gmail.com>.
Martin,

The wicket-examples site rarely works for me (server under-resourced?) but I
found the code in the examples section of the Wicket source from git. 

LocaleFirstMapper was a huge help; I'm fairly sure I wouldn't have gotten it
working without that reference, so thank you very much.  Here's what I came
up with:

https://gist.github.com/2198074

I suspect that stripping the locale from the hostname (vs path segment) is
not needed, since you were probably doing that in your example so that the
locale doesn't show up as a parameter to the page. I'm still experimenting
with it.

Thanks again for your help.


--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4503485.html
Sent from the Users forum mailing list archive at Nabble.com.

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


Re: inferring locale from URL in 1.5

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Check http://www.wicket-library.com/wicket-examples/mappers/ - LocaleFirstMapper

On Fri, Mar 23, 2012 at 2:04 AM, armhold <ar...@gmail.com> wrote:
> What's the cleanest way to set a user's locale based on the domainname of the
> URL of the request in 1.5?
>
> https://cwiki.apache.org/WICKET/wicket-and-localized-urls.html This guide
> relies on overriding newRequestCycleProcessor(). Would a proper 1.5 analog
> be to add a custom AbstractRequestCycleListener like this?
>
>                RequestCycleListenerCollection listeners = new
> RequestCycleListenerCollection();
>                application.getRequestCycleListeners().add(listeners);
>                listeners.add(new AbstractRequestCycleListener() {
>                        public void onBeginRequest(RequestCycle cycle) {
>                               Session.get().setLocale(...);
>                        }
>
>               });
>
> BTW, I've been asked to use the domainname for the locale (vs the
> context/servlet path), so my URLs will look like: fr.example.com/somepage.
>
> I'm planning to use (HttpServletRequest)
> getContainerRequest()).getServerName()) for this, unless there is something
> nicer.
>
> Thank you.
>
> --
> View this message in context: http://apache-wicket.1842946.n4.nabble.com/inferring-locale-from-URL-in-1-5-tp4497412p4497412.html
> Sent from the Users forum mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>



-- 
Martin Grigorov
jWeekend
Training, Consulting, Development
http://jWeekend.com

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