You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Chris Miles <ch...@chrismiles.org> on 2010/06/24 22:50:33 UTC

Passing parameters to getter methods?

Hi,

I want to call s:iterator and fetch a list by passing it an index. This list will be dynamically generated.

<s:iterator value="products[#index]" var="product" status="stat">

where I want getProducts(Integer index) to be called. 

Is this possible?

Thanks

Chris

Re: Passing parameters to getter methods?

Posted by Chris Miles <ch...@chrismiles.org>.
Hi thanks. Sorry. My iterator is actually nested within another iterator. It 
is fetching products based on the value of the index in the first loop.

Thanks. I will try that.

Chris

----- Original Message ----- 
From: "Greg Lindholm" <gr...@gmail.com>
To: "Struts Users Mailing List" <us...@struts.apache.org>
Sent: Friday, June 25, 2010 1:58 PM
Subject: Re: Passing parameters to getter methods?


> Well technically it's not a "getter" since it takes a parameter but
> that doesn't matter you can call any method on your action just using
> the full name and calling it like in java.
>
> <s:iterator value="getProducts(#index)" var="product" status="stat">
>
> Now I'm not sure what you are trying to do with the #index syntax
> since getProducts() will be called once and should return a Collection
> or Array, it is not called on each loop of the iterator.
>
> You may need a different form of the iterator tag.
> http://struts.apache.org/2.1.8.1/docs/iterator.html
>
>
>
> On Fri, Jun 25, 2010 at 4:25 AM, Alex Rodriguez Lopez
> <al...@flordeutopia.pt> wrote:
>> You can do this without parameters. Write a setter for this index 
>> property
>> (to save it), and then in the getter you grab the saved value.
>>
>>> Hi,
>>>
>>> I want to call s:iterator and fetch a list by passing it an index. This
>>> list will be dynamically generated.
>>>
>>> <s:iterator value="products[#index]" var="product" status="stat">
>>>
>>> where I want getProducts(Integer index) to be called.
>>>
>>> Is this possible?
>>>
>>> Thanks
>>>
>>> Chris
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Passing parameters to getter methods?

Posted by Greg Lindholm <gr...@gmail.com>.
Well technically it's not a "getter" since it takes a parameter but
that doesn't matter you can call any method on your action just using
the full name and calling it like in java.

<s:iterator value="getProducts(#index)" var="product" status="stat">

Now I'm not sure what you are trying to do with the #index syntax
since getProducts() will be called once and should return a Collection
or Array, it is not called on each loop of the iterator.

You may need a different form of the iterator tag.
http://struts.apache.org/2.1.8.1/docs/iterator.html



On Fri, Jun 25, 2010 at 4:25 AM, Alex Rodriguez Lopez
<al...@flordeutopia.pt> wrote:
> You can do this without parameters. Write a setter for this index property
> (to save it), and then in the getter you grab the saved value.
>
>> Hi,
>>
>> I want to call s:iterator and fetch a list by passing it an index. This
>> list will be dynamically generated.
>>
>> <s:iterator value="products[#index]" var="product" status="stat">
>>
>> where I want getProducts(Integer index) to be called.
>>
>> Is this possible?
>>
>> Thanks
>>
>> Chris
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Passing parameters to getter methods?

Posted by Alex Rodriguez Lopez <al...@flordeutopia.pt>.
You can do this without parameters. Write a setter for this index 
property (to save it), and then in the getter you grab the saved value.

> Hi,
>
> I want to call s:iterator and fetch a list by passing it an index. This list will be dynamically generated.
>
> <s:iterator value="products[#index]" var="product" status="stat">
>
> where I want getProducts(Integer index) to be called.
>
> Is this possible?
>
> Thanks
>
> Chris

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org