incubator-adffaces-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthias Wessendorf" <mat...@apache.org>
Subject Re: Custom messages for converters
Date Fri, 26 Jan 2007 07:18:35 GMT
well, at least you can create a custom converter, which isn't really to much :)

You also could extend the standard datetimeconverter and override the
getAsXxx and catch the exceptions, to throw your own.

-M

On 1/25/07, magdolna holitska <mholitska3@hotmail.com> wrote:
> Hi,
>
> I just would like to share my findings, after upgrading to the latest
> version of Trinidad:
>
> 1. -- Overriding
> org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_BOTH and
> org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_BOTH_detail
> did not work
>
> 2. -- messageDetailConvertBoth works, as long as you don's set the pattern
> As I understood this is intentional, to only allow customization of the
> message if the pattern is not set (I don't know why)
>
> 3. -- for achieving both customize message and also set the pattern, I ended
> up writing my own converter. It's really easy, I just extended
> javax.faces.convert.Converter and set the pattern and the error message to
> whatever I needed. I'm not sure if that's the best way to do it, but I
> didn't find a nicer way so far.
>
> Regards,
> Magdolna
>
>
>
>
>
>
> >From: "magdolna holitska" <mholitska3@hotmail.com>
> >Reply-To: adffaces-user@incubator.apache.org
> >To: adffaces-user@incubator.apache.org
> >Subject: Re: Custom messages for converters
> >Date: Wed, 24 Jan 2007 14:32:35 -0500
> >
> >Hi Matthias,
> >
> >Thank you for pointing that out to update to a newer version of Trinidad, I
> >will follow your advice.
> >
> >Also, I tried to override CONVERT_BOTH_detail, but no luck yet.
> >I will try again after I switch to the new version.
> >
> >However, the description in the messageDetailConvertBoth attribute really
> >caught my eye:
> >"... if pattern is not set or is null".
> >To me this sounds like if the pattern is set and not null, the message
> >customization is ignored.
> >Just something I felt that I should point out.
> >
> >Thank you for all your help,
> >Magdolna
> >
> >
> >
> >
> >
> >>From: "Matthias Wessendorf" <matzew@apache.org>
> >>Reply-To: adffaces-user@incubator.apache.org
> >>To: adffaces-user@incubator.apache.org
> >>Subject: Re: Custom messages for converters
> >>Date: Wed, 24 Jan 2007 15:17:49 +0100
> >>
> >><tr:inputText label="test">
> >>  <tr:convertDateTime
> >>   type="both"
> >>   messageDetailConvertBoth="Well,the value ({1}) is not really in a
> >>propper format, like {2}"
> >>  />
> >></tr:inputText>
> >>
> >>works for me w/ latest trinidad (check the trunk)
> >>
> >>the messageDetailConvertBoth works, only when type is both and pattern not
> >>set
> >>(means don't provide the pattern attr)
> >>
> >>have u tried to override
> >>
> >>org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_BOTH_detail
> >>
> >>?
> >>
> >>
> >>regarding "convertBothMessageDetail" we changed them during october 2006
> >>(tracked in Jira)
> >>
> >>-M
> >>
> >>On 1/24/07, magdolna holitska <mholitska3@hotmail.com> wrote:
> >>>Hello Matthias,
> >>>
> >>>Thank you so much for responding.
> >>>
> >>>In the Trinidad documentation and demo source I have seen the attribute
> >>>messageDetailConvertBoth, but interestingly, it didn't seem to do
> >>>anything
> >>>for me ...
> >>>
> >>>However, convertBothMessageDetail (found in adf documentation) did work:
> >>>         <tr:inputText id="firstDate">
> >>>             <tr:convertDateTime type="both"
> >>>convertBothMessageDetail="Well,
> >>>the value ({1}) is not really in a propper format, like {2}"/>
> >>>         </tr:inputText>
> >>>
> >>>The problem is, that if I add the attribute pattern (pattern="MMM-dd-yyyy
> >>>HH:mm:ss") the custom message stops working.
> >>>
> >>>If you look at the trinidad api, they even specify in the description for
> >>>the attribute messageDetailConvertBoth:
> >>>"... when type is set to 'both' and pattern is not set or is null"
> >>>(http://incubator.apache.org/adffaces/trinidad-api/tagdoc/tr_convertDateTime.html)
> >>>
> >>>Is there a way to have both pattern as well as customized messages?
> >>>
> >>>Thank you,
> >>>Magdolna
> >>>
> >>>
> >>>
> >>>
> >>> >From: "Matthias Wessendorf" <matzew@apache.org>
> >>> >Reply-To: adffaces-user@incubator.apache.org
> >>> >To: adffaces-user@incubator.apache.org
> >>> >Subject: Re: Custom messages for converters
> >>> >Date: Wed, 24 Jan 2007 09:50:32 +0100
> >>> >
> >>> >note that the type is by default "date"
> >>> >
> >>> >you need to do something like
> >>> >
> >>> ><tr:convertDateTime type="both" messageDetailConvertBoth="Well, the
> >>> >value ({1}) is not really in a propper format, like {2}"/>
> >>> >
> >>> >
> >>> >
> >>> >
> >>> >On 1/24/07, Matthias Wessendorf <matzew@apache.org> wrote:
> >>> >>On 1/24/07, magdolna holitska <mholitska3@hotmail.com> wrote:
> >>> >> > Hi all,
> >>> >> >
> >>> >> > I have been trying, unsuccessfully to customize the error
messages
> >>> >>generated
> >>> >> > by a date/time converter (tr:convertDateTime).
> >>> >> >
> >>> >> > - I tried to add the message id to my resources file
> >>> >> >
> >>>(org.apache.myfaces.trinidad.convert.DateTimeConverter.CONVERT_BOTH)
> >>> >>
> >>> >>_detail
> >>> >>
> >>> >>
> >>> >> > - I tried to use the attribute convertBothMessageDetail
> >>> >>
> >>> >>attributes renamed to
> >>> >>
> >>> >>-messageDetailConvertBoth
> >>> >>-messageDetailConvertDate
> >>> >>-messageDetailConvertTime
> >>> >>
> >>> >>
> >>> >> > - I tried to create my own converter class by extending Trinidad
> >>> >>converter
> >>> >> > and use the setConvertBothMessageDetail method to set the
custom
> >>> >>message
> >>> >> >
> >>> >> > It appears that it only works if I don't set the pattern.
> >>> >> > As soon as I am setting the pattern I get a default validation
text
> >>> >>(The
> >>> >> > value "xxx" is not a valid date. Valid example: "Nov-29-2005
> >>> >>15:45:24".)
> >>> >> >
> >>> >> > Validator messages seem to be easily customizable, but not
> >>>converters.
> >>> >> > Could please someone point out what I am missing here?
> >>> >> >
> >>> >> > Thank you,
> >>> >> > Magdolna
> >>> >> >
> >>> >> > _________________________________________________________________
> >>> >> > Windows Live Spaces: share your New Year pictures!
> >>> >> > http://discoverspaces.live.com/?loc=en-CA
> >>> >> >
> >>> >> >
> >>> >>
> >>> >>
> >>> >>--
> >>> >>Matthias Wessendorf
> >>> >>http://tinyurl.com/fmywh
> >>> >>
> >>> >>further stuff:
> >>> >>blog: http://jroller.com/page/mwessendorf
> >>> >>mail: mwessendorf-at-gmail-dot-com
> >>> >>
> >>> >
> >>> >
> >>> >--
> >>> >Matthias Wessendorf
> >>> >http://tinyurl.com/fmywh
> >>> >
> >>> >further stuff:
> >>> >blog: http://jroller.com/page/mwessendorf
> >>> >mail: mwessendorf-at-gmail-dot-com
> >>>
> >>>_________________________________________________________________
> >>>Your Space. Your Friends. Your Stories. Share your world with Windows
> >>>Live
> >>>Spaces. http://discoverspaces.live.com/?loc=en-CA
> >>>
> >>>
> >>
> >>
> >>--
> >>Matthias Wessendorf
> >>http://tinyurl.com/fmywh
> >>
> >>further stuff:
> >>blog: http://jroller.com/page/mwessendorf
> >>mail: mwessendorf-at-gmail-dot-com
> >
> >_________________________________________________________________
> >Buy what you want when you want it on Sympatico / MSN Shopping
> >http://shopping.sympatico.msn.ca/content/shp/?ctId=2,ptnrid=176,ptnrdata=081805
> >
>
> _________________________________________________________________
> Free Alerts: Be smart - let your information find you!
> http://alerts.live.com/Alerts/Default.aspx
>
>


-- 
Matthias Wessendorf
http://tinyurl.com/fmywh

further stuff:
blog: http://jroller.com/page/mwessendorf
mail: mwessendorf-at-gmail-dot-com

Mime
View raw message