Hi Mic :) ,
I'm not sure if this is the reason ... but in the InitialValue documentation
is says :
"The initial value for the property as a binding reference that is evaluated
when the page is first constructed, and again every time the page is
detached and returned to the page pool."
So ... the first init may be called when the page is injected (if it is
constructed at that moment) and prop2 is null and then the second time is
when the page is detached and returned to the pool, at which time, the value
of the prop2 is "someValue".
Do you get the same behaviour with and without the chache enabled ?
Hope it helps,
Andrei Chiritescu
On 3/7/06, Mircea Militaru < [EMAIL PROTECTED]> wrote:
>
> Hi guys!
>
> I am having some problems setting page properties. Here is how our code
> looks like
>
> PageSource.java
> @InjectPage( "TargetPage" )
> public abstract BasePage getPageTarget();
>
> public void myListener( IRequestCycle cycle )
> {
> System.out.println( "before getPageTarget" );
> BasePage actionPage=getPageTarget();
> IComponent compAction=actionPage.getComponent( "TargetComponent"
> );
> PropertyUtils.write( compAction, "prop2", "someValue");
>
> System.out.println( "before activate page" );
> cycle.activate( actionPage );
> }
>
> TargetComponent.page
> ....
> <property name="prop1" initial-value="ognl:initProp1()"/>
> <property name="prop2"/>
> ....
>
> TargetComponent.java
> ...
> public void initProp1()
> {
> System.out.println ( "initProp1 with " + getProp2() );
> return getProp2();
> }
> ..
>
>
> Here is a what the logging looks like:
> ...
> before getPageTarget
> initProp1 with null
> before activate page
> initProp1 with someValue
> ...
>
> Why is the init function called twice and why does the rendered page
> have prop1=null and prop2=someValue ? I think it's a little strange
> because i would expect either both properties to be null or none of them.
>
> Thanks
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>