|
Hi, is there a way in Tapestry to set global date formats? As it is now we specify the date format inside the tag like this: It would be much easier and less error prone if we could specify the format as a global setting. Thanks, Özkan |
|
I can't see the usage example you are referring too. Have you tried using
the global *app.properties* file ? I reckon it's named after your module name so if your module class is *MyAppModule.java*, your application catalog filename should be *myapp.properties* (Case insensitive I think) In that file you can store your format and refer to it through ${message:your.date-format} Unless you are trying to use a default date format without even specifying the *format* attribute as in the DateField<http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/DateField.html> component (The only example I can think of since you didn't specify which component is asking you for a date format), well I don't know how to do that since that attribute is required ! On Wed, Sep 5, 2012 at 9:26 AM, ZKN __ <[hidden email]> wrote: > > Hi, > is there a way in Tapestry to set global date formats? As it is now we > specify the date format inside the tag like this: > > It would be much easier and less error prone if we could specify the > format as a global setting. > Thanks, > Özkan |
|
In reply to this post by ZKN __
Unfortunately, nabble seems to have removed your example so I can't see it. I'm assuming that your post is related to DateField.
You could use a similar technique to taha's example [1] and add a custom mixin to all DateField components using a ComponentClassTransformWorker2. [1] http://tawus.wordpress.com/2011/08/01/tapestry-mixins-classtransformations/ |
|
In reply to this post by ZKN __
Hi Muhammad, thanks for the quick response. Yes, I'm referring to the the DateField component and was trying to achieve that without specifying the format attribute. It seems to be working without it even though it is required. What I want is to be sure that everywhere a date input fields is used or a date is output as text the same date format is used without setting any attributes. Regards, Özkan -------- Оригинално писмо -------- От: Muhammad Gelbana [hidden email] Относно: Re: Global setting for date format До: Tapestry users Изпратено на: Сряда, 2012, Септември 5 10:40:26 EEST I can't see the usage example you are referring too. Have you tried using the global *app.properties* file ? I reckon it's named after your module name so if your module class is *MyAppModule.java*, your application catalog filename should be *myapp.properties* (Case insensitive I think) In that file you can store your format and refer to it through ${message:your.date-format} Unless you are trying to use a default date format without even specifying the *format* attribute as in the DateField " target="_blank">http://tapestry.apache.org/current/apidocs/org/apache/tapestry5/corelib/components/DateField.html> component (The only example I can think of since you didn't specify which component is asking you for a date format), well I don't know how to do that since that attribute is required ! On Wed, Sep 5, 2012 at 9:26 AM, ZKN __ [hidden email] > wrote: > > Hi, > is there a way in Tapestry to set global date formats? As it is now we > specify the date format inside the tag like this: > > It would be much easier and less error prone if we could specify the > format as a global setting. > Thanks, > Özkan |
|
In reply to this post by ZKN __
Hi Lance, I was refering to DateField but I wanted the same thing applied everywhere even when I just output a text. I just want to be sure that someone did not forget to put a specific attribute somwhere in the code. -------- Оригинално писмо -------- От: Lance Java [hidden email] Относно: Re: Global setting for date format До: [hidden email] Изпратено на: Сряда, 2012, Септември 5 10:43:45 EEST Unfortunately, nabble seems to have removed your example so I can't see it. I'm assuming that your post is related to DateField. You could use a similar technique to taha's example [1] and add a custom mixin to all DateField components using a ComponentClassTransformWorker2. [1] http://tawus.wordpress.com/2011/08/01/tapestry-mixins-classtransformations/ -- View this message in context: http://tapestry.1045711.n5.nabble.com/Global-setting-for-date-format-tp5716054p5716056.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
> Hi Lance,
Hi > I was refering to DateField but I wanted the same thing applied everywhere ComponentClassTransformWorker2 will do this > even when I just output a text. I don't understand this I just want to be sure that someone did not forget to put a specific attribute somwhere in the code. > No, datefield will default to DateFormat.SHORT for the locale of the user unless a specific "format" parameter is provided. |
|
In reply to this post by ZKN __
For example in beandisplay component. Displaying all date fields for an object in the same default date format. -------- Оригинално писмо -------- От: Lance Java [hidden email] Относно: Re: Global setting for date format До: [hidden email] Изпратено на: Сряда, 2012, Септември 5 13:28:05 EEST > Hi Lance, Hi > I was refering to DateField but I wanted the same thing applied everywhere ComponentClassTransformWorker2 will do this > even when I just output a text. I don't understand this I just want to be sure that someone did not forget to put a specific attribute somwhere in the code. > No, datefield will default to DateFormat.SHORT for the locale of the user > unless a specific "format" parameter is provided. -- View this message in context: http://tapestry.1045711.n5.nabble.com/Global-setting-for-date-format-tp5716054p5716061.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
You should be able to do this with a mixin but you cannot for the same reason I'm having trouble with submitLabel in BeanEditForm.
see: http://tapestry.1045711.n5.nabble.com/Can-t-change-BeanEditForm-submitLabel-with-a-mixin-td5716012.html If the Parameter is defaulted to a readonly value you can't easily create a global default. This is unfortunate and I'm going to experiment with fixing this. I'm certain that ParameterWorker can be overridden with one that ignores defaults but that may be a bit drastic. |
|
In reply to this post by ZKN __
> For example in beandisplay component
You will need to contribute a BeanBlockContribution to BeanBlockOverrideSource. This will require you to create a page which contains the block that you would like to use instead (the override). eg: MyPage.java @Environmental @Property private PropertyOutputContext context; MyPage.tml <t:block id="myDate"> <t:output value="context.propertyValue" format="dd/MM/yyyy"/> </t:block> AppModule.java public static void contributeBeanBlockOverrideSource(Configuration<BeanBlockContribution> configuration { configuration.add(new DisplayBlockContribution(DataTypeConstants.DATE, "MyPage", "myDate")); } |
|
In reply to this post by ZKN __
That's what I was trying to avoid - find different solutions for each case. Cause I might even just do ${myDateField} and I would expect it to be formatted as I need. Since the project is already deployed I don't want to go through each case and occurrence to check if it is using valid format. I was looking for a quick/smart fix. Anyway that doesn't seem possible at least not now. Thanks for helping. -------- Оригинално писмо -------- От: Lance Java [hidden email] Относно: Re: Global setting for date format До: [hidden email] Изпратено на: Сряда, 2012, Септември 5 17:45:13 EEST > For example in beandisplay component You will need to contribute a BeanBlockContribution to BeanBlockOverrideSource. This will require you to create a page which contains the block that you would like to use instead (the override). eg: MyPage.java @Environmental @Property private PropertyOutputContext context; MyPage.tml AppModule.java public static void contributeBeanBlockOverrideSource(Configuration configuration { configuration.add(new DisplayBlockContribution(DataTypeConstants.DATE, "MyPage", "myDate")); } -- View this message in context: http://tapestry.1045711.n5.nabble.com/Global-setting-for-date-format-tp5716054p5716065.html Sent from the Tapestry - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [hidden email] For additional commands, e-mail: [hidden email] |
|
I agree with you that this is difficult to override. It would be nice if there was an overridable service to provide default formats instead of the current hard-coded DateFormat.SHORT.
|
| Powered by Nabble | Edit this page |
