--- Begin Message ---
Hi Magodlna,
 
Many thanks for the information.
I will implement this right away.
 
regards,
Anshuman

________________________________

From: magdolna holitska [mailto:[EMAIL PROTECTED]
Sent: Wed 1/31/2007 3:56 AM
To: [email protected]
Subject: RE: Custom messages for converters



Hi Anshuman,

You could just try something like:
<tr:inputText label="test" converter="myCustomDateTimeConverter"/>

As the message is set in the converter you could use if-else logic or
something similar to set different messages. Note that you don't have to
hard code the actual messages, you can still store them externally in a
properties file - same for the pattern.

Regards,
Magdolna





>From: "Anshuman Abhishek Roy" <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: <[email protected]>
>Subject: RE: Custom messages for converters
>Date: Fri, 26 Jan 2007 19:54:05 +0530
>
Nice suggestion Matthias.

But then how do we configure this new datetime converter class in your faces
application.

is it via using something like this:
<converter>

<converter-id>javax.faces.DateTime</converter-id>

<converter-class>test.converter.CustomDateTimeConverter</converter-class>

</converter>


in the faces-config.xml?

One more thing this will lead to the problem of what if I want to display
different messages in different places for the same <tr:convertDatetime>?

Can it be done programatically by catching hold of the UIXComponent and then
setXXX() methods on to the UIXComponent?

regards,
Anshuman

________________________________

From: [EMAIL PROTECTED] on behalf of Matthias Wessendorf
Sent: Fri 1/26/2007 12:48 PM
To: [email protected]
Subject: Re: Custom messages for converters



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 <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]>
> >Reply-To: [email protected]
> >To: [email protected]
> >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" <[EMAIL PROTECTED]>
> >>Reply-To: [email protected]
> >>To: [email protected]
> >>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 <[EMAIL PROTECTED]> 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" <[EMAIL PROTECTED]>
> >>> >Reply-To: [email protected]
> >>> >To: [email protected]
> >>> >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 <[EMAIL PROTECTED]> wrote:
> >>> >>On 1/24/07, magdolna holitska <[EMAIL PROTECTED]> 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

_________________________________________________________________
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



<<winmail.dat>>


--- End Message ---
Disclaimer

This email and any files transmitted with it are confidential and intended 
solely for the use of the individual or entity to whom it is addressed.  If you 
have received this communication in error, please immediately notify the [EMAIL 
PROTECTED] and destroy the original message. The recipient should check this 
email and any attachments for the presence of viruses.  Ness has taken every 
reasonable precaution to minimize this risk, and accepts no liability for any 
damage caused by any virus transmitted in this email.  Ness reserves the rights 
to monitor and review the content of all messages sent to or from this E-mail 
address, and store them on the Ness E-mail system.

Reply via email to