The problem is the initialization of the component.  The initial-value is
set at the time the component is initialized, not at the time the parameter
was passed in.  Thus,
the property "rateProp" will be set to 0 in this case since parameter "rate"
was not available.

What you can do instead is use a bean; such as follow:

<bean name="rateProp" class="IntBean">
   <set name="value" value="rate"/>
</bean>

IntBean has a simple getter and setter:

public class IntBean
{
    int _value;

    public void setValue(int value)..

    public int getValue();
}

To reference in your html or page use beans.rateProp.value



On 3/15/06, Mike Snare <[EMAIL PROTECTED]> wrote:
>
> I have a component with a parameter named rate and a session-scoped
> property named rateProp.  Both are to be ints.
>
> I have my rate parameter declared as follows:
> &lt;parameter name="rate" required="true" /&gt;
>
> I have the rateProp declared as follows:
>
> &lt;property name="rateProp" initial-value="rate" persist="session" /&gt;
>
> Note that I am trying to use the value of the rate parameter to
> initialize the rateProp property.
>
> I use the rateProp in the value binding of a form field (a
> PropertySelection) and as an input-symbol to a script included in the
> component.
>
> The problem is that the rateProp property does not get initialized
> with the value of the rate parameter as I would like.  So, when the
> component actually renders itself the value of the rateProp is the
> default int value of 0, not the 10 that I am passing in to the
> component from the page that includes the component.
>
> I could work around the problem by setting the initial value of the
> rateProp property to some invalid value (like -1) and then look for
> that in the pageAttached method -- resetting the rateProp to the value
> of rate as needed, but it seems like that shouldn't be necessary.
>
> After resetting the rateProp via the PropertySelection on the page it
> works fine.
>
> Any help would be appreciated.
>
> -Mike
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

Reply via email to