Re: T5: Domain level localization
Hi Kristian, This is a old post, i finally tried it out, it works, but how to check domain name? calling 'request' s method cause exceptions, example: System.out.println(request.getContextPath()); ERROR] RequestExceptionHandler Processing of request failed with uncaught exception: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException java.lang.RuntimeException: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException at org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:65) kristian.marinkovic wrote: you could create your own ThreadLocale object that has DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tp13032958p14391706.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Antwort: Re: T5: Domain level localization
can you show me how you define your DomainThreadLocale service in your module class? Angelo Chen [EMAIL PROTECTED] 18.12.2007 11:33 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Hi Kristian, This is a old post, i finally tried it out, it works, but how to check domain name? calling 'request' s method cause exceptions, example: System.out.println(request.getContextPath()); ERROR] RequestExceptionHandler Processing of request failed with uncaught exception: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException java.lang.RuntimeException: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException at org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:65) kristian.marinkovic wrote: you could create your own ThreadLocale object that has DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tp13032958p14391706.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Antwort: Re: T5: Domain level localization
ok... just tried it myself... i get the same exception if you move your method call to getLocale it works. the DomainThreadLocale service is realized by the IOC container long before tapestry core initializes its Request service (that itself depends on RequestGlobals) because it is needed in another service before. another option is to write a Dispatcher that reads the locale from the request and sets it in the ThreadLocale: public class LocaleDispatcher implements Dispatcher { private final ThreadLocale locale; public LocaleDispatcher (ThreadLocale locale) { this.locale=locale; } public boolean dispatch(Request request, Response response) throws IOException { locale.setLocale(request.getLocale()); return false; } } g, kris Kristian Marinkovic [EMAIL PROTECTED] 18.12.2007 12:13 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema Antwort: Re: T5: Domain level localization can you show me how you define your DomainThreadLocale service in your module class? Angelo Chen [EMAIL PROTECTED] 18.12.2007 11:33 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Hi Kristian, This is a old post, i finally tried it out, it works, but how to check domain name? calling 'request' s method cause exceptions, example: System.out.println(request.getContextPath()); ERROR] RequestExceptionHandler Processing of request failed with uncaught exception: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException java.lang.RuntimeException: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException at org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:65) kristian.marinkovic wrote: you could create your own ThreadLocale object that has DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tp13032958p14391706.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Antwort: Re: T5: Domain level localization
Hi Kristian, Thanks for the reply, my need is not to get the locale from the request but, I have two domain names, all will point to the same IP, one domain will have 'en' as locale while another one will have 'zh' as its locale, your solution works except I have to find out first the domain name before setting the locales. Thanks, A.C kristian.marinkovic wrote: ok... just tried it myself... i get the same exception if you move your method call to getLocale it works. another option is to write a Dispatcher that reads the locale from the request and sets it in the ThreadLocale: public class LocaleDispatcher implements Dispatcher { private final ThreadLocale locale; public LocaleDispatcher (ThreadLocale locale) { this.locale=locale; } public boolean dispatch(Request request, Response response) throws IOException { locale.setLocale(request.getLocale()); return false; } } g, kris Kristian Marinkovic [EMAIL PROTECTED] 18.12.2007 12:13 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema Antwort: Re: T5: Domain level localization can you show me how you define your DomainThreadLocale service in your module class? Angelo Chen [EMAIL PROTECTED] 18.12.2007 11:33 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Hi Kristian, This is a old post, i finally tried it out, it works, but how to check domain name? calling 'request' s method cause exceptions, example: System.out.println(request.getContextPath()); ERROR] RequestExceptionHandler Processing of request failed with uncaught exception: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException java.lang.RuntimeException: Error invoking constructor org.bfe.myapp.t5.DomainThreadLocale(Request) (at DomainThreadLocale.java:42) (for service 'domainThreadLocale'): java.lang.NullPointerException at org.apache.tapestry.ioc.internal.ConstructorServiceCreator.createObject(ConstructorServiceCreator.java:65) kristian.marinkovic wrote: you could create your own ThreadLocale object that has DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tp13032958p14391706.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tp13032958p14396833.html Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Domain level localization
Maybe a servlet filter? Jérôme. On 10/4/07, Angelo Chen [EMAIL PROTECTED] wrote: Hi, I'm not so sure if this Tapestry related, my T5 app can switch locales between English and Chinese using persistentLocaleService.set(Locale.SIMPLIFIED_CHINESE); Now I like the localization also in the domain level, let's say, I have two domains, namely mydomain.com and mydomain.com.cn, if user goes to mydomain.com it show the English locale, if he goes to mydomain.com.cn it will choose Chinese locale, it looks different sites but actually all goes to the same IP, possible? any tips on this, thanks. A.C. -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13032958 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jérôme BERNARD, Kalixia, SARL. http://weblog.kalixia.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Domain level localization
you could create your own ThreadLocale object that has the request object injected and contribute it to the alias service. i haven't tried it myself but it should look something like that: public static void bind(ServiceBinder binder) { binder.bind(ThreadLocale.class, DomainThreadLocale.class).scope( IOCConstants.PERTHREAD_SCOPE).withId(domainThreadLocale); ...} // create alias public static void contributeAliasOverrides( @InjectService(domainThreadLocale) ThreadLocale threadLocale, ConfigurationAliasContribution? configuration) { configuration.add( AliasContribution.create( ThreadLocale.class, threadLocale)); } DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } Jérôme BERNARD [EMAIL PROTECTED] 04.10.2007 10:30 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Maybe a servlet filter? Jérôme. On 10/4/07, Angelo Chen [EMAIL PROTECTED] wrote: Hi, I'm not so sure if this Tapestry related, my T5 app can switch locales between English and Chinese using persistentLocaleService.set(Locale.SIMPLIFIED_CHINESE); Now I like the localization also in the domain level, let's say, I have two domains, namely mydomain.com and mydomain.com.cn, if user goes to mydomain.com it show the English locale, if he goes to mydomain.com.cn it will choose Chinese locale, it looks different sites but actually all goes to the same IP, possible? any tips on this, thanks. A.C. -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13032958 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jérôme BERNARD, Kalixia, SARL. http://weblog.kalixia.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Domain level localization
Hi Jerome, Thanks, filter looks easier, you meant we will set the locales in the filter based on the domain then 'chain' to the T5 filter/servlet? but I seem not able to find a setLocale in the request? any hint? A.C. Jérôme BERNARD wrote: Maybe a servlet filter? Jérôme. On 10/4/07, Angelo Chen [EMAIL PROTECTED] wrote: -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13039794 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Domain level localization
Hi Kristian, Thanks for the reply, it's kind of difficult for a Tapestry newbie to understand that code, will try to research some more on the topic of alias first and come back later. A.C. kristian.marinkovic wrote: you could create your own ThreadLocale object that has the request object injected and contribute it to the alias service. i haven't tried it myself but it should look something like that: public static void bind(ServiceBinder binder) { binder.bind(ThreadLocale.class, DomainThreadLocale.class).scope( IOCConstants.PERTHREAD_SCOPE).withId(domainThreadLocale); ...} // create alias public static void contributeAliasOverrides( @InjectService(domainThreadLocale) ThreadLocale threadLocale, ConfigurationAliasContribution? configuration) { configuration.add( AliasContribution.create( ThreadLocale.class, threadLocale)); } DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } Jérôme BERNARD [EMAIL PROTECTED] 04.10.2007 10:30 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Maybe a servlet filter? Jérôme. On 10/4/07, Angelo Chen [EMAIL PROTECTED] wrote: Hi, I'm not so sure if this Tapestry related, my T5 app can switch locales between English and Chinese using persistentLocaleService.set(Locale.SIMPLIFIED_CHINESE); Now I like the localization also in the domain level, let's say, I have two domains, namely mydomain.com and mydomain.com.cn, if user goes to mydomain.com it show the English locale, if he goes to mydomain.com.cn it will choose Chinese locale, it looks different sites but actually all goes to the same IP, possible? any tips on this, thanks. A.C. -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13032958 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jérôme BERNARD, Kalixia, SARL. http://weblog.kalixia.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13039727 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Domain level localization
you have to put in all the methods into your AppModule class... they should work as is. die Alias Service is needed to replace an existing service with a new service that has the same interface. Tapestry has the ThreadLocale service that uses the ThreadLocaleImpl implementation. By contributing to the alias service we tell the tapestry ioc container to use your ThreadLocale implementation DomainThreadLocale wherever it is referenced/injected instead of its own. So whenever to inject the ThreadLocale you will get your implementation the ioc container will also inject dependencies that are referenced by the constructor of your ThreadLocale implementation automatically if you use the ServiceBinder hope this will give you a good start :) Angelo Chen [EMAIL PROTECTED] 04.10.2007 15:20 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Hi Kristian, Thanks for the reply, it's kind of difficult for a Tapestry newbie to understand that code, will try to research some more on the topic of alias first and come back later. A.C. kristian.marinkovic wrote: you could create your own ThreadLocale object that has the request object injected and contribute it to the alias service. i haven't tried it myself but it should look something like that: public static void bind(ServiceBinder binder) { binder.bind(ThreadLocale.class, DomainThreadLocale.class).scope( IOCConstants.PERTHREAD_SCOPE).withId(domainThreadLocale); ...} // create alias public static void contributeAliasOverrides( @InjectService(domainThreadLocale) ThreadLocale threadLocale, ConfigurationAliasContribution? configuration) { configuration.add( AliasContribution.create( ThreadLocale.class, threadLocale)); } DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } Jérôme BERNARD [EMAIL PROTECTED] 04.10.2007 10:30 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Maybe a servlet filter? Jérôme. On 10/4/07, Angelo Chen [EMAIL PROTECTED] wrote: Hi, I'm not so sure if this Tapestry related, my T5 app can switch locales between English and Chinese using persistentLocaleService.set(Locale.SIMPLIFIED_CHINESE); Now I like the localization also in the domain level, let's say, I have two domains, namely mydomain.com and mydomain.com.cn, if user goes to mydomain.com it show the English locale, if he goes to mydomain.com.cn it will choose Chinese locale, it looks different sites but actually all goes to the same IP, possible? any tips on this, thanks. A.C. -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13032958 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jérôme BERNARD, Kalixia, SARL. http://weblog.kalixia.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13039727 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: T5: Domain level localization
Hi Kristian, Thanks for the super fast reply, it's surprised me! alias service looks the T5 way to go for that, but kind of advanced topic, u did give me some directions, let me study those areas first before asking more questions. A.C. kristian.marinkovic wrote: you have to put in all the methods into your AppModule class... they should work as is. die Alias Service is needed to replace an existing service with a new service that has the same interface. Tapestry has the ThreadLocale service that uses the ThreadLocaleImpl implementation. By contributing to the alias service we tell the tapestry ioc container to use your ThreadLocale implementation DomainThreadLocale wherever it is referenced/injected instead of its own. So whenever to inject the ThreadLocale you will get your implementation the ioc container will also inject dependencies that are referenced by the constructor of your ThreadLocale implementation automatically if you use the ServiceBinder hope this will give you a good start :) Angelo Chen [EMAIL PROTECTED] 04.10.2007 15:20 Bitte antworten an Tapestry users users@tapestry.apache.org An users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Hi Kristian, Thanks for the reply, it's kind of difficult for a Tapestry newbie to understand that code, will try to research some more on the topic of alias first and come back later. A.C. kristian.marinkovic wrote: you could create your own ThreadLocale object that has the request object injected and contribute it to the alias service. i haven't tried it myself but it should look something like that: public static void bind(ServiceBinder binder) { binder.bind(ThreadLocale.class, DomainThreadLocale.class).scope( IOCConstants.PERTHREAD_SCOPE).withId(domainThreadLocale); ...} // create alias public static void contributeAliasOverrides( @InjectService(domainThreadLocale) ThreadLocale threadLocale, ConfigurationAliasContribution? configuration) { configuration.add( AliasContribution.create( ThreadLocale.class, threadLocale)); } DomainThreadLocale implements ThreadLocale { public DomainThreadLocale (Request request) { // check domain and set locale } } Jérôme BERNARD [EMAIL PROTECTED] 04.10.2007 10:30 Bitte antworten an Tapestry users users@tapestry.apache.org An Tapestry users users@tapestry.apache.org Kopie Thema Re: T5: Domain level localization Maybe a servlet filter? Jérôme. On 10/4/07, Angelo Chen [EMAIL PROTECTED] wrote: Hi, I'm not so sure if this Tapestry related, my T5 app can switch locales between English and Chinese using persistentLocaleService.set(Locale.SIMPLIFIED_CHINESE); Now I like the localization also in the domain level, let's say, I have two domains, namely mydomain.com and mydomain.com.cn, if user goes to mydomain.com it show the English locale, if he goes to mydomain.com.cn it will choose Chinese locale, it looks different sites but actually all goes to the same IP, possible? any tips on this, thanks. A.C. -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13032958 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- Jérôme BERNARD, Kalixia, SARL. http://weblog.kalixia.com - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13039727 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13040108 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
T5: Domain level localization
Hi, I'm not so sure if this Tapestry related, my T5 app can switch locales between English and Chinese using persistentLocaleService.set(Locale.SIMPLIFIED_CHINESE); Now I like the localization also in the domain level, let's say, I have two domains, namely mydomain.com and mydomain.com.cn, if user goes to mydomain.com it show the English locale, if he goes to mydomain.com.cn it will choose Chinese locale, it looks different sites but actually all goes to the same IP, possible? any tips on this, thanks. A.C. -- View this message in context: http://www.nabble.com/T5%3A-Domain-level-localization-tf4565942.html#a13032958 Sent from the Tapestry - User mailing list archive at Nabble.com. - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]