You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Rajat Pandit <ra...@centergroupinc.com> on 2003/12/14 10:46:16 UTC
indexed properties mini(est) HOWTO
hello,
am positng a quick HOWTO to get started with using indexed properties,
as i guess almost everyone has had to deal with it atleast once.
pls post any suggestions/additions etc to improve on it. i might add on
the JSTL version a little version of it. (only the view part changes in
that case) just removes the inline scripting in that case.
In the View
-----------
<html:text name="_put_form_bean_name_here_"
property="<%="bidAmount[" + currIdx + "]"%> />
_put_form_bean_name_here_ => put your form bean name here.
currIdx = is the indexId from the <logic:iterate...>
bidAmount one of the values form the indexed property, property
In the formBean
----------------
u should use the property has arrayList as it can grow in size as required.
its basically very obvious to guess what will be arguments for the
getter and the setter will be, if u look at the view
getter (in case bidAmount arraylist stores float type)
------------------------------------------------------
public Float getBidAmount(int idx) {
if (idx < bidAmount.size()) {
return this.bidAmount[idx]
} else {
return new Float(0);
}
}
setter (this was the tricky one)
--------------------------------
public void setBidAmount(int idx, Float value) {
// the while loop will increase the size
// to what is required
while (idx >= this.bidAmount.size()) {
this.bidAmount.add(new Float(0));
}
// now just replace the value at the requried position.
this.bidAmount.set(idx,value);
}
--
Rajat Pandit | rajatp@centergroupinc.com
IT Consultant
Phone: +91 612 3117606
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org
Re: indexed properties mini(est) HOWTO
Posted by Hubert Rabago <ja...@yahoo.com>.
The wiki might be a good place for this:
http://nagoya.apache.org/wiki/apachewiki.cgi?StrutsNewFaqs
--- Rajat Pandit <ra...@centergroupinc.com> wrote:
> hello,
> am positng a quick HOWTO to get started with using indexed properties,
> as i guess almost everyone has had to deal with it atleast once.
>
> pls post any suggestions/additions etc to improve on it. i might add on
> the JSTL version a little version of it. (only the view part changes in
> that case) just removes the inline scripting in that case.
>
>
> In the View
> -----------
> <html:text name="_put_form_bean_name_here_"
> property="<%="bidAmount[" + currIdx + "]"%> />
>
> _put_form_bean_name_here_ => put your form bean name here.
> currIdx = is the indexId from the <logic:iterate...>
> bidAmount one of the values form the indexed property, property
>
> In the formBean
> ----------------
> u should use the property has arrayList as it can grow in size as required.
>
> its basically very obvious to guess what will be arguments for the
> getter and the setter will be, if u look at the view
>
> getter (in case bidAmount arraylist stores float type)
> ------------------------------------------------------
> public Float getBidAmount(int idx) {
> if (idx < bidAmount.size()) {
> return this.bidAmount[idx]
> } else {
> return new Float(0);
> }
> }
>
> setter (this was the tricky one)
> --------------------------------
> public void setBidAmount(int idx, Float value) {
> // the while loop will increase the size
> // to what is required
> while (idx >= this.bidAmount.size()) {
> this.bidAmount.add(new Float(0));
> }
>
> // now just replace the value at the requried position.
> this.bidAmount.set(idx,value);
> }
>
>
>
>
>
> --
>
>
> Rajat Pandit | rajatp@centergroupinc.com
> IT Consultant
> Phone: +91 612 3117606
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
>
__________________________________
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org