You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@shale.apache.org by Gary VanMatre <gv...@apache.org> on 2006/11/02 17:53:12 UTC
RE: Clay - how to set locale Parameter for f:view in html/xml views
>Still need to create the issue - but i've got an idea for a workaround.
>How about a viewhandler, which uses a custom session bean which holds
>the locale - and which return this one when "calculateLocale" is called?
>
>Something like this:
>
>public Locale calculateLocale(FacesContext facesContext) {
> LanguageBean neededBean
> = (LanguageBean) facesContext.getApplication()
> .getVariableResolver().resolveVariable(facesContext,
>"language");
> if(neededBean != null) {
> log.info("current locale -> " + neededBean.getCurrentLanguage());
> return neededBean.getCurrentLocale();
> }
> log.info("current locale -> " + base.calculateLocale(facesContext));
> ; ; return base.calculateLocale(facesContext);
> }
>
>Any drawbacks of this workaround?
>
I don't see a reason why this solution wouldn't work but I really think that
the locale should be defined per page. To make this work, the locale would
have to be applied to the view root before rendering.
I was thinking about a new category of Clay component definitions. A
"action" type that would let you invoke method binding expressions. Before
the sub component tree was built by the Clay component, it would walk thru
the graph of config beans and invoke any "action" types. The action types
would be ignored otherwise. Maybe we could extend the clay metadata adding
method binding info so that all components could have it.
Maybe something like this:
<component jsfid="myField" extends="h:outputText" >
<actions>
<method-expression value="#{@managed-bean-name.viewSetup}"
formalParameter="void
(javax.faces.component.UIViewRoot) "
actualParameter="#{facesContext.view}"
/>
--- or --
<method-expression value="#{@managed-bean-name.prerender}"
formalParameter="void
(javax.faces.component.UIViewRoot,
org.apache.shale.clay.config.beans.ComponentBean) "
actualParameter="#{facesContext.view},
#{this}" />
</actions>
What do you think?
>Torsten
Gary