You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Vernon <ve...@gatewaytech.com> on 2003/04/21 06:32:20 UTC

[Tiles] How the getDefinitionsFactoryKey method is called

Is the getDefinitionsFactoryKey of I18nFactorySet class called each time 
when a page is loaded?

I pick a easier way to achieve the goal: modifying the 
getDefinitionsFactoryKey method rather than writing a new factory. The 
method, however, doesn't seem to be called each time when a page is loaded. 
For my application, the locale needs to be checked every single page is 
loaded. The reason behind that is I follow the approach stated on 
http://developer.java.sun.com/developer/technicalArticles/Intl/MultilingualJSP/. 
 The locale on the first few pages is determined by the browser. Also, I 
want to keep my localization approach: using JSTL/resource Bundle, but not 
a page per locale as demonstrated in the Tiles documentation. Is a 
achievable goal with Tiles?

Thanks for your helps.

Vernon


On Thu, 17 Apr 2003 00:16:54 +0200, Cedric Dumoulin <ce...@apache.org> 
wrote:

>
> The factory doesn't check the local from the http request, but from an 
> attribute set by struts in the jsp context. So, if you don't use struts, 
> you need to set this attribute yourself :-(. A solution is to extends the 
> default factory (I18nFactorySet) to change the 
> getDefinitionsFactoryKey(...) method.
> See http://www.lifl.fr/~dumoulin/howto/writeAFactory.doc for details 
> about writing a factory.
>
> Hope this help,
>
> Cedric
>
> Vernon wrote:
>
>> I just move an Java web application to Tiles from another template tags 
>> (not the Struts'). The page layout is defined in a XML file. The 
>> application is internationalized using the JSTL fmt tag, and it doesn't 
>> employ Struts. The localization is not working properly in the current 
>> setting.
>>
>> To resolve the issue, I create another one named tiles-def_es.xml since 
>> I already have a layout definition XML file called tiles-def.xml. The 
>> locale region files are invoked in the tile-defs_es.xml. I also create a 
>> new set of JSP files with the locale and replace all fmt with the locale 
>> content. It seems the locale factory is not invoked after a user changes 
>> his/her locale. The locale in the application is defined using 
>> Config.set of jstl. To my reading, the Tiles locale works in the same 
>> fashion as the Java property file. Can someone tell me why it doesn't 
>> work for Tiles, but for Java property files?
>>
>>
>> Thanks for your help.
>>
>>
>> Vernon
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



-- 
Vernon

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [Tiles] How the getDefinitionsFactoryKey method is called

Posted by Vernon <ve...@gatewaytech.com>.
Hi, Cedric,

> The method is called each time a Tiles definition is inserted. Do you 
> have instruct Tiles to use your extended factory instead of the default 
> one ?
>
I have modified the method to fit in the application, but not create 
another factory. It works as what it intends, that I have mentioned in my 
another email.

Before the user preferred locale can be retrived, the locale is the one at 
browser's acception-language. Otherwise, the user's preferred locale.

>> For my application, the locale needs to be checked every single page is 
>> loaded. The reason behind that is I follow the approach stated on 
>> http://developer.java.sun.com/developer/technicalArticles/Intl/MultilingualJSP/. 
>>
>>
>>
>> The locale on the first few pages is determined by the browser. Also, I 
>> want to keep my localization approach: using JSTL/resource Bundle, but 
>> not a page per locale as demonstrated in the Tiles documentation. Is a 
>> achievable goal with Tiles?
>
> Absolutely. You can mix both approach if you want, or use the one you 
> want.
>
> Cedric
>

So far, it DOESN'T work with the resource bunlde  approach. A scenario is 
that a locale page is kept in the session no matter the incoming request's 
locale. Say, one of two users with two different locale visits a page. The 
other user visits the same page afterward. What the second user gets is not 
a page with his/her preferred locale, but the first one's. I thought this 
problem could be resolved by specifying the definiton scope (insert tag 
scope can't be set with XML defintion). I have no any luck with it.

It would be very helpful if you can enlighten me other than a simple 
statement. I have read thorough all available on-line document and haven't 
find any helpful information.

Keep or toss Tiles is my current mind state after near one month long 
experience with it.

Thanks for your helps.

Vernon
>>
>>
>> Thanks for your helps.
>>
>> Vernon
>>
>>
>> On Thu, 17 Apr 2003 00:16:54 +0200, Cedric Dumoulin <ce...@apache.org> 
>> wrote:
>>
>>>
>>> The factory doesn't check the local from the http request, but from an 
>>> attribute set by struts in the jsp context. So, if you don't use 
>>> struts, you need to set this attribute yourself :-(. A solution is to 
>>> extends the default factory (I18nFactorySet) to change the 
>>> getDefinitionsFactoryKey(...) method.
>>> See http://www.lifl.fr/~dumoulin/howto/writeAFactory.doc for details 
>>> about writing a factory.
>>>
>>> Hope this help,
>>>
>>> Cedric
>>>
>>> Vernon wrote:
>>>
>>>> I just move an Java web application to Tiles from another template 
>>>> tags (not the Struts'). The page layout is defined in a XML file. The 
>>>> application is internationalized using the JSTL fmt tag, and it 
>>>> doesn't employ Struts. The localization is not working properly in the 
>>>> current setting.
>>>>
>>>> To resolve the issue, I create another one named tiles-def_es.xml 
>>>> since I already have a layout definition XML file called tiles- 
>>>> def.xml. The locale region files are invoked in the tile-defs_es.xml. 
>>>> I also create a new set of JSP files with the locale and replace all 
>>>> fmt with the locale content. It seems the locale factory is not 
>>>> invoked after a user changes his/her locale. The locale in the 
>>>> application is defined using Config.set of jstl. To my reading, the 
>>>> Tiles locale works in the same fashion as the Java property file. Can 
>>>> someone tell me why it doesn't work for Tiles, but for Java property 
>>>> files?
>>>>
>>>>
>>>> Thanks for your help.
>>>>
>>>>
>>>> Vernon
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>>
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
>



-- 
Vernon

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [Tiles] How the getDefinitionsFactoryKey method is called

Posted by Cedric Dumoulin <ce...@apache.org>.

Vernon wrote:

>
> Is the getDefinitionsFactoryKey of I18nFactorySet class called each 
> time when a page is loaded?
>
> I pick a easier way to achieve the goal: modifying the 
> getDefinitionsFactoryKey method rather than writing a new factory. The 
> method, however, doesn't seem to be called each time when a page is 
> loaded. 

  The method is called each time a Tiles definition is inserted. Do you 
have instruct Tiles to use your extended factory instead of the default 
one ?

> For my application, the locale needs to be checked every single page 
> is loaded. The reason behind that is I follow the approach stated on 
> http://developer.java.sun.com/developer/technicalArticles/Intl/MultilingualJSP/. 
> The locale on the first few pages is determined by the browser. Also, 
> I want to keep my localization approach: using JSTL/resource Bundle, 
> but not a page per locale as demonstrated in the Tiles documentation. 
> Is a achievable goal with Tiles? 

  Absolutely. You can mix both approach if you want, or use the one you 
want.

   Cedric

>
>
> Thanks for your helps.
>
> Vernon
>
>
> On Thu, 17 Apr 2003 00:16:54 +0200, Cedric Dumoulin 
> <ce...@apache.org> wrote:
>
>>
>> The factory doesn't check the local from the http request, but from 
>> an attribute set by struts in the jsp context. So, if you don't use 
>> struts, you need to set this attribute yourself :-(. A solution is to 
>> extends the default factory (I18nFactorySet) to change the 
>> getDefinitionsFactoryKey(...) method.
>> See http://www.lifl.fr/~dumoulin/howto/writeAFactory.doc for details 
>> about writing a factory.
>>
>> Hope this help,
>>
>> Cedric
>>
>> Vernon wrote:
>>
>>> I just move an Java web application to Tiles from another template 
>>> tags (not the Struts'). The page layout is defined in a XML file. 
>>> The application is internationalized using the JSTL fmt tag, and it 
>>> doesn't employ Struts. The localization is not working properly in 
>>> the current setting.
>>>
>>> To resolve the issue, I create another one named tiles-def_es.xml 
>>> since I already have a layout definition XML file called 
>>> tiles-def.xml. The locale region files are invoked in the 
>>> tile-defs_es.xml. I also create a new set of JSP files with the 
>>> locale and replace all fmt with the locale content. It seems the 
>>> locale factory is not invoked after a user changes his/her locale. 
>>> The locale in the application is defined using Config.set of jstl. 
>>> To my reading, the Tiles locale works in the same fashion as the 
>>> Java property file. Can someone tell me why it doesn't work for 
>>> Tiles, but for Java property files?
>>>
>>>
>>> Thanks for your help.
>>>
>>>
>>> Vernon
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>>
>>
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] redundant code generation for setters/getters

Posted by Affan Qureshi <qu...@etilize.com>.
Your IDE might have some features for this. I use NetBeans and it has
Generate Getters/Setters option in tools context menu. Also it allows you to
generate properties when defining a class.

----- Original Message -----
From: <st...@daydream.stanford.edu>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, April 21, 2003 10:16 AM
Subject: [OT] redundant code generation for setters/getters


> Hi,
>
> I've had to make many web forms with many entries. Which means I had to
> make a bunch of accessors/mutators (setters/getters) for all the action
> classes.  That can be quite cumbersome, so I made my own tool using basic
> "cat" and "sed" in Unix.
>
> I list all the names of the methods in a file and it uses a template to
> generate the methods along with the comments. I do the same for the
> declarations using the same file. I then just paste in the output.
>
> Maybe others have better ways of doing this. If so, what do you use?
>
> If anyone is interested in the tool I'm developing, I'll post it on my
> website. For Win32 users, you'd need cygwin of course.
>
> Oscar
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: [OT] redundant code generation for setters/getters

Posted by James Mitchell <jm...@apache.org>.
I've done the same thing using simple JavaScript in a broswer.  Type your
fields and types in one textarea and hit 'go' and then cut and paste the
result from another textarea to your editor.  Simple stuff.


--
James Mitchell
Software Developer/Struts Evangelist
http://www.open-tools.org



----- Original Message -----
From: <st...@daydream.stanford.edu>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Monday, April 21, 2003 1:16 AM
Subject: [OT] redundant code generation for setters/getters


> Hi,
>
> I've had to make many web forms with many entries. Which means I had to
> make a bunch of accessors/mutators (setters/getters) for all the action
> classes.  That can be quite cumbersome, so I made my own tool using basic
> "cat" and "sed" in Unix.
>
> I list all the names of the methods in a file and it uses a template to
> generate the methods along with the comments. I do the same for the
> declarations using the same file. I then just paste in the output.
>
> Maybe others have better ways of doing this. If so, what do you use?
>
> If anyone is interested in the tool I'm developing, I'll post it on my
> website. For Win32 users, you'd need cygwin of course.
>
> Oscar
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


[OT] redundant code generation for setters/getters

Posted by st...@daydream.stanford.edu.
Hi,

I've had to make many web forms with many entries. Which means I had to
make a bunch of accessors/mutators (setters/getters) for all the action
classes.  That can be quite cumbersome, so I made my own tool using basic
"cat" and "sed" in Unix.

I list all the names of the methods in a file and it uses a template to
generate the methods along with the comments. I do the same for the
declarations using the same file. I then just paste in the output.

Maybe others have better ways of doing this. If so, what do you use?

If anyone is interested in the tool I'm developing, I'll post it on my
website. For Win32 users, you'd need cygwin of course.

Oscar




---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org