If Weekday is an java 5 enumeration (the approach should be almost
the same if you just have an int) I have just created a converter
class.
that implements javax.faces.convert.Converter and
something like org.springframework.context.MessageSourceAware(MessageSource is a
Spring class that represents a Message Bundle, I'm sure there are others if you
aren't using Spring)
In the
public String getAsString(FacesContext context, UIComponent
component, Object value) throws ConverterException
method, you just look up the text string in the Message
Source using the toString value of the enumeration. Value would be
something like Weekdays.MONDAY.
getMessageSource().getMessage(value.toString(), null,
context.getViewRoot().getLocale());
The correct string will be displayed if you have an entry in your
resource bundle that looks like this
MONDAY = Monday
When you want to output this string you just do this in your
page.
<t:outputText converter="#{WeekDayDisplayConverter}"
value="#{bean.weekday}"/>
then everything should work. (See the MyFaces
documentation for registering your converter)
JB
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, September 06, 2006 7:36 AM
To: users@myfaces.apache.org
Subject: Nested EL _expression_
Hi,
I have to display
weekday name (Sunday, Monday etc.), given weekday number which is available
in bean.
Please help me how
to write EL _expression_ to get the weekday name from resource
bundle.
Any pointers in this
regard are also highly appreciated.
Thanks,
Kiran
The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain proprietary, confidential or privileged information. If you are not the intended recipient, you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately and destroy all copies of this message and any attachments. WARNING: Computer viruses can be transmitted via email. The recipient should check this email and any attachments for the presence of viruses. The company accepts no liability for any damage caused by any virus transmitted by this email. www.wipro.com |