On Wed, 30 Jul 2014 10:42:39 -0300, Stephan Windmüller
<stephan.windmuel...@tu-dortmund.de> wrote:
Injecting the service in onActivate and setting the value does not
work.
Define "does not work". Did you debug your binding factory?
Yes, and it seems that "newBinding" is only called once for each
location and the value is cached. But more importantly, newBinding is
called _before_ the onActivate method is evaluated.
In other words: It seems that it is not possible to change evaluated
value from onActivate.
We can prevent that. Look at the Binding interface: it has this method:
/**
* Returns true if the value of the binding does not ever change.
Components will often cache such values
* aggressively.
*/
boolean isInvariant();
Then at AbstractBinding:
/**
* Returns true. Subclasses that do not supply a fixed, read-only
value should override this method to return
* false.
*/
public boolean isInvariant()
{
return true;
}
So, if you don't override this method, AbstractBinding subclasses are
invariant and values get cached for performance.
Create a VariantLiteralBinding subclass that overrides isInvariant() to
return false, use instead of LiteralBinding and I guess it'll work.
--
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org