You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Geoffrey Wiseman <ge...@gmail.com> on 2009/07/24 22:27:24 UTC

Accessing Tapestry's Enum Translation

Tapestry's already got a mechanism for translating an enum (e.g. LAST_NAME)
to a human-readable value (e.g. Last Name) which can also be overridden in
the properties.  Is there an easy way to get access to that in order to
reuse it in validation messages?  Seems silly to do this another way when
there's a perfectly good UI model for this already.
  I could inject the Select, but that won't give me access to the
SelectModel.  I guess I could construct the EnumSelectModel instance
myself using injected messages and my own knowledge of the enum class?
>From there I could run through the OptionModel instances, compare the vaules
and get the label.  It's a little painful, but looks workable.

Is there an easier path someone's found?

  - Geoffrey
-- 
Geoffrey Wiseman
http://www.geoffreywiseman.ca/

Re: Accessing Tapestry's Enum Translation

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Fri, 24 Jul 2009 17:27:24 -0300, Geoffrey Wiseman  
<ge...@gmail.com> escreveu:

> Is there an easier path someone's found?

Taking a look at EnumSelectModel, I've found that it uses  
TapestryInternalUtils.getLabelForEnum(messages, prefix, value). to get the  
label. The only downside is that it is internal, so no backward  
compatibilities are made about it. Use at your own risk. :)

-- 
Thiago H. de Paula Figueiredo
Independent Java consultant, developer, and instructor
http://www.arsmachina.com.br/thiago

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org