You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@myfaces.apache.org by Simon Lessard <si...@gmail.com> on 2007/08/06 15:20:13 UTC

Re: [Trinidad] setActionListener and resource bundle

Hello Luka,

This isn't really a Trinidad bug, but a f:loadBundle inconvenience.
f:loadBundle is executed only during the render response phase. Therefore,
there's no bundle yet during the invoke application phase in which the
setActionListener is called. There's two works around:


   1. Use JSF 1.2 which include a resource-bundle facility.
   2. Create yourself a Bean class that act as a resource bundle (you can
   look at f:loadBundle code in MyFaces to see how it's done) and have it
   accept basename property. After that, define yourself a managed bean for
   your resource bundles setting the basename with a managed property
   (depending on your implementation it will have a different scope, the one we
   use in our projects is application scoped and cache the bundles for various
   locales for example). That strategy has three advantages: You no longer need
   to use f:loadBundle, if the bundle change for a new file you only have one
   place to change it and finally it prevent your strange issue. Note that this
   strategy is pretty much what JSF 1.2's resource-bundle feature do.


Regards,

~ Simon

On 8/6/07, Luka Surija <lu...@iytim.hr> wrote:
>
> I've found some strange "feature" with tr:setActionListener.
>
> if I try this:
> <f:loadBundle basename="#{mypackage.resource}" var="msg" />
> <tr:setActionListener from="#{msg.someLabel}" to="MyManagedBean.label" />
>
> it doesn't work (it works but MyManagedBean.label is empty string), but
> if I put
>
> <tr:setActionListener from="someLabel" to="MyManagedBean.label" />
>
> then MyManagedBean.label is "someLabel".
>
> I think it is a bug, but I'm asking if is there any workaround for this
> problem??
>
> Regards,
> Luka
>
>
>