You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by ZKN __ <zk...@abv.bg> on 2012/09/05 09:26:45 UTC

Global setting for date format

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 

Re: Global setting for date format

Posted by Muhammad Gelbana <m....@gmail.com>.
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 __ <zk...@abv.bg> 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

Re: Global setting for date format

Posted by Lance Java <la...@googlemail.com>.
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Global setting for date format

Posted by Lance Java <la...@googlemail.com>.
> 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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Global setting for date format

Posted by Lance Java <la...@googlemail.com>.
> 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"));
}



--
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: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: Global setting for date format

Posted by Lance Java <la...@googlemail.com>.
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.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Global-setting-for-date-format-tp5716054p5716067.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: Global setting for date format

Posted by trsvax <tr...@gmail.com>.
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.



--
View this message in context: http://tapestry.1045711.n5.nabble.com/Global-setting-for-date-format-tp5716054p5716064.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