List Info

Thread: RE: TagHandlers, Compiletime/Rendertime and State of ValueExpressions




RE: TagHandlers, Compiletime/Rendertime and State of ValueExpressions
user name
2007-10-11 07:16:34
I was not able to reproduce this problem using Facelets
1.1.11 and Sun RI 1.2_04-b10.  Which versions of the
software are you using?

Ray


-----Original Message-----
From: Denny Strietzbaum [mailto:mailinglistsfluxmux.de]
Sent: Thursday, October 11, 2007 03:30
To: usersfacelets.dev.java.net
Subject: TagHandlers, Compiletime/Rendertime and State of
ValueExpressions



Hi,

i've come to an issue which can be shortened to the example
below:

1)
A Taghandler which does nothing more than setting a variable
"myVar"
with a random value:
public void apply(FaceletContext faceletcontext, UIComponent
uicomponent)
			throws IOException, FacesException, FaceletException,
ELException {

	faceletcontext.setAttribute("myVar",
String.valueOf(Math.random()));
}

2)
A xhtml which displays this Variable.
<h:form>
<xy:myTag />	
<h:outputText value="#"/>	
<h:commandLink value="post"/>
<h:form>

What happens is that with every post the outputtext
component displays  
always
the same value (the firstly created random)

My first thought: the reason is that a TagHandler only is
valid during  
tree creation.
Doing a post to the same view requests the previously
created tree which  
means the
TagHandler won't be called again.
But something is wrong with my understanding of compiletime
and rendertime  
because the
TagHandler gets called everytime regardless of a post to the
same view or  
requesting a new view.

Having a closer look at the sources i can summarize this to
the following:
"#" is a com.sun.el.ValueExpressionImpl
which holds the  
ValueExpresion "myVar".
Additionally a VariableMapper is set which maps as
key<->value the  
myVar<->theRandomValue.
The VariableMapper is only used when pushing a Variable into
the context  
via faceletcontext.setAttribute(...)
I've found no other cases when the VariableMapper was set.

And now: ValueExpressionImpl externalizes the
VariableMapper.

This means the component which holds the valueexpression
"#" always  
associates this binding
with the first resolved value and never resolves that
ValueBinding again.


Is this a desired behaviour?
The problem simply is that my TagHandler prepares a value
which changes  
dynamically.
But my components never work with other values than the
initial one  
although the TagHandler
pushes the right value with every request into the context.

Does anybody have had the same problem and knows a
workaround?
(Or: is it really neccessary that the VariableMapper must be
externalized?)

thanks
Denny

------------------------------------------------------------
---------
To unsubscribe, e-mail: users-unsubscribefacelets.dev.java.net
For additional commands, e-mail: users-helpfacelets.dev.java.net

------------------------------------------------------------
---------
To unsubscribe, e-mail: users-unsubscribefacelets.dev.java.net
For additional commands, e-mail: users-helpfacelets.dev.java.net


Re: TagHandlers, Compiletime/Rendertime and State of ValueExpressions
user name
2007-10-11 08:47:54
I'm using facelets 1.1.4 and myfaces 1.1.5.
Unfortunately i can't switch to myfaces 1.2 at this time
because
there're currently some problems with tomcat an EL
functions.
(this issue was already detected by another one:
https://facelets.dev.java.net/servlets/R
eadMsg?list=users&msgNo=8167)

Denny

On Thu, 11 Oct 2007 14:16:34 +0200, Raymond K. DeCampo  
<rkdecampopromergent.com> wrote:

> I was not able to reproduce this problem using Facelets
1.1.11 and Sun  
> RI 1.2_04-b10.  Which versions of the software are you
using?
>
> Ray
>
>
> -----Original Message-----
> From: Denny Strietzbaum [mailto:mailinglistsfluxmux.de]
> Sent: Thursday, October 11, 2007 03:30
> To: usersfacelets.dev.java.net
> Subject: TagHandlers, Compiletime/Rendertime and State
of
> ValueExpressions
>
>
>
> Hi,
>
> i've come to an issue which can be shortened to the
example below:
>
> 1)
> A Taghandler which does nothing more than setting a
variable "myVar"
> with a random value:
> public void apply(FaceletContext faceletcontext,
UIComponent uicomponent)
> 			throws IOException, FacesException,
FaceletException, ELException {
>
> 	faceletcontext.setAttribute("myVar",
String.valueOf(Math.random()));
> }
>
> 2)
> A xhtml which displays this Variable.
> <h:form>
> <xy:myTag />	
> <h:outputText value="#"/>	
> <h:commandLink value="post"/>
> <h:form>
>
> What happens is that with every post the outputtext
component displays
> always
> the same value (the firstly created random)
>
> My first thought: the reason is that a TagHandler only
is valid during
> tree creation.
> Doing a post to the same view requests the previously
created tree which
> means the
> TagHandler won't be called again.
> But something is wrong with my understanding of
compiletime and  
> rendertime
> because the
> TagHandler gets called everytime regardless of a post
to the same view or
> requesting a new view.
>
> Having a closer look at the sources i can summarize
this to the  
> following:
> "#" is a
com.sun.el.ValueExpressionImpl which holds the
> ValueExpresion "myVar".
> Additionally a VariableMapper is set which maps as
key<->value the
> myVar<->theRandomValue.
> The VariableMapper is only used when pushing a Variable
into the context
> via faceletcontext.setAttribute(...)
> I've found no other cases when the VariableMapper was
set.
>
> And now: ValueExpressionImpl externalizes the
VariableMapper.
>
> This means the component which holds the
valueexpression "#"  
> always
> associates this binding
> with the first resolved value and never resolves that
ValueBinding again.
>
>
> Is this a desired behaviour?
> The problem simply is that my TagHandler prepares a
value which changes
> dynamically.
> But my components never work with other values than the
initial one
> although the TagHandler
> pushes the right value with every request into the
context.
>
> Does anybody have had the same problem and knows a
workaround?
> (Or: is it really neccessary that the VariableMapper
must be  
> externalized?)
>
> thanks
> Denny
>

------------------------------------------------------------
---------
To unsubscribe, e-mail: users-unsubscribefacelets.dev.java.net
For additional commands, e-mail: users-helpfacelets.dev.java.net


[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )