RE: indexed properties mini(est) HOWTO

2003-12-16 Thread Nimish Chourey , Tidel Park - Chennai
What if I have a DynaAction form . In that case how do I handle the
getter/Setter method ...

-Original Message-
From: Rajat Pandit [mailto:[EMAIL PROTECTED] 
Sent: Sunday, December 14, 2003 3:16 PM
To: Struts Users Mailing List
Subject: 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 | [EMAIL PROTECTED]
IT Consultant
Phone: +91 612 3117606




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: indexed properties mini(est) HOWTO

2003-12-16 Thread rajatp
hello,
not very sure but iguess make ur custom form class by extending the
DynaActionForm and write your own getters and setters.

you would have to make it anyway coz (as far as i know) i couldnt find a
better way to do validatoin on indexed values. hence wrote it in the
validate() method.



 What if I have a DynaAction form . In that case how do I handle the
 getter/Setter method ...

 -Original Message-
 From: Rajat Pandit [mailto:[EMAIL PROTECTED]
 Sent: Sunday, December 14, 2003 3:16 PM
 To: Struts Users Mailing List
 Subject: 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 | [EMAIL PROTECTED]
 IT Consultant
 Phone: +91 612 3117606




 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: indexed properties mini(est) HOWTO

2003-12-15 Thread Hubert Rabago
The wiki might be a good place for this:
http://nagoya.apache.org/wiki/apachewiki.cgi?StrutsNewFaqs

--- Rajat Pandit [EMAIL PROTECTED] 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 | [EMAIL PROTECTED]
 IT Consultant
 Phone: +91 612 3117606
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


__
Do you Yahoo!?
New Yahoo! Photos - easier uploading and sharing.
http://photos.yahoo.com/

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties + Validator + JavaScript

2003-10-28 Thread Nicholas L Mohler





Hi Vara,

I have implemented client-side validations for indexed properties, but I
have done it through custom validators.  Look through the archive for a
thread titled Validation of Indexed properties.  I describe how I
implemented the client side validations for indexed properties.

Nick




   

  Vara Prasad 

  Reddy   To:   Struts Users Mailing List 
[EMAIL PROTECTED]  
  [EMAIL PROTECTED]cc:
 
  bs.net  Subject:  Indexed Properties + 
Validator + JavaScript   
   

  10/28/2003 07:47 

  AM   

  Please respond to

  Struts Users

  Mailing List

   

   





The validations for indexed properties are not fired on the client side,
they are fired on the server side only.

Is there a way I can do that on the client side.

I am working on a PO screen with many line items.

Regards
Vara Prasad


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties + Validator + JavaScript

2003-10-28 Thread Vara Prasad Reddy
Nick

http://www.mail-archive.com/[EMAIL PROTECTED]/msg19122.html

is this the message you are talking about or something else ?


Vara Prasad

-Original Message-
From: Nicholas L Mohler [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 28, 2003 6:38 PM
To: Struts Users Mailing List
Subject: Re: Indexed Properties + Validator + JavaScript







Hi Vara,

I have implemented client-side validations for indexed properties, but I
have done it through custom validators.  Look through the archive for a
thread titled Validation of Indexed properties.  I describe how I
implemented the client side validations for indexed properties.

Nick





  Vara Prasad
  Reddy   To:   Struts Users
Mailing List [EMAIL PROTECTED]
  [EMAIL PROTECTED]cc:
  bs.net  Subject:  Indexed Properties
+ Validator + JavaScript

  10/28/2003 07:47
  AM
  Please respond to
  Struts Users
  Mailing List






The validations for indexed properties are not fired on the client side,
they are fired on the server side only.

Is there a way I can do that on the client side.

I am working on a PO screen with many line items.

Regards
Vara Prasad


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties + Validator + JavaScript

2003-10-28 Thread Nicholas L Mohler





Vara,

Sorry about that Vara.  I thought I had sent this via the mailing list.
This was based on a private exchange with another person.  I have pasted my
comments below.  I don't guarantee that my method is the best way, but it
works for me :-)

Let me know if this helps.
Nick

I have done some indexed property validation, but I have primarily done
this by creating custom validators.  Many of my custom validators provide
the same functionality, but I do customize it so that I can do what I need.

For example, I have a required validation that uses the same(cloned)
javascript code for client-side validation and for server-side validation,
my java code uses the struts code to carry out the validation.

My validations have a few variables that help my javascript or java class -
some may be unneccessary , but I'm not yet slick enough with the DOM to get
around them:
indexed - is the property indexed (allows me to reuse the
validation for non-indexed properties)
tableName   - name of the html table that contains the rows to be
validated
headerRowPresent  - helps me count data rows in the table.
listName- name of one row in the form property - used when the page
is submitted and the indexed properties are loaded into the form.
formCollectionName  - name of the form property that contains the
collection to be validated - I could probably combine with tableName

In the Javascript:
I get my indexed variable and if the property is indexed, I set up to loop
through my table rows.
  I get the html table and get the row count so that I know how many
data rows to validate.
  I then loop through each row:
Construct the element name using the listName value + [ +
indexId + ]. + propertyName
Get the form element for the name and pass it to the validation
function to apply the validation.
If the property is not indexed, I get the form element and pass it to the
validation function to apply the validation.

I add any validation failure messsages to the fields array in the same
way as the struts validations, but I tack on the row number for information
since I validate all of the data rows.

In my java validation class, I do similar things, but I only apply the
indexed validations until one fails.  My java validation uses reflection in
quite a few places to invoke struts validations and to apply my own
validations.  The overall process is easier, though.
1)  Determine if the property is indexed.  If it is, then loop through the
collection of objects (formCollectionName) that contain the property.
2)  For each collection element, invoke the appropriate validation method
until all of the rows are validated or a property fails validation.
3)  If the property is not indexed, invoke the appropriate validation
method for the property.





   

  Vara Prasad 

  Reddy   To:   Struts Users Mailing List 
[EMAIL PROTECTED]  
  [EMAIL PROTECTED]cc:
 
  bs.net  Subject:  RE: Indexed Properties + 
Validator + JavaScript   
   

  10/28/2003 08:30 

  AM   

  Please respond to

  Struts Users

  Mailing List

   

   





Nick

http://www.mail-archive.com/[EMAIL PROTECTED]/msg19122.html

is this the message you are talking about or something else ?


Vara Prasad

-Original Message-
From: Nicholas L Mohler [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 28, 2003 6:38 PM
To: Struts Users Mailing List
Subject: Re: Indexed Properties + Validator + JavaScript







Hi Vara,

I have implemented client-side

RE: Indexed properties help!

2003-10-26 Thread Rajat Pandit
Hello fred,
Thanks for the  reply, so just for clarifiation, if I am using a
property which will be indexed then the getters and setters will be a
little different from the usual set and get
Ie

public String getBidAmount(int index) {
return bidAmount[index];
}

And 
public  void setBidAmount(int index, String val) {
bidAmount[index] = val;
}

And have to implement the bidAmoutn as an array?
Protected String[] bidAmount;

Do confirm if igot that right?
Thanks once again for ur time.


-Original Message-
From: Frederic Dernbach [mailto:[EMAIL PROTECTED] 
Sent: Sunday, October 26, 2003 8:23 AM
To: Struts Users Mailing List
Subject: Re: Indexed properties help!


Rajat,

Here is an example of an indexed property called 'signal' (in my
application it holds complex objects, not simple strings or integers):

public OrderedSignalBean getSignal(int index) {
while( index = this.getSignals().size() ){
this.getSignals().add(new OrderedSignalBean());
}
return (OrderedSignalBean) this.getSignals().get(index);
}

public void setSignal(int index, OrderedSignalBean signal) {
while ( index = signals.size() ){
signals.add(new OrderedSignalBean());
}
signals.set(index, signal);
}

The 'signals' member is private and is of type 'ArrayList'. It is
created in the form's contructor and the reset method of the form :
signals = new ArrayList().

The setter and getter methods of the indexed property perform so-clled
lazy-initialization so you do not have to worry about the siez of the
array list.

Hope this helps.

Fred 


Le dim 26/10/2003 à 16:54, Rajat Pandit a écrit :
 Hello,
 I am pasting some excepts from the struts documentation. It would be 
 really great if someone could help me clear this.
 
 Question 1:
 !-- snip --
  The indexed tags feature is provided by several tags that have an 
 optional boolean indexed attribute. This is only legal when inside a

 logic:iterate tag. When the indexed attribute is true, then the 
 tag will incorporate the loop index into the resulting HTML component.
 
 The several tags that support the indexed attribute can be broken 
 into three groups, split by what they do to incorporate the loop index

 into the resulting HTML component.
 Group 1   Group 2 Group 3
 checkbox  button  link
 file  image
 hiddensubmit   
 password   
 radio  
 select 
 text   
 textarea   
 
 In Group 1, all of these tags will generate an HTML name attribute 
 of name[nn].property. The value of each tag will also be initialized

 by the getter method corresponding to that property specification. 
 !--snip --
 
 
 So if I have name[nn].property, that essentially means I am creating 
 an array of the form. But what I really need is an array of property, 
 instead of the bean.
 
 Question 2:
 
 How should the property be declared in the the actionForm if it has to

 receive an array of information.
 
 
 thanks
 
 
 
 
 Rajat Pandit | [EMAIL PROTECTED]
 +91 612 3117606
 [ Developer and Part Time Human Being]
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed properties help!

2003-10-26 Thread Frederic Dernbach
Looks OK.

However, I would not use a basic array  (private members) but ArrayList,
HashMap or LinkedList, etc.

I did not manage to have arrays working (the lazy initialization
failed).

You will have problems in JSPs.


Le dim 26/10/2003  18:04, Rajat Pandit a crit :
 Hello fred,
 Thanks for the  reply, so just for clarifiation, if I am using a
 property which will be indexed then the getters and setters will be a
 little different from the usual set and get
 Ie
 
 public String getBidAmount(int index) {
   return bidAmount[index];
 }
 
 And 
 public  void setBidAmount(int index, String val) {
   bidAmount[index] = val;
 }
 
 And have to implement the bidAmoutn as an array?
 Protected String[] bidAmount;
 
 Do confirm if igot that right?
 Thanks once again for ur time.
 
 
 -Original Message-
 From: Frederic Dernbach [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, October 26, 2003 8:23 AM
 To: Struts Users Mailing List
 Subject: Re: Indexed properties help!
 
 
 Rajat,
 
 Here is an example of an indexed property called 'signal' (in my
 application it holds complex objects, not simple strings or integers):
 
   public OrderedSignalBean getSignal(int index) {
   while( index = this.getSignals().size() ){
   this.getSignals().add(new OrderedSignalBean());
   }
   return (OrderedSignalBean) this.getSignals().get(index);
   }
 
   public void setSignal(int index, OrderedSignalBean signal) {
   while ( index = signals.size() ){
   signals.add(new OrderedSignalBean());
   }
   signals.set(index, signal);
   }
 
 The 'signals' member is private and is of type 'ArrayList'. It is
 created in the form's contructor and the reset method of the form :
 signals = new ArrayList().
 
 The setter and getter methods of the indexed property perform so-clled
 lazy-initialization so you do not have to worry about the siez of the
 array list.
 
 Hope this helps.
 
 Fred 
 
 
 Le dim 26/10/2003  16:54, Rajat Pandit a crit :
  Hello,
  I am pasting some excepts from the struts documentation. It would be 
  really great if someone could help me clear this.
  
  Question 1:
  !-- snip --
   The indexed tags feature is provided by several tags that have an 
  optional boolean indexed attribute. This is only legal when inside a
 
  logic:iterate tag. When the indexed attribute is true, then the 
  tag will incorporate the loop index into the resulting HTML component.
  
  The several tags that support the indexed attribute can be broken 
  into three groups, split by what they do to incorporate the loop index
 
  into the resulting HTML component.
  Group 1 Group 2 Group 3
  checkboxbutton  link
  fileimage
  hidden  submit   
  password 
  radio
  select   
  text 
  textarea 
  
  In Group 1, all of these tags will generate an HTML name attribute 
  of name[nn].property. The value of each tag will also be initialized
 
  by the getter method corresponding to that property specification. 
  !--snip --
  
  
  So if I have name[nn].property, that essentially means I am creating 
  an array of the form. But what I really need is an array of property, 
  instead of the bean.
  
  Question 2:
  
  How should the property be declared in the the actionForm if it has to
 
  receive an array of information.
  
  
  thanks
  
  
  
  
  Rajat Pandit | [EMAIL PROTECTED]
  +91 612 3117606
  [ Developer and Part Time Human Being]
  
  
  -
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed properties help!

2003-10-26 Thread Frederic Dernbach
Rajat,

Here is an example of an indexed property called 'signal' (in my
application it holds complex objects, not simple strings or integers):

public OrderedSignalBean getSignal(int index) {
while( index = this.getSignals().size() ){
this.getSignals().add(new OrderedSignalBean());
}
return (OrderedSignalBean) this.getSignals().get(index);
}

public void setSignal(int index, OrderedSignalBean signal) {
while ( index = signals.size() ){
signals.add(new OrderedSignalBean());
}
signals.set(index, signal);
}

The 'signals' member is private and is of type 'ArrayList'. It is
created in the form's contructor and the reset method of the form :
signals = new ArrayList().

The setter and getter methods of the indexed property perform so-clled
lazy-initialization so you do not have to worry about the siez of the
array list.

Hope this helps.

Fred 


Le dim 26/10/2003  16:54, Rajat Pandit a crit :
 Hello,
 I am pasting some excepts from the struts documentation. It would be
 really great if someone could help me clear this.
 
 Question 1:
 !-- snip --
  The indexed tags feature is provided by several tags that have an
 optional boolean indexed attribute. This is only legal when inside a
 logic:iterate tag. When the indexed attribute is true, then the
 tag will incorporate the loop index into the resulting HTML component.
 
 The several tags that support the indexed attribute can be broken into
 three groups, split by what they do to incorporate the loop index into
 the resulting HTML component.
 Group 1   Group 2 Group 3
 checkbox  button  link
 file  image
 hiddensubmit   
 password   
 radio  
 select 
 text   
 textarea   
 
 In Group 1, all of these tags will generate an HTML name attribute of
 name[nn].property. The value of each tag will also be initialized by
 the getter method corresponding to that property specification. 
 !--snip --
 
 
 So if I have name[nn].property, that essentially means I am creating an
 array of the form. But what I really need is an array of property,
 instead of the bean.
 
 Question 2:
 
 How should the property be declared in the the actionForm if it has to
 receive an array of information.
 
 
 thanks
 
 
 
 
 Rajat Pandit | [EMAIL PROTECTED]
 +91 612 3117606
 [ Developer and Part Time Human Being]
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties examples?

2003-10-21 Thread hsc
i have same question as you , do you have get right answer?
my resolve is like this :

form bean -
  private ArrayList awards = new ArrayList (5);
  public void reset(ActionMapping actionMapping, HttpServletRequest
httpServletRequest) {
awards .add(0,new AwardMasView ());
awards .add(1,new AwardMasView ());
awards .add(2,new AwardMasView ());
awards .add(3,new AwardMasView ());
awards .add(4,new AwardMasView ());
  }

the program can right work, but ArrayList's length is fixed .

if you have get right answer ,would you maind share whit me.




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties examples?

2003-10-21 Thread shirishchandra.sakhare
Search the user archive...
This question has been answered many times(Use of lazy lists is one of the ways to 
manange the list runtime..)

-Original Message-
From: hsc [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 21, 2003 9:29 AM
To: [EMAIL PROTECTED]
Subject: Re: Indexed Properties examples?


i have same question as you , do you have get right answer?
my resolve is like this :

form bean -
  private ArrayList awards = new ArrayList (5);
  public void reset(ActionMapping actionMapping, HttpServletRequest
httpServletRequest) {
awards .add(0,new AwardMasView ());
awards .add(1,new AwardMasView ());
awards .add(2,new AwardMasView ());
awards .add(3,new AwardMasView ());
awards .add(4,new AwardMasView ());
  }

the program can right work, but ArrayList's length is fixed .

if you have get right answer ,would you maind share whit me.




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties examples?

2003-10-21 Thread Benz Lim
try looking at www.keyboardmonkey.com

I believe the example on nested tag will help you...

Best Regards,
Benz Lim

-Original Message-
From: hsc [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 21, 2003 3:29 PM
To: [EMAIL PROTECTED]
Subject: Re: Indexed Properties examples?


i have same question as you , do you have get right answer?
my resolve is like this :

form bean -
  private ArrayList awards = new ArrayList (5);
  public void reset(ActionMapping actionMapping, HttpServletRequest
httpServletRequest) {
awards .add(0,new AwardMasView ());
awards .add(1,new AwardMasView ());
awards .add(2,new AwardMasView ());
awards .add(3,new AwardMasView ());
awards .add(4,new AwardMasView ());
  }

the program can right work, but ArrayList's length is fixed .

if you have get right answer ,would you maind share whit me.




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties examples?

2003-10-21 Thread Frederic Dernbach
OK, I faced the same problems you a few weeks ago (I was a total newbee
with indexed properties and I spent 10 full days on the problem - I'm
still hot on this one !).

I haven't read the initial post and I hope my input will be useful to
you.

Regarding the form :
1/ I create an empty array list in the constructor :
ArrayList awards = new ArrayList();

2/ I do the same in the reset() method. Create the an empty ArrayList.
Do not set the list to null items like you proposed, otherwise you will
have problems with the BeanUtils.populate() method when forwarding a
struts request.Reset the list elements to null only for boolean
elements.

3/ Have the following the setter and getter methods in your form (and
perform laying list initialization for the 'Award' form property) :
public ArrayList getAwards() {
return awards
}
public void setAwards (ArrayList awards) {
this.awards = awards;
}

public AwardMasView getAward(int index) {
while( index = awards.size() ){
awards.add(new AwardMasView());
}
return (AwardLasView) awards.get(index);
}
public void setAward(int index, AwardMasView object) {
while ( index = awards.size() ){
awards.add(new AwardMasView());
}
awards.set(index, object);
}

In a JSp you can now use tboth the 'Awards' and 'Award' form property
('Award' being the INDEXED property) :

logic:iterate  name=youtformname
property=awards
id=award 
type=path.to.your.form.yourformname

html:hidden name=award property=youtpropertyname   indexed=true/

/logic:iterate

Note that the 'id' attribute of the login:iterate has to be equal to
the name of your indexed property ('Award').

And do not forget to include every indexed property in your form (liek
the example above) if you are using bean:write tag to display your
indexed property, otherwise you will have problems with
BeanUtils.populate() methods.

Cheers,

Fred


Le mar 21/10/2003  09:29, hsc a crit :
 i have same question as you , do you have get right answer?
 my resolve is like this :
 
 form bean -
   private ArrayList awards = new ArrayList (5);
   public void reset(ActionMapping actionMapping, HttpServletRequest
 httpServletRequest) {
 awards .add(0,new AwardMasView ());
 awards .add(1,new AwardMasView ());
 awards .add(2,new AwardMasView ());
 awards .add(3,new AwardMasView ());
 awards .add(4,new AwardMasView ());
   }
 
 the program can right work, but ArrayList's length is fixed .
 
 if you have get right answer ,would you maind share whit me.
 
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties examples?

2003-10-21 Thread Mark Lowe
If you're using struts 1.1 you can define a form property as an 
arrayList to do the same thing..

form-property name=myproperty type=java.util.ArrayList /
...
action name=myForm scope=session ..
..
ArrayList myList = new ArrayList()

theForm.set(myproperty,myList);



..
logic:iterate id=foo name=myForm property=myproperty
..

Cheers Mark

On Tuesday, October 21, 2003, at 12:33 PM, Frederic Dernbach wrote:

OK, I faced the same problems you a few weeks ago (I was a total newbee
with indexed properties and I spent 10 full days on the problem - I'm
still hot on this one !).
I haven't read the initial post and I hope my input will be useful to
you.
Regarding the form :
1/ I create an empty array list in the constructor :
ArrayList awards = new ArrayList();
2/ I do the same in the reset() method. Create the an empty ArrayList.
Do not set the list to null items like you proposed, otherwise you will
have problems with the BeanUtils.populate() method when forwarding a
struts request.Reset the list elements to null only for boolean
elements.
3/ Have the following the setter and getter methods in your form (and
perform laying list initialization for the 'Award' form property) :
public ArrayList getAwards() {
return awards
}
public void setAwards (ArrayList awards) {
this.awards = awards;
}
public AwardMasView getAward(int index) {
while( index = awards.size() ){
awards.add(new AwardMasView());
}
return (AwardLasView) awards.get(index);
}
public void setAward(int index, AwardMasView object) {
while ( index = awards.size() ){
awards.add(new AwardMasView());
}
awards.set(index, object);
}
In a JSp you can now use tboth the 'Awards' and 'Award' form property
('Award' being the INDEXED property) :
logic:iterate   name=youtformname
property=awards
id=award
type=path.to.your.form.yourformname

html:hidden name=award property=youtpropertynameindexed=true/

/logic:iterate
Note that the 'id' attribute of the login:iterate has to be equal to
the name of your indexed property ('Award').
And do not forget to include every indexed property in your form (liek
the example above) if you are using bean:write tag to display your
indexed property, otherwise you will have problems with
BeanUtils.populate() methods.
Cheers,

Fred

Le mar 21/10/2003 à 09:29, hsc a écrit :
i have same question as you , do you have get right answer?
my resolve is like this :
form bean -
  private ArrayList awards = new ArrayList (5);
  public void reset(ActionMapping actionMapping, HttpServletRequest
httpServletRequest) {
awards .add(0,new AwardMasView ());
awards .add(1,new AwardMasView ());
awards .add(2,new AwardMasView ());
awards .add(3,new AwardMasView ());
awards .add(4,new AwardMasView ());
  }
the program can right work, but ArrayList's length is fixed .

if you have get right answer ,would you maind share whit me.



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Indexed Properties examples?

2003-10-14 Thread Karr, David
Try changing the property value reference in your JSP to reference
awardIndexed instead of AwardIndexed.  That might help, but I'm not
certain.

 -Original Message-
 From: Michael Blair [mailto:[EMAIL PROTECTED] 
 
 I am still trying to get this to work. I simply want to 
 display records in
 table format in a browser and be able to change the data, do 
 a submit and
 have access to the changes back in the action. Currently I am 
 getting :
 HTTP ERROR: 500 No getter method for property 
 AwardIndexed[0].safAwardCode
 of bean awards
 
 If I can offer anymore info, please ask. Also, if anyone has a working
 example of this I would love to see the snippets of the jsp, 
 formbean and
 any other relevant parts.
 
 Mike
 
 Here are some snippets.
 .jsp -
 logic:iterate name=awardMasResultsForm property=awards 
 id=awards
 scope=session indexId=ctr
bean:write name=awards property='%= 
 AwardIndexed[ + ctr +
 ].safAwardCode %'/
html:checkbox name=awards property='%= 
 AwardIndexed[ + ctr +
 ].deleteRecord %'/
 
 form bean -
   private ArrayList awards;
  public void setAwardIndexed(int index, AwardMasView ob){
   System.out.println(setAward);
   this.awards.set(index, ob);
  }
 
  public AwardMasView getAwardIndexed(int index){
   System.out.println(getAward);
   return (AwardMasView)this.awards.get(index);
  }

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-29 Thread Nicholas L Mohler





Atta,

It sounds to me like you have it.  As long as your names match up, it
should work fine.  Ajay has given a full code example that looks good.

Nick



   

  atta-ur rehman 

  [EMAIL PROTECTED]To:   Struts Users Mailing List 
[EMAIL PROTECTED]  
  com cc: 

   Subject:  Re: Indexed Properties

  07/28/2003 08:44 

  PM   

  Please respond to

  Struts Users

  Mailing List

   

   





Yes, I currently have two independent String arrays for blockName and
blockType. Putting them, and all the other block related properties, is
what
seems to be the right thing to do! So you have confirmed.

here is what i have understood from your text:

1) my form would have blocks property that would be a collection of Block
beans
2) iterating each block in the blocks collection i can sure display each
block with indexed=true directive for text boxes and dropdowns.
3) now for the submission part i'd need to have setBlockType(int, string)
and getBlockType(int) and same for the rest of properties. The name of
property in the Block Form and name of the property in the Block Bean must
match.
4) and it should work?

I've had my head stuck in my computer whole day today and i'm barely able
to
write this email :) Tommorrow morning i'd come back and confirm it by
running it. meanwhile I'd appreciate if you could confirm these 4 points
i've noted above!

Thankyou very much for your help. It really did help.

Regards,

ATTA


- Original Message -
From: Nick [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 5:08 PM
Subject: RE: Indexed Properties


 Hi Atta,

 No problem with the assistance.  Just hope that I can be helpful :-)  In
 the cases where I use indexed properties, the property is part of a
 larger object.  It sounds to me like you have two arrays in your form
 class: one for blockName and one for blockType.  I would suggest
 creating a bean with the two properties, and then have a collection of
 those objects in your form.

 Building on my previous example, you'd have something like this:
  logic:iterate name=blocks id=oneBlock
  type=com.myco.beans.Block
  td
html:text name=oneBlock property=blockName indexed =true/
  /td
  td
html:select name=oneBlock property=blockType
 indexed=true size=1
   html:options name=myForm property=blockTypes/
/html:select.
  /td
  /logic:iterate

 This example assumes your collection of blockTypes is part of your form,
 but it could be a collection that was in request/session/application
 scope.  You would create form entries for the collection like you
 implemented in our previous emails.

 I have almost this exact code in a few places and it works well.

 Hope this helps.
 Nick

 -Original Message-
 From: atta-ur rehman [mailto:[EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 3:37 PM
 To: Struts Users Mailing List
 Subject: Re: Indexed Properties

 Thanks, for the reply.

 Okay, here is the background. I'm trying to learn the user of Indexed
 Properties. Why I'm doing that? Well, I have a form that lists, let's
 say
 for the sake of simplicity, Block Name and Block Type columns. Block
 Name is
 a readonly text field while the Block Type is a dropdown list box with a
 set
 of reference values  coming from the database. User can have n blocks on
 the
 page and he can change the block type of any block on the page. user
 cannot
 define a new block on this page.

 In my form I've got String[] getter/setters for blockName and blockType
 properties. In my action, I set both these arrays

Re: Indexed Properties

2003-07-29 Thread atta-ur rehman
Hello again Nick.

Well i've come a step forward in that i've been able to successfully show
the jsp page using index=true for all the rows and submit the form without
any errors too:

logic:iterate name=theForm property=blocks id=block
type=test.Block
   tr
td align=center
 html:text property=id name=block indexed=true /
/td
td
 html:text property=name name=block indexed=true /
/td
td
 html:select property=category name=block indexed=true
  html:options collection=optionList property=value
labelProperty=label/
 /html:select
/td
   /tr
  /logic:iterate

works like a charm!

What i'm still missing what is updated when i submit the form? where can i
get updated values from? my ActionForm has list attirbute called blocks
each element in the list is a Block bean object. The Block bean has
getter/setters for id, name and category.

In ActionForm I also included setCategory(int) and getCategory(int, string)
which doesn't seem to be called at all!

something obvious that i'm missing?

Thanks.

ATTA


- Original Message - 
From: Nicholas L Mohler [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 2:57 AM
Subject: Re: Indexed Properties







 Atta,

 It sounds to me like you have it.  As long as your names match up, it
 should work fine.  Ajay has given a full code example that looks good.

 Nick




   atta-ur rehman
   [EMAIL PROTECTED]To:   Struts Users
Mailing List [EMAIL PROTECTED]
   com cc:
Subject:  Re: Indexed
Properties
   07/28/2003 08:44
   PM
   Please respond to
   Struts Users
   Mailing List






 Yes, I currently have two independent String arrays for blockName and
 blockType. Putting them, and all the other block related properties, is
 what
 seems to be the right thing to do! So you have confirmed.

 here is what i have understood from your text:

 1) my form would have blocks property that would be a collection of
Block
 beans
 2) iterating each block in the blocks collection i can sure display each
 block with indexed=true directive for text boxes and dropdowns.
 3) now for the submission part i'd need to have setBlockType(int, string)
 and getBlockType(int) and same for the rest of properties. The name of
 property in the Block Form and name of the property in the Block Bean must
 match.
 4) and it should work?

 I've had my head stuck in my computer whole day today and i'm barely able
 to
 write this email :) Tommorrow morning i'd come back and confirm it by
 running it. meanwhile I'd appreciate if you could confirm these 4 points
 i've noted above!

 Thankyou very much for your help. It really did help.

 Regards,

 ATTA


 - Original Message -
 From: Nick [EMAIL PROTECTED]
 To: 'Struts Users Mailing List' [EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 5:08 PM
 Subject: RE: Indexed Properties


  Hi Atta,
 
  No problem with the assistance.  Just hope that I can be helpful :-)  In
  the cases where I use indexed properties, the property is part of a
  larger object.  It sounds to me like you have two arrays in your form
  class: one for blockName and one for blockType.  I would suggest
  creating a bean with the two properties, and then have a collection of
  those objects in your form.
 
  Building on my previous example, you'd have something like this:
   logic:iterate name=blocks id=oneBlock
   type=com.myco.beans.Block
   td
 html:text name=oneBlock property=blockName indexed =true/
   /td
   td
 html:select name=oneBlock property=blockType
  indexed=true size=1
html:options name=myForm property=blockTypes/
 /html:select.
   /td
   /logic:iterate
 
  This example assumes your collection of blockTypes is part of your form,
  but it could be a collection that was in request/session/application
  scope.  You would create form entries for the collection like you
  implemented in our previous emails.
 
  I have almost this exact code in a few places and it works well.
 
  Hope this helps.
  Nick
 
  -Original Message-
  From: atta-ur rehman [mailto:[EMAIL PROTECTED]
  Sent: Monday, July 28, 2003 3:37 PM
  To: Struts Users Mailing List
  Subject: Re: Indexed Properties
 
  Thanks, for the reply.
 
  Okay, here is the background. I'm trying to learn the user of Indexed
  Properties. Why I'm doing that? Well, I have a form that lists, let's
  say
  for the sake of simplicity, Block Name and Block Type columns. Block
  Name is
  a readonly text field while the Block Type is a dropdown list box with a
  set
  of reference values  coming from the database. User can have n blocks on
  the
  page and he can change the block type of any block on the page. user
  cannot

RE: Indexed Properties

2003-07-29 Thread Paananen, Tero
 What i'm still missing what is updated when i submit the 
 form? where can i
 get updated values from? my ActionForm has list attirbute 
 called blocks
 each element in the list is a Block bean object. The
 Block bean has getter/setters for id, name and category.

Two strategies:

1. Update everything every time you submit regardless of
   whether the information changed or not

2. Keep the previous values around and compare the values
   submitted to the previous ones. Then only update the beans
   that changed. You could do this in a number of ways.

-TPP

-
This email may contain confidential and privileged material for the sole use of the 
intended recipient(s). Any review, use, retention, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete all 
copies of this message.  Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive emails on the 
basis that we are not liable for any such corruption, interception, tampering, 
amendment or viruses or any consequence thereof.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-29 Thread atta-ur rehman
Thanks.

you see my problem is i don't know how to get the updated values when the
form is submitted? my beans collection is updated, my indexed getter/setter
are not called? so where are the new values or even the same values when i
submit without changing anything at all on the form?

this is my Action code that i'm using to get values:
TestForm tf = (TestForm) form;

HttpSession session = request.getSession();

if (tf != null  tf.getBlocks() != null) {

List list = tf.getBlocks();

Block block;

for (int i = 0; i  list.size(); i++) {

block = (Block) list.get(i);

System.out.println(TestAction.execute Block:  +

block.getId() + ,  + block.getName() + ,  +

block.getCategory());

}

} // if (tf != null  tf.getBlocks() != null)

but this code always prints the values that i set the first time page was
shown!



ATTA

- Original Message - 
From: Paananen, Tero [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 10:04 AM
Subject: RE: Indexed Properties


  What i'm still missing what is updated when i submit the
  form? where can i
  get updated values from? my ActionForm has list attirbute
  called blocks
  each element in the list is a Block bean object. The
  Block bean has getter/setters for id, name and category.

 Two strategies:

 1. Update everything every time you submit regardless of
whether the information changed or not

 2. Keep the previous values around and compare the values
submitted to the previous ones. Then only update the beans
that changed. You could do this in a number of ways.

 -TPP

 -
 This email may contain confidential and privileged material for the sole
use of the intended recipient(s). Any review, use, retention, distribution
or disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact the
sender by reply email and delete all copies of this message.  Also, email is
susceptible to data corruption, interception, tampering, unauthorized
amendment and viruses. We only send and receive emails on the basis that we
are not liable for any such corruption, interception, tampering, amendment
or viruses or any consequence thereof.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties

2003-07-29 Thread Paananen, Tero
 but this code always prints the values that i set
 the first time page was shown!

Beats me...the code looked fine to me.

Maybe something wrong with your action mappings
and form bean configurations? Or the JSP the values
are changed on.

-TPP

-
This email may contain confidential and privileged material for the sole use of the 
intended recipient(s). Any review, use, retention, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete all 
copies of this message.  Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive emails on the 
basis that we are not liable for any such corruption, interception, tampering, 
amendment or viruses or any consequence thereof.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-29 Thread atta-ur rehman
so you are saying that ideally the the beans collection in my ActionForm
should be updated on form submission?


- Original Message - 
From: Paananen, Tero [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 10:30 AM
Subject: RE: Indexed Properties


  but this code always prints the values that i set
  the first time page was shown!

 Beats me...the code looked fine to me.

 Maybe something wrong with your action mappings
 and form bean configurations? Or the JSP the values
 are changed on.

 -TPP

 -
 This email may contain confidential and privileged material for the sole
use of the intended recipient(s). Any review, use, retention, distribution
or disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact the
sender by reply email and delete all copies of this message.  Also, email is
susceptible to data corruption, interception, tampering, unauthorized
amendment and viruses. We only send and receive emails on the basis that we
are not liable for any such corruption, interception, tampering, amendment
or viruses or any consequence thereof.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties

2003-07-29 Thread Paananen, Tero
 so you are saying that ideally the the beans collection
 in my ActionForm should be updated on form submission?

The attribute values in the beans held in the collection
should change on form submission, yes.

-TPP

-
This email may contain confidential and privileged material for the sole use of the 
intended recipient(s). Any review, use, retention, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete all 
copies of this message.  Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive emails on the 
basis that we are not liable for any such corruption, interception, tampering, 
amendment or viruses or any consequence thereof.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-29 Thread atta-ur rehman
Okay.

my form-bean definition looks like:

form-bean name=testForm type=test.TestForm/

while the action is:

action path=/test  type=test.TestAction
  name=testForm  scope=session validate=false
input=/test.jsp
  forward name=failure path=/mainMenu.jsp/
  forward name=success path=/test.jsp/
/action

my form class extends ActionForm.

any ideas?

ATTA

- Original Message - 
From: Paananen, Tero [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 10:43 AM
Subject: RE: Indexed Properties


  so you are saying that ideally the the beans collection
  in my ActionForm should be updated on form submission?

 The attribute values in the beans held in the collection
 should change on form submission, yes.

 -TPP

 -
 This email may contain confidential and privileged material for the sole
use of the intended recipient(s). Any review, use, retention, distribution
or disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact the
sender by reply email and delete all copies of this message.  Also, email is
susceptible to data corruption, interception, tampering, unauthorized
amendment and viruses. We only send and receive emails on the basis that we
are not liable for any such corruption, interception, tampering, amendment
or viruses or any consequence thereof.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-29 Thread Nicholas L Mohler





Hi Atta

Just to clatify:
1)  You have a form that contains a blocks property which is a collection
of test.Block objects.
2)  The test.Block object has the following properties(get/set methods
for each): id, name, and category
3)  As we discussesed in our earlier emails, you have the get/set methods
for the blocks property in your form.
4)  You also have a singular getBlock method that takes an int (index)
and returns the Block object from the collection for the given index.

A couple possible causes for the error:
-  Item 4) is not implemented correctly.  You need the method shown below.
Note that since your form is in the session, you shouldn't need the
sizing logic.
public Block getBlock(int index) {
  while (index = this.blocks.size()) {
this.blocks.add(new Block());
  }
  return (Block) this.blocks.get(index);
}

-  When looking at your page, look at the source and confirm that your
indexed properties are named correctly.  You should see block[0].id,
block[0].name, block[0].category.

If none of this helps, I'm not sure where else to look.  It sounds like
everything else is lining up...

Nick




   

  atta-ur rehman 

  [EMAIL PROTECTED]To:   Struts Users Mailing List 
[EMAIL PROTECTED]  
  com cc: 

   Subject:  Re: Indexed Properties

  07/29/2003 12:57 

  PM   

  Please respond to

  Struts Users

  Mailing List

   

   





Hello again Nick.

Well i've come a step forward in that i've been able to successfully show
the jsp page using index=true for all the rows and submit the form
without
any errors too:

logic:iterate name=theForm property=blocks id=block
type=test.Block
   tr
td align=center
 html:text property=id name=block indexed=true /
/td
td
 html:text property=name name=block indexed=true /
/td
td
 html:select property=category name=block indexed=true
  html:options collection=optionList property=value
labelProperty=label/
 /html:select
/td
   /tr
  /logic:iterate

works like a charm!

What i'm still missing what is updated when i submit the form? where can i
get updated values from? my ActionForm has list attirbute called blocks
each element in the list is a Block bean object. The Block bean has
getter/setters for id, name and category.

In ActionForm I also included setCategory(int) and getCategory(int, string)
which doesn't seem to be called at all!

something obvious that i'm missing?

Thanks.

ATTA


- Original Message -
From: Nicholas L Mohler [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 2:57 AM
Subject: Re: Indexed Properties







 Atta,

 It sounds to me like you have it.  As long as your names match up, it
 should work fine.  Ajay has given a full code example that looks good.

 Nick




   atta-ur rehman
   [EMAIL PROTECTED]To:   Struts Users
Mailing List [EMAIL PROTECTED]
   com cc:
Subject:  Re: Indexed
Properties
   07/28/2003 08:44
   PM
   Please respond to
   Struts Users
   Mailing List






 Yes, I currently have two independent String arrays for blockName and
 blockType. Putting them, and all the other block related properties, is
 what
 seems to be the right thing to do! So you have confirmed.

 here is what i have understood from your text:

 1) my form would have blocks property that would be a collection of
Block
 beans
 2) iterating each block

Re: Indexed Properties

2003-07-29 Thread atta-ur rehman
Bingo!

The deceptive ActionForm.getBlock(int):Block was not there. Just added it
and wow!

This is opened up a whole paradigm for me. I can see how easy and manageable
code becomes not to mention its reduced size! Its just what i've been
looking for, for quite sometime! Learning new things pays, after all ;)

My sincere thanks for your help and patience! It took some time, but was
worth it!

ATTA


- Original Message - 
From: Nicholas L Mohler [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Tuesday, July 29, 2003 11:19 AM
Subject: Re: Indexed Properties







 Hi Atta

 Just to clatify:
 1)  You have a form that contains a blocks property which is a
collection
 of test.Block objects.
 2)  The test.Block object has the following properties(get/set methods
 for each): id, name, and category
 3)  As we discussesed in our earlier emails, you have the get/set methods
 for the blocks property in your form.
 4)  You also have a singular getBlock method that takes an int (index)
 and returns the Block object from the collection for the given index.

 A couple possible causes for the error:
 -  Item 4) is not implemented correctly.  You need the method shown below.
 Note that since your form is in the session, you shouldn't need the
 sizing logic.
 public Block getBlock(int index) {
   while (index = this.blocks.size()) {
 this.blocks.add(new Block());
   }
   return (Block) this.blocks.get(index);
 }

 -  When looking at your page, look at the source and confirm that your
 indexed properties are named correctly.  You should see block[0].id,
 block[0].name, block[0].category.

 If none of this helps, I'm not sure where else to look.  It sounds like
 everything else is lining up...

 Nick






   atta-ur rehman
   [EMAIL PROTECTED]To:   Struts Users
Mailing List [EMAIL PROTECTED]
   com cc:
Subject:  Re: Indexed
Properties
   07/29/2003 12:57
   PM
   Please respond to
   Struts Users
   Mailing List






 Hello again Nick.

 Well i've come a step forward in that i've been able to successfully show
 the jsp page using index=true for all the rows and submit the form
 without
 any errors too:

 logic:iterate name=theForm property=blocks id=block
 type=test.Block
tr
 td align=center
  html:text property=id name=block indexed=true /
 /td
 td
  html:text property=name name=block indexed=true /
 /td
 td
  html:select property=category name=block indexed=true
   html:options collection=optionList property=value
 labelProperty=label/
  /html:select
 /td
/tr
   /logic:iterate

 works like a charm!

 What i'm still missing what is updated when i submit the form? where can i
 get updated values from? my ActionForm has list attirbute called blocks
 each element in the list is a Block bean object. The Block bean has
 getter/setters for id, name and category.

 In ActionForm I also included setCategory(int) and getCategory(int,
string)
 which doesn't seem to be called at all!

 something obvious that i'm missing?

 Thanks.

 ATTA


 - Original Message -
 From: Nicholas L Mohler [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Tuesday, July 29, 2003 2:57 AM
 Subject: Re: Indexed Properties


 
 
 
 
 
  Atta,
 
  It sounds to me like you have it.  As long as your names match up, it
  should work fine.  Ajay has given a full code example that looks good.
 
  Nick
 
 
 
 
atta-ur rehman
[EMAIL PROTECTED]To:   Struts Users
 Mailing List [EMAIL PROTECTED]
com cc:
 Subject:  Re: Indexed
 Properties
07/28/2003 08:44
PM
Please respond to
Struts Users
Mailing List
 
 
 
 
 
 
  Yes, I currently have two independent String arrays for blockName and
  blockType. Putting them, and all the other block related properties, is
  what
  seems to be the right thing to do! So you have confirmed.
 
  here is what i have understood from your text:
 
  1) my form would have blocks property that would be a collection of
 Block
  beans
  2) iterating each block in the blocks collection i can sure display each
  block with indexed=true directive for text boxes and dropdowns.
  3) now for the submission part i'd need to have setBlockType(int,
string)
  and getBlockType(int) and same for the rest of properties. The name of
  property in the Block Form and name of the property in the Block Bean
 must
  match.
  4) and it should work?
 
  I've had my head stuck in my computer whole day today and i'm barely
able
  to
  write

RE: Indexed Properties

2003-07-28 Thread Paananen, Tero
 I've been reading an indexed properties article at:
 
 http://jakarta.apache.org/struts/faqs/indexedprops.html

Also read http://www.developer.com/java/other/article.php/2233591

Very helpful.

-TPP

-
This email may contain confidential and privileged material for the sole use of the 
intended recipient(s). Any review, use, retention, distribution or disclosure by 
others is strictly prohibited. If you are not the intended recipient (or authorized to 
receive for the recipient), please contact the sender by reply email and delete all 
copies of this message.  Also, email is susceptible to data corruption, interception, 
tampering, unauthorized amendment and viruses. We only send and receive emails on the 
basis that we are not liable for any such corruption, interception, tampering, 
amendment or viruses or any consequence thereof.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-28 Thread atta-ur rehman
Thanks. It was helpful.

But it still leaves me thinking if Indexed Properties are meant ONLY for
DynaActionForm type of forms?

I'm still unable to use them by using an array in my conventional
ActionForm.

ATTA


- Original Message - 
From: Paananen, Tero [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 10:12 AM
Subject: RE: Indexed Properties


  I've been reading an indexed properties article at:
 
  http://jakarta.apache.org/struts/faqs/indexedprops.html

 Also read http://www.developer.com/java/other/article.php/2233591

 Very helpful.

 -TPP

 -
 This email may contain confidential and privileged material for the sole
use of the intended recipient(s). Any review, use, retention, distribution
or disclosure by others is strictly prohibited. If you are not the intended
recipient (or authorized to receive for the recipient), please contact the
sender by reply email and delete all copies of this message.  Also, email is
susceptible to data corruption, interception, tampering, unauthorized
amendment and viruses. We only send and receive emails on the basis that we
are not liable for any such corruption, interception, tampering, amendment
or viruses or any consequence thereof.


 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-28 Thread Nicholas L Mohler





Atta,

You can use indexed properties in your ActionForm class.  The key is having
all of the correct methods in your form class.

1)  Getter and setter:  You need a get/Set method for the collection that
you refer to in your jsp.  for example:
public Collection getLocations()
public void setLocations(Collection locs)

2) Getter and setter for one instance in the collection.  The name that you
use must match the name you define in your jsp as a single instance from
the collection (specified as the id).  For example:
logic:iterate name=locations id=oneLocation
type=com.myco.toolkits.beans.Location
td
html:text name=oneLocation property=locationName indexed
=true/
/td
td
html:text name=oneLocation property=locationAddress
indexed=true/
/td
/logic:iterate

Your form should in this case have the following get/set methods:
public com.myco.toolkits.beans.Location getOneLocation(int index)
public void setOneLocation(int index, com.myco.toolkits.beans.Location
oneLocation)

Your code may never use either of the oneLocation methods, but they are
important for Struts.  When your page is submitted, your two indexed
properties will be submitted as oneLocation[ix].locationName 
oneLocation[ix].locationAddress where ix is the index of the row (0-10 for
example).  As Struts proceses the indexed items, Struts will use the
getOneLocation method to get the Collection instance for the provided
index.  This method must resize the collection as needed and then return
the object for the provided index.  For example, if your collection has no
objects and the getter receives an index of 2, the method should load the
first three (0, 1, 2) collection locations with an initialized object and
return the third object.  Struts will then populate the appropriate
property in that object.

As an aside, I tend to use the ArrayList object as my collection type when
working with indexed properties, but I know that the Vector works equally
well.  A simple array will work fine, but the logic to expand the size is a
little more involved.

Let me know if this helps.
Nick



-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-28 Thread atta-ur rehman
Thanks very much Nick! It was indeed helpful. I was missing getter/setter
for individual list items!

now my form has following methods:
private String[] fruit = {Apple, Orange, Banana};

public List getFruits() {

return Arrays.asList(this.fruit);

}

public void setFruits(List l) {

this.fruit = (String[]) l.toArray();

}


public String getFruit(int index) {

if (this.fruit == null) return null;

return this.fruit[index];

}

public void setFruit(int index, String f) {

this.fruit[index] = f;

}

my JSP has following has this html:iterator:

logic:iterate name=theForm property=fruits id=oneF
type=java.lang.String 
   tr
td align=center
 hi!
/td
td
 html:text property=fruit name=oneF indexed=true /
/td
   /tr
  /logic:iterate

and exception i get is this:

javax.servlet.jsp.JspException: No getter method for property fruit of bean
oneF
at org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)


i think it has to do with the fact that my individual fruit is a string
object rather than being a bean in itself if some getter method(s)?

can you see what's going wrong!

Thanks again.

ATTA

- Original Message - 
From: Nicholas L Mohler [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 11:58 AM
Subject: Re: Indexed Properties







 Atta,

 You can use indexed properties in your ActionForm class.  The key is
having
 all of the correct methods in your form class.

 1)  Getter and setter:  You need a get/Set method for the collection that
 you refer to in your jsp.  for example:
 public Collection getLocations()
 public void setLocations(Collection locs)

 2) Getter and setter for one instance in the collection.  The name that
you
 use must match the name you define in your jsp as a single instance from
 the collection (specified as the id).  For example:
 logic:iterate name=locations id=oneLocation
 type=com.myco.toolkits.beans.Location
 td
 html:text name=oneLocation property=locationName indexed
 =true/
 /td
 td
 html:text name=oneLocation property=locationAddress
 indexed=true/
 /td
 /logic:iterate

 Your form should in this case have the following get/set methods:
 public com.myco.toolkits.beans.Location getOneLocation(int index)
 public void setOneLocation(int index, com.myco.toolkits.beans.Location
 oneLocation)

 Your code may never use either of the oneLocation methods, but they are
 important for Struts.  When your page is submitted, your two indexed
 properties will be submitted as oneLocation[ix].locationName 
 oneLocation[ix].locationAddress where ix is the index of the row (0-10 for
 example).  As Struts proceses the indexed items, Struts will use the
 getOneLocation method to get the Collection instance for the provided
 index.  This method must resize the collection as needed and then return
 the object for the provided index.  For example, if your collection has no
 objects and the getter receives an index of 2, the method should load the
 first three (0, 1, 2) collection locations with an initialized object and
 return the third object.  Struts will then populate the appropriate
 property in that object.

 As an aside, I tend to use the ArrayList object as my collection type when
 working with indexed properties, but I know that the Vector works equally
 well.  A simple array will work fine, but the logic to expand the size is
a
 little more involved.

 Let me know if this helps.
 Nick



 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]





-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Indexed Properties

2003-07-28 Thread Nicholas L Mohler





Atta,

The complaint you are getting is because the property fruit is not a
property of the oneF bean.  That the oneF object is not a bean with
properties will give you problems.  Depending on your goal, you need to do
something different.  What are you trying to do?

I'm off work in a minute, but I'll check messages at home later this
evening and see if I can help at all.
Nick



   

  atta-ur rehman 

  [EMAIL PROTECTED]To:   Struts Users Mailing List 
[EMAIL PROTECTED]  
  com cc: 

   Subject:  Re: Indexed Properties

  07/28/2003 03:44 

  PM   

  Please respond to

  Struts Users

  Mailing List

   

   





Thanks very much Nick! It was indeed helpful. I was missing getter/setter
for individual list items!

now my form has following methods:
private String[] fruit = {Apple, Orange, Banana};

public List getFruits() {

return Arrays.asList(this.fruit);

}

public void setFruits(List l) {

this.fruit = (String[]) l.toArray();

}


public String getFruit(int index) {

if (this.fruit == null) return null;

return this.fruit[index];

}

public void setFruit(int index, String f) {

this.fruit[index] = f;

}

my JSP has following has this html:iterator:

logic:iterate name=theForm property=fruits id=oneF
type=java.lang.String 
   tr
td align=center
 hi!
/td
td
 html:text property=fruit name=oneF indexed=true /
/td
   /tr
  /logic:iterate

and exception i get is this:

javax.servlet.jsp.JspException: No getter method for property fruit of bean
oneF
 at
org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)


i think it has to do with the fact that my individual fruit is a string
object rather than being a bean in itself if some getter method(s)?

can you see what's going wrong!

Thanks again.

ATTA

- Original Message -
From: Nicholas L Mohler [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 11:58 AM
Subject: Re: Indexed Properties







 Atta,

 You can use indexed properties in your ActionForm class.  The key is
having
 all of the correct methods in your form class.

 1)  Getter and setter:  You need a get/Set method for the collection that
 you refer to in your jsp.  for example:
 public Collection getLocations()
 public void setLocations(Collection locs)

 2) Getter and setter for one instance in the collection.  The name that
you
 use must match the name you define in your jsp as a single instance from
 the collection (specified as the id).  For example:
 logic:iterate name=locations id=oneLocation
 type=com.myco.toolkits.beans.Location
 td
 html:text name=oneLocation property=locationName indexed
 =true/
 /td
 td
 html:text name=oneLocation property=locationAddress
 indexed=true/
 /td
 /logic:iterate

 Your form should in this case have the following get/set methods:
 public com.myco.toolkits.beans.Location getOneLocation(int index)
 public void setOneLocation(int index, com.myco.toolkits.beans.Location
 oneLocation)

 Your code may never use either of the oneLocation methods, but they are
 important for Struts.  When your page is submitted, your two indexed
 properties will be submitted as oneLocation[ix].locationName 
 oneLocation[ix].locationAddress where ix is the index of the row (0-10
for
 example).  As Struts proceses the indexed items, Struts will use the
 getOneLocation method to get the Collection instance for the provided
 index.  This method must resize the collection as needed and then return
 the object for the provided index.  For example

Re: Indexed Properties

2003-07-28 Thread atta-ur rehman
Thanks, for the reply.

Okay, here is the background. I'm trying to learn the user of Indexed
Properties. Why I'm doing that? Well, I have a form that lists, let's say
for the sake of simplicity, Block Name and Block Type columns. Block Name is
a readonly text field while the Block Type is a dropdown list box with a set
of reference values  coming from the database. User can have n blocks on the
page and he can change the block type of any block on the page. user cannot
define a new block on this page.

In my form I've got String[] getter/setters for blockName and blockType
properties. In my action, I set both these arrays reading from the database.
Block Names show allright, but the block type dropdown, that is using
html:select tag, shows same type for all the blocks irrespective of the type
of the block read from database.

Now a few days back i asked a question on this forum regarding how to have
my dropdowns display the right block type as set in the blockType String[]
property of the form. Someone, I think it was Wendy Smoak, and i've seen
quite a lot of helpful mails from him, mentioned that Indexed Properties
might be the way go. Althogh, he also mentioned that he hasn't used them.

I solved the problem by using value property of html:select tag. the doc
says that value property denotes the value of the listbox that would be
used to select an item in the list. so far so good.

now the kind of guy i'm, i thought why not try it thrue index properties and
learn something new ;) so i set out to learn indexed properties. read some
articles and still i'm not sure what i'm missing.

Hope this gives you the background and thanks once more for taking some out
to hlep me.

ATTA

- Original Message - 
From: Nicholas L Mohler [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 1:09 PM
Subject: Re: Indexed Properties







 Atta,

 The complaint you are getting is because the property fruit is not a
 property of the oneF bean.  That the oneF object is not a bean with
 properties will give you problems.  Depending on your goal, you need to do
 something different.  What are you trying to do?

 I'm off work in a minute, but I'll check messages at home later this
 evening and see if I can help at all.
 Nick




   atta-ur rehman
   [EMAIL PROTECTED]To:   Struts Users
Mailing List [EMAIL PROTECTED]
   com cc:
Subject:  Re: Indexed
Properties
   07/28/2003 03:44
   PM
   Please respond to
   Struts Users
   Mailing List






 Thanks very much Nick! It was indeed helpful. I was missing getter/setter
 for individual list items!

 now my form has following methods:
 private String[] fruit = {Apple, Orange, Banana};

 public List getFruits() {

 return Arrays.asList(this.fruit);

 }

 public void setFruits(List l) {

 this.fruit = (String[]) l.toArray();

 }


 public String getFruit(int index) {

 if (this.fruit == null) return null;

 return this.fruit[index];

 }

 public void setFruit(int index, String f) {

 this.fruit[index] = f;

 }

 my JSP has following has this html:iterator:

 logic:iterate name=theForm property=fruits id=oneF
 type=java.lang.String 
tr
 td align=center
  hi!
 /td
 td
  html:text property=fruit name=oneF indexed=true /
 /td
/tr
   /logic:iterate

 and exception i get is this:

 javax.servlet.jsp.JspException: No getter method for property fruit of
bean
 oneF
  at
 org.apache.struts.util.RequestUtils.lookup(RequestUtils.java:968)


 i think it has to do with the fact that my individual fruit is a string
 object rather than being a bean in itself if some getter method(s)?

 can you see what's going wrong!

 Thanks again.

 ATTA

 - Original Message -
 From: Nicholas L Mohler [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 11:58 AM
 Subject: Re: Indexed Properties


 
 
 
 
 
  Atta,
 
  You can use indexed properties in your ActionForm class.  The key is
 having
  all of the correct methods in your form class.
 
  1)  Getter and setter:  You need a get/Set method for the collection
that
  you refer to in your jsp.  for example:
  public Collection getLocations()
  public void setLocations(Collection locs)
 
  2) Getter and setter for one instance in the collection.  The name that
 you
  use must match the name you define in your jsp as a single instance from
  the collection (specified as the id).  For example:
  logic:iterate name=locations id=oneLocation
  type=com.myco.toolkits.beans.Location
  td
  html:text name=oneLocation property=locationName
indexed
  =true/
  /td
  td
  html:text name=oneLocation property=locationAddress
  indexed=true

RE: Indexed Properties

2003-07-28 Thread Nick
Hi Atta,

No problem with the assistance.  Just hope that I can be helpful :-)  In
the cases where I use indexed properties, the property is part of a
larger object.  It sounds to me like you have two arrays in your form
class: one for blockName and one for blockType.  I would suggest
creating a bean with the two properties, and then have a collection of
those objects in your form.

Building on my previous example, you'd have something like this:
 logic:iterate name=blocks id=oneBlock
 type=com.myco.beans.Block
 td
   html:text name=oneBlock property=blockName indexed =true/
 /td
 td
   html:select name=oneBlock property=blockType
indexed=true size=1
  html:options name=myForm property=blockTypes/
   /html:select.
 /td
 /logic:iterate

This example assumes your collection of blockTypes is part of your form,
but it could be a collection that was in request/session/application
scope.  You would create form entries for the collection like you
implemented in our previous emails.

I have almost this exact code in a few places and it works well.

Hope this helps.
Nick

-Original Message-
From: atta-ur rehman [mailto:[EMAIL PROTECTED] 
Sent: Monday, July 28, 2003 3:37 PM
To: Struts Users Mailing List
Subject: Re: Indexed Properties

Thanks, for the reply.

Okay, here is the background. I'm trying to learn the user of Indexed
Properties. Why I'm doing that? Well, I have a form that lists, let's
say
for the sake of simplicity, Block Name and Block Type columns. Block
Name is
a readonly text field while the Block Type is a dropdown list box with a
set
of reference values  coming from the database. User can have n blocks on
the
page and he can change the block type of any block on the page. user
cannot
define a new block on this page.

In my form I've got String[] getter/setters for blockName and blockType
properties. In my action, I set both these arrays reading from the
database.
Block Names show allright, but the block type dropdown, that is using
html:select tag, shows same type for all the blocks irrespective of the
type
of the block read from database.

Now a few days back i asked a question on this forum regarding how to
have
my dropdowns display the right block type as set in the blockType
String[]
property of the form. Someone, I think it was Wendy Smoak, and i've seen
quite a lot of helpful mails from him, mentioned that Indexed Properties
might be the way go. Althogh, he also mentioned that he hasn't used
them.

I solved the problem by using value property of html:select tag. the
doc
says that value property denotes the value of the listbox that would
be
used to select an item in the list. so far so good.

now the kind of guy i'm, i thought why not try it thrue index properties
and
learn something new ;) so i set out to learn indexed properties. read
some
articles and still i'm not sure what i'm missing.

Hope this gives you the background and thanks once more for taking some
out
to hlep me.

ATTA

- Original Message - 
From: Nicholas L Mohler [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 1:09 PM
Subject: Re: Indexed Properties







 Atta,

 The complaint you are getting is because the property fruit is not a
 property of the oneF bean.  That the oneF object is not a bean with
 properties will give you problems.  Depending on your goal, you need
to do
 something different.  What are you trying to do?

 I'm off work in a minute, but I'll check messages at home later this
 evening and see if I can help at all.
 Nick




   atta-ur rehman
   [EMAIL PROTECTED]To:   Struts Users
Mailing List [EMAIL PROTECTED]
   com cc:
Subject:  Re: Indexed
Properties
   07/28/2003 03:44
   PM
   Please respond to
   Struts Users
   Mailing List






 Thanks very much Nick! It was indeed helpful. I was missing
getter/setter
 for individual list items!

 now my form has following methods:
 private String[] fruit = {Apple, Orange, Banana};

 public List getFruits() {

 return Arrays.asList(this.fruit);

 }

 public void setFruits(List l) {

 this.fruit = (String[]) l.toArray();

 }


 public String getFruit(int index) {

 if (this.fruit == null) return null;

 return this.fruit[index];

 }

 public void setFruit(int index, String f) {

 this.fruit[index] = f;

 }

 my JSP has following has this html:iterator:

 logic:iterate name=theForm property=fruits id=oneF
 type=java.lang.String 
tr
 td align=center
  hi!
 /td
 td
  html:text property=fruit name=oneF indexed=true /
 /td
/tr
   /logic:iterate

 and exception i get is this:

 javax.servlet.jsp.JspException: No getter method for property fruit of
bean
 oneF

Re: Indexed Properties

2003-07-28 Thread atta-ur rehman
Yes, I currently have two independent String arrays for blockName and
blockType. Putting them, and all the other block related properties, is what
seems to be the right thing to do! So you have confirmed.

here is what i have understood from your text:

1) my form would have blocks property that would be a collection of Block
beans
2) iterating each block in the blocks collection i can sure display each
block with indexed=true directive for text boxes and dropdowns.
3) now for the submission part i'd need to have setBlockType(int, string)
and getBlockType(int) and same for the rest of properties. The name of
property in the Block Form and name of the property in the Block Bean must
match.
4) and it should work?

I've had my head stuck in my computer whole day today and i'm barely able to
write this email :) Tommorrow morning i'd come back and confirm it by
running it. meanwhile I'd appreciate if you could confirm these 4 points
i've noted above!

Thankyou very much for your help. It really did help.

Regards,

ATTA


- Original Message - 
From: Nick [EMAIL PROTECTED]
To: 'Struts Users Mailing List' [EMAIL PROTECTED]
Sent: Monday, July 28, 2003 5:08 PM
Subject: RE: Indexed Properties


 Hi Atta,

 No problem with the assistance.  Just hope that I can be helpful :-)  In
 the cases where I use indexed properties, the property is part of a
 larger object.  It sounds to me like you have two arrays in your form
 class: one for blockName and one for blockType.  I would suggest
 creating a bean with the two properties, and then have a collection of
 those objects in your form.

 Building on my previous example, you'd have something like this:
  logic:iterate name=blocks id=oneBlock
  type=com.myco.beans.Block
  td
html:text name=oneBlock property=blockName indexed =true/
  /td
  td
html:select name=oneBlock property=blockType
 indexed=true size=1
   html:options name=myForm property=blockTypes/
/html:select.
  /td
  /logic:iterate

 This example assumes your collection of blockTypes is part of your form,
 but it could be a collection that was in request/session/application
 scope.  You would create form entries for the collection like you
 implemented in our previous emails.

 I have almost this exact code in a few places and it works well.

 Hope this helps.
 Nick

 -Original Message-
 From: atta-ur rehman [mailto:[EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 3:37 PM
 To: Struts Users Mailing List
 Subject: Re: Indexed Properties

 Thanks, for the reply.

 Okay, here is the background. I'm trying to learn the user of Indexed
 Properties. Why I'm doing that? Well, I have a form that lists, let's
 say
 for the sake of simplicity, Block Name and Block Type columns. Block
 Name is
 a readonly text field while the Block Type is a dropdown list box with a
 set
 of reference values  coming from the database. User can have n blocks on
 the
 page and he can change the block type of any block on the page. user
 cannot
 define a new block on this page.

 In my form I've got String[] getter/setters for blockName and blockType
 properties. In my action, I set both these arrays reading from the
 database.
 Block Names show allright, but the block type dropdown, that is using
 html:select tag, shows same type for all the blocks irrespective of the
 type
 of the block read from database.

 Now a few days back i asked a question on this forum regarding how to
 have
 my dropdowns display the right block type as set in the blockType
 String[]
 property of the form. Someone, I think it was Wendy Smoak, and i've seen
 quite a lot of helpful mails from him, mentioned that Indexed Properties
 might be the way go. Althogh, he also mentioned that he hasn't used
 them.

 I solved the problem by using value property of html:select tag. the
 doc
 says that value property denotes the value of the listbox that would
 be
 used to select an item in the list. so far so good.

 now the kind of guy i'm, i thought why not try it thrue index properties
 and
 learn something new ;) so i set out to learn indexed properties. read
 some
 articles and still i'm not sure what i'm missing.

 Hope this gives you the background and thanks once more for taking some
 out
 to hlep me.

 ATTA

 - Original Message - 
 From: Nicholas L Mohler [EMAIL PROTECTED]
 To: Struts Users Mailing List [EMAIL PROTECTED]
 Sent: Monday, July 28, 2003 1:09 PM
 Subject: Re: Indexed Properties


 
 
 
 
 
  Atta,
 
  The complaint you are getting is because the property fruit is not a
  property of the oneF bean.  That the oneF object is not a bean with
  properties will give you problems.  Depending on your goal, you need
 to do
  something different.  What are you trying to do?
 
  I'm off work in a minute, but I'll check messages at home later this
  evening and see if I can help at all.
  Nick
 
 
 
 
atta-ur rehman
[EMAIL

RE: Indexed properties and JavaScript

2003-06-25 Thread Jones, Ted
Have you tried:

onclick=alert(document.testForm.elements['att[0]'].value)

?


-Original Message-
From: Fabiano de O. Lucchese [mailto:[EMAIL PROTECTED]
Sent: Wednesday, June 25, 2003 1:53 PM
To: [EMAIL PROTECTED]
Subject: Indexed properties and JavaScript


Hi All,

I've been trying to develop a Struts based web site
and got stuck by the following problem: I have defined
a form bean that contains indexed properties; thus,
I'm supposed to use squared brackets [x] to refer to
the individual elements of each of these array-like
properties into my HTML/JSP page; on the other hand,
I also had to embbed some javascript code in this page
in order to enlighten the server-side processing. The
problem is that I just can't use javascript code along
with array-like properties because the brackets used
by them seem to conflict with the javascript syntax.

The following sample code reproduces this problem:

html
head
titletest/title
/head

body
form action=/test method=GET
name=testForm
input type=text
name=att[0]
input type=button
onclick=alert(document.testForm.att[0])
value=test
/form
/body
/html

and the error message is something like:
document.testForm.att.0 is null or is not an object.

One should notice that when the index reference [0] is
deleted, the page works fine.

Does anyone here has any experience with this problem
?

Thanks in advance.

FLu-X


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Confidentiality Warning:  This e-mail contains information intended only for the use 
of the individual or entity named above.  If the reader of this e-mail is not the 
intended recipient or the employee or agent responsible for delivering it to the 
intended recipient, any dissemination, publication or copying of this e-mail is 
strictly prohibited. The sender does not accept any responsibility for any loss, 
disruption or damage to your data or computer system that may occur while using data 
contained in, or transmitted with, this e-mail.   If you have received this e-mail in 
error, please immediately notify us by return e-mail.  Thank you.


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed properties and JavaScript

2003-06-25 Thread Fabiano de O. Lucchese
Hi, Ted.

I hadn't tryied this, and it has worked on IE 6 and
Opera 7.1, but not on Netscape 7 !

Do you know if this syntax isn't 100 % compliant to
the JavaScript standard or if Netscape has
implementation problems ?

Thank you very much anyway.

FLu-X

--- Jones, Ted [EMAIL PROTECTED] wrote:
 Have you tried:
 

onclick=alert(document.testForm.elements['att[0]'].value)
 
 ?
 
 
 -Original Message-
 From: Fabiano de O. Lucchese
 [mailto:[EMAIL PROTECTED]
 Sent: Wednesday, June 25, 2003 1:53 PM
 To: [EMAIL PROTECTED]
 Subject: Indexed properties and JavaScript
 
 
 Hi All,
 
 I've been trying to develop a Struts based web site
 and got stuck by the following problem: I have
 defined
 a form bean that contains indexed properties; thus,
 I'm supposed to use squared brackets [x] to refer
 to
 the individual elements of each of these array-like
 properties into my HTML/JSP page; on the other
 hand,
 I also had to embbed some javascript code in this
 page
 in order to enlighten the server-side processing.
 The
 problem is that I just can't use javascript code
 along
 with array-like properties because the brackets
 used
 by them seem to conflict with the javascript syntax.
 
 The following sample code reproduces this problem:
 
 html
 head
 titletest/title
 /head
 
 body
 form action=/test method=GET
 name=testForm
 input type=text
 name=att[0]
 input type=button
 onclick=alert(document.testForm.att[0])
 value=test
 /form
 /body
 /html
 
 and the error message is something like:
 document.testForm.att.0 is null or is not an
 object.
 
 One should notice that when the index reference [0]
 is
 deleted, the page works fine.
 
 Does anyone here has any experience with this
 problem
 ?
 
 Thanks in advance.
 
 FLu-X
 
 
 __
 Do you Yahoo!?
 SBC Yahoo! DSL - Now only $29.95 per month!
 http://sbc.yahoo.com
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 
 
 
 Confidentiality Warning:  This e-mail contains
 information intended only for the use of the
 individual or entity named above.  If the reader of
 this e-mail is not the intended recipient or the
 employee or agent responsible for delivering it to
 the intended recipient, any dissemination,
 publication or copying of this e-mail is strictly
 prohibited. The sender does not accept any
 responsibility for any loss, disruption or damage to
 your data or computer system that may occur while
 using data contained in, or transmitted with, this
 e-mail.   If you have received this e-mail in error,
 please immediately notify us by return e-mail. 
 Thank you.
 
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed properties and JavaScript

2003-06-25 Thread Kruse, Matt
 I hadn't tryied this, and it has worked on IE 6 and
 Opera 7.1, but not on Netscape 7 !

Try this instead:

document.forms['testForm']['att[0]'].value

That should work in any browser.

Matt Kruse


RE: Indexed properties and JavaScript

2003-06-25 Thread Fabiano de O. Lucchese
Perfect !
Thank you and Ted.

FLu-X

--- Kruse, Matt [EMAIL PROTECTED] wrote:
  I hadn't tryied this, and it has worked on IE 6
 and
  Opera 7.1, but not on Netscape 7 !
 
 Try this instead:
 
 document.forms['testForm']['att[0]'].value
 
 That should work in any browser.
 
 Matt Kruse
 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: indexed properties.

2003-05-29 Thread Andrew Hill
The fields name is name[0] right?

So in javascript you cant use something like document.forms[0].name[0] so
you will need to use the alternative javascript notation to get at your
field:

document.forms[0].elements['name[0]']

If you need to change the way indexed fields are done in struts however, Im
afraid I dont have the answer. :-(

-Original Message-
From: Abhinav (Cognizant) [mailto:[EMAIL PROTECTED]
Sent: Thursday, 29 May 2003 17:11
To: Struts Users Mailing List
Subject: indexed properties.


Will someone please tell me how to override indexed naming (like name[0],
name[1], name[2])
in my form when my form bean has
attribute
String [] name
and methods
getName(int index), setName(int index, String nm).

thanx, coz its really urgent.
I need this b'coz i cant validate field named name[0] in javascript




-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties with DynaActionForm Problems (forgot versions)

2003-03-18 Thread Josh Rayls
JDK 1.4.1
Struts 1.1 Nightly
JSTL 1.0.3


RE: Indexed Properties with DynaActionForm Problems

2003-03-18 Thread Karr, David
Are you using Struts-EL?  You can't reference EL expressions in Struts
tags, just Struts-EL.

 -Original Message-
 From: Josh Rayls [mailto:[EMAIL PROTECTED]
 
 I have been struggling with this for a couple of days now.  I've
scoured
 the
 archives from top to bottom, and I've found some useful tidbits, but
 nothing
 that directly addresses my dilemma.  Then again, maybe I'm just not
 getting
 it!
 
 I get an IndexOutOfBoundsException each time.  I want to be able to
have
 an
 arbitrary numbers of rows in the form and then be able to construct
beans
 from the rows in my action class.
 
 Any help would be greatly appreciated.  I'm going to have very little
hair
 left when this is done
 
 -Josh
 
 Code is below:
 
 JSP ---
 
 !-- Begin table body data --
 tbody
  c:set var=count value=-1/
  c:forEach items=${collection} var=dayPart
   c:set var=count value=${count + 1}/
   tr
td
 html:hidden property=id value=${dayPart.id}
indexed=true/
 html:hidden property=status value=${dayPart.status}
 indexed=true/
 html:hidden property=deleteable
value=${dayPart.deleteable}
 indexed=true/
 html:text property=code size=3 maxlength=3
 value=${dayPart.code} indexed=true/
/td
td
 html:text property=name size=16 value=${dayPart.name}
 indexed=true/
/td
td
 html:text property=beginTime maxlength=4 size=10
 value=${dayPart.beginTime} onblur=check24Hours(this)
indexed=true/
/td
td
 html:text property=endTime maxlength=4 size=10
 value=${dayPart.endTime} onblur=check24Hours(this)
indexed=true/
/td
td
 c:if test=${dayPart.deleteable}
  ct:isAuthorized screen=68 control=30
   html:link
 href=javascript:post('delete','null','${dayPart.id}');
html:img src=images/delete.gif border=0/
   /html:link
  /ct:isAuthorized
 /c:if
/td
   /tr
  /c:forEach
  html:hidden property=rows value=${count}/
 /tbody
 !-- End table body data --
 
 Action -
 
 // instance variables
 ActionErrors errors = new ActionErrors();
 Collection c = new ArrayList();
 int rows = ((Integer)PropertyUtils.getProperty(actionForm,
 rows)).intValue();
 
 // populate the collection with day parts
 DayPart dayPart = null;
 PropertyDescriptor[] props =
 PropertyUtils.getPropertyDescriptors(DayPart.class);
 for (int x=0; xrows; x++) {
   dayPart = new DayPart();
   for (int i=0; iprops.length; i++) {
 PropertyUtils.getIndexedProperty(actionForm,
props[i].getName(),
 x);
   }
   // add the new day part to the collection
   c.add(dayPart);
 }
 
 try {
   CorporateManager manager = JNDIUtil.createCorporateManager();
   manager.updateDayParts(c);
 } catch (SetupException se) {
   LogManager.error(this.getClass(), There has been a problem
updating
 dayparts., se);
   errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(The day
parts
 could not be updated.));
 }
 
 // forward request
 if (errors.isEmpty()) {
   return actionMapping.findForward(view);
 } else {
   this.saveErrors(request, errors);
   return actionMapping.findForward(view);
 }
 
 Struts-Config.xml 
 
   form-bean name=daypartForm
 type=org.apache.struts.action.DynaActionForm
form-property name=action type=java.lang.String/
form-property name=sortType
type=java.lang.String/
form-property name=id type=java.util.ArrayList/
form-property name=status
type=java.util.ArrayList/
form-property name=deleteable
 type=java.util.ArrayList/
form-property name=code type=java.util.ArrayList/
form-property name=name type=java.util.ArrayList/
form-property name=beginTime
 type=java.util.ArrayList/
form-property name=endTime
type=java.util.ArrayList/
form-property name=rows type=java.lang.Integer/
   /form-bean

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties with DynaActionForm Problems

2003-03-18 Thread Josh Rayls
Yep.  Using Struts-EL.

-Original Message-
From: Karr, David [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 4:16 PM
To: Struts Users Mailing List
Subject: RE: Indexed Properties with DynaActionForm Problems


Are you using Struts-EL?  You can't reference EL expressions in Struts
tags, just Struts-EL.

 -Original Message-
 From: Josh Rayls [mailto:[EMAIL PROTECTED]
 
 I have been struggling with this for a couple of days now.  I've
scoured
 the
 archives from top to bottom, and I've found some useful tidbits, but
 nothing
 that directly addresses my dilemma.  Then again, maybe I'm just not
 getting
 it!
 
 I get an IndexOutOfBoundsException each time.  I want to be able to
have
 an
 arbitrary numbers of rows in the form and then be able to construct
beans
 from the rows in my action class.
 
 Any help would be greatly appreciated.  I'm going to have very little
hair
 left when this is done
 
 -Josh
 
 Code is below:
 
 JSP ---
 
 !-- Begin table body data --
 tbody
  c:set var=count value=-1/
  c:forEach items=${collection} var=dayPart
   c:set var=count value=${count + 1}/
   tr
td
 html:hidden property=id value=${dayPart.id}
indexed=true/
 html:hidden property=status value=${dayPart.status}
 indexed=true/
 html:hidden property=deleteable
value=${dayPart.deleteable}
 indexed=true/
 html:text property=code size=3 maxlength=3
 value=${dayPart.code} indexed=true/
/td
td
 html:text property=name size=16 value=${dayPart.name}
 indexed=true/
/td
td
 html:text property=beginTime maxlength=4 size=10
 value=${dayPart.beginTime} onblur=check24Hours(this)
indexed=true/
/td
td
 html:text property=endTime maxlength=4 size=10
 value=${dayPart.endTime} onblur=check24Hours(this)
indexed=true/
/td
td
 c:if test=${dayPart.deleteable}
  ct:isAuthorized screen=68 control=30
   html:link
 href=javascript:post('delete','null','${dayPart.id}');
html:img src=images/delete.gif border=0/
   /html:link
  /ct:isAuthorized
 /c:if
/td
   /tr
  /c:forEach
  html:hidden property=rows value=${count}/
 /tbody
 !-- End table body data --
 
 Action -
 
 // instance variables
 ActionErrors errors = new ActionErrors();
 Collection c = new ArrayList();
 int rows = ((Integer)PropertyUtils.getProperty(actionForm,
 rows)).intValue();
 
 // populate the collection with day parts
 DayPart dayPart = null;
 PropertyDescriptor[] props =
 PropertyUtils.getPropertyDescriptors(DayPart.class);
 for (int x=0; xrows; x++) {
   dayPart = new DayPart();
   for (int i=0; iprops.length; i++) {
 PropertyUtils.getIndexedProperty(actionForm,
props[i].getName(),
 x);
   }
   // add the new day part to the collection
   c.add(dayPart);
 }
 
 try {
   CorporateManager manager = JNDIUtil.createCorporateManager();
   manager.updateDayParts(c);
 } catch (SetupException se) {
   LogManager.error(this.getClass(), There has been a problem
updating
 dayparts., se);
   errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(The day
parts
 could not be updated.));
 }
 
 // forward request
 if (errors.isEmpty()) {
   return actionMapping.findForward(view);
 } else {
   this.saveErrors(request, errors);
   return actionMapping.findForward(view);
 }
 
 Struts-Config.xml 
 
   form-bean name=daypartForm
 type=org.apache.struts.action.DynaActionForm
form-property name=action type=java.lang.String/
form-property name=sortType
type=java.lang.String/
form-property name=id type=java.util.ArrayList/
form-property name=status
type=java.util.ArrayList/
form-property name=deleteable
 type=java.util.ArrayList/
form-property name=code type=java.util.ArrayList/
form-property name=name type=java.util.ArrayList/
form-property name=beginTime
 type=java.util.ArrayList/
form-property name=endTime
type=java.util.ArrayList/
form-property name=rows type=java.lang.Integer/
   /form-bean

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: Indexed Properties with DynaActionForm Problems

2003-03-18 Thread Karr, David
It would be hard for us to figure out anything without any description
of what really happens.  Do you have an exception stack trace?

You could really help yourself out by setting this up in a JPDA debugger
and really tracking exactly what happens at the point of the error (and
before).

 -Original Message-
 From: Josh Rayls [mailto:[EMAIL PROTECTED]
 
 Hello,
 
 I have been struggling with this for a couple of days now.  I've
scoured
 the
 archives from top to bottom, and I've found some useful tidbits, but
 nothing
 that directly addresses my dilemma.  Then again, maybe I'm just not
 getting
 it!
 
 I get an IndexOutOfBoundsException each time.  I want to be able to
have
 an
 arbitrary numbers of rows in the form and then be able to construct
beans
 from the rows in my action class.
 
 Any help would be greatly appreciated.  I'm going to have very little
hair
 left when this is done
 
 -Josh
 
 Code is below:
 
 
 JSP ---
 
 !-- Begin table body data --
 tbody
  c:set var=count value=-1/
  c:forEach items=${collection} var=dayPart
   c:set var=count value=${count + 1}/
   tr
td
 html:hidden property=id value=${dayPart.id}
indexed=true/
 html:hidden property=status value=${dayPart.status}
 indexed=true/
 html:hidden property=deleteable
value=${dayPart.deleteable}
 indexed=true/
 html:text property=code size=3 maxlength=3
 value=${dayPart.code} indexed=true/
/td
td
 html:text property=name size=16 value=${dayPart.name}
 indexed=true/
/td
td
 html:text property=beginTime maxlength=4 size=10
 value=${dayPart.beginTime} onblur=check24Hours(this)
indexed=true/
/td
td
 html:text property=endTime maxlength=4 size=10
 value=${dayPart.endTime} onblur=check24Hours(this)
indexed=true/
/td
td
 c:if test=${dayPart.deleteable}
  ct:isAuthorized screen=68 control=30
   html:link
 href=javascript:post('delete','null','${dayPart.id}');
html:img src=images/delete.gif border=0/
   /html:link
  /ct:isAuthorized
 /c:if
/td
   /tr
  /c:forEach
  html:hidden property=rows value=${count}/
 /tbody
 !-- End table body data --
 
 Action -
 
 // instance variables
 ActionErrors errors = new ActionErrors();
 Collection c = new ArrayList();
 int rows = ((Integer)PropertyUtils.getProperty(actionForm,
 rows)).intValue();
 
 // populate the collection with day parts
 DayPart dayPart = null;
 PropertyDescriptor[] props =
 PropertyUtils.getPropertyDescriptors(DayPart.class);
 for (int x=0; xrows; x++) {
   dayPart = new DayPart();
   for (int i=0; iprops.length; i++) {
 PropertyUtils.getIndexedProperty(actionForm,
props[i].getName(),
 x);
   }
   // add the new day part to the collection
   c.add(dayPart);
 }
 
 try {
   CorporateManager manager = JNDIUtil.createCorporateManager();
   manager.updateDayParts(c);
 } catch (SetupException se) {
   LogManager.error(this.getClass(), There has been a problem
updating
 dayparts., se);
   errors.add(ActionErrors.GLOBAL_ERROR, new ActionError(The day
parts
 could not be updated.));
 }
 
 // forward request
 if (errors.isEmpty()) {
   return actionMapping.findForward(view);
 } else {
   this.saveErrors(request, errors);
   return actionMapping.findForward(view);
 }
 
 Struts-Config.xml 
 
   form-bean name=daypartForm
 type=org.apache.struts.action.DynaActionForm
form-property name=action type=java.lang.String/
form-property name=sortType
type=java.lang.String/
form-property name=id type=java.util.ArrayList/
form-property name=status
type=java.util.ArrayList/
form-property name=deleteable
 type=java.util.ArrayList/
form-property name=code type=java.util.ArrayList/
form-property name=name type=java.util.ArrayList/
form-property name=beginTime
 type=java.util.ArrayList/
form-property name=endTime
type=java.util.ArrayList/
form-property name=rows type=java.lang.Integer/
   /form-bean

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



RE: Indexed Properties with DynaActionForm Problems

2003-03-18 Thread Josh Rayls
m t_daypart order by begin_time asc
Mar 18, 2003 4:00:37 PM EST Error HTTP 101017
[ServletContext(id=6914328,name=ctweb.war,context-path=)] Root cause
vletException
java.lang.IndexOutOfBoundsException: Index: 2, Size: 0
at java.util.ArrayList.RangeCheck(ArrayList.java:508)
at java.util.ArrayList.set(ArrayList.java:336)
at
org.apache.struts.action.DynaActionForm.set(DynaActionForm.java:460)
at
org.apache.commons.beanutils.PropertyUtilsBean.setIndexedProperty(PropertyUt
ilsBean.java:1373)
at
org.apache.commons.beanutils.BeanUtilsBean.setProperty(BeanUtilsBean.java:10
23)
at
org.apache.commons.beanutils.BeanUtilsBean.populate(BeanUtilsBean.java:818)
at
org.apache.commons.beanutils.BeanUtils.populate(BeanUtils.java:343)
at
org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1136)
at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
ava:815)
at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1421)
at
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:518)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at
weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(Servle
tStubImpl.java:1058)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:401)
at
weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java
:306)
at
weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(W
ebAppServletContext.java:5445)
at
weblogic.security.service.SecurityServiceManager.runAs(SecurityServiceManage
r.java:780)
at
weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletCo
ntext.java:3105)
at
weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java
:2588)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:213)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:189)

I'll give the debugger a shot and see what happens.

-Josh

-Original Message-
From: Karr, David [mailto:[EMAIL PROTECTED]
Sent: Tuesday, March 18, 2003 4:32 PM
To: Struts Users Mailing List
Subject: RE: Indexed Properties with DynaActionForm Problems


It would be hard for us to figure out anything without any description
of what really happens.  Do you have an exception stack trace?

You could really help yourself out by setting this up in a JPDA debugger
and really tracking exactly what happens at the point of the error (and
before).

 -Original Message-
 From: Josh Rayls [mailto:[EMAIL PROTECTED]
 
 Hello,
 
 I have been struggling with this for a couple of days now.  I've
scoured
 the
 archives from top to bottom, and I've found some useful tidbits, but
 nothing
 that directly addresses my dilemma.  Then again, maybe I'm just not
 getting
 it!
 
 I get an IndexOutOfBoundsException each time.  I want to be able to
have
 an
 arbitrary numbers of rows in the form and then be able to construct
beans
 from the rows in my action class.
 
 Any help would be greatly appreciated.  I'm going to have very little
hair
 left when this is done
 
 -Josh
 
 Code is below:
 
 
 JSP ---
 
 !-- Begin table body data --
 tbody
  c:set var=count value=-1/
  c:forEach items=${collection} var=dayPart
   c:set var=count value=${count + 1}/
   tr
td
 html:hidden property=id value=${dayPart.id}
indexed=true/
 html:hidden property=status value=${dayPart.status}
 indexed=true/
 html:hidden property=deleteable
value=${dayPart.deleteable}
 indexed=true/
 html:text property=code size=3 maxlength=3
 value=${dayPart.code} indexed=true/
/td
td
 html:text property=name size=16 value=${dayPart.name}
 indexed=true/
/td
td
 html:text property=beginTime maxlength=4 size=10
 value=${dayPart.beginTime} onblur=check24Hours(this)
indexed=true/
/td
td
 html:text property=endTime maxlength=4 size=10
 value=${dayPart.endTime} onblur=check24Hours(this)
indexed=true/
/td
td
 c:if test=${dayPart.deleteable}
  ct:isAuthorized screen=68 control=30
   html:link
 href=javascript:post('delete','null','${dayPart.id}');
html:img src=images/delete.gif border=0/
   /html:link
  /ct:isAuthorized
 /c:if
/td
   /tr
  /c:forEach
  html:hidden property=rows value=${count}/
 /tbody
 !-- End table body data --
 
 Action -
 
 // instance variables
 ActionErrors errors = new ActionErrors();
 Collection c = new ArrayList();
 int rows = ((Integer)PropertyUtils.getProperty(actionForm,
 rows)).intValue

RE: Indexed properties and form

2003-02-12 Thread Chen, Gin
umm is my email program messed up or does anyone else here see the same
thing.
% int i = ; %
?? I dont see how that works.
Shouldnt it be more like:
% int i = 0; %

-Tim

-Original Message-
From: Samir Shah [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 11, 2003 9:32 PM
To: Struts Users Mailing List
Subject: Re: Indexed properties and form


Actually i is just another variable I am using to
display to the user the number of the row.  It is
declared in another scriplet as

% int i = ; %

--- Evan Schnell [EMAIL PROTECTED] wrote:
 Samir Shah wrote:
 
 Hi,
 
 I have a JSP page that outputs data using a
 Collection
 using the following section
 
 logic:iterate id=lifeBenefit name=lifeBenefits
  type=com.quote.dao.BenefitLineItem
 indexId=classNum
   
 
 Where do you declare i?  I think you need to use
 
   td class=formtext %=classNum %/td
 
 instead of...
 
   td class=formtext %=i %/td
   % i++; %
 
 Regards, Evan.
 
 
 
   
 
 
 
 -- 
 Evan Schnell, Technical Lead
 nVISIA, Twin Cities  Digital Architecture and
 Construction
 7701 France Ave. S, Edina, MN 55435
 Voice: 952.837.2577 -- Fax: 952.837.2578 -- Mobile:
 612.232.5972
 
 

 ATTACHMENT part 2 application/x-pkcs7-signature
name=smime.p7s



=
-Samir Shah

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Indexed properties and form

2003-02-12 Thread Samir Shah
I meant to say 

% int i = 0; %

The page display correctly.  The problem is accessing
the variable in the ActionForm.  How do I declare the
form variables in the ActionForm to gain access to
them

Thanks,
Samir
--- Chen, Gin [EMAIL PROTECTED] wrote:
 umm is my email program messed up or does anyone
 else here see the same
 thing.
 % int i = ; %
 ?? I dont see how that works.
 Shouldnt it be more like:
 % int i = 0; %
 
 -Tim
 
 -Original Message-
 From: Samir Shah [mailto:[EMAIL PROTECTED]]
 Sent: Tuesday, February 11, 2003 9:32 PM
 To: Struts Users Mailing List
 Subject: Re: Indexed properties and form
 
 
 Actually i is just another variable I am using to
 display to the user the number of the row.  It is
 declared in another scriplet as
 
 % int i = ; %
 
 --- Evan Schnell [EMAIL PROTECTED] wrote:
  Samir Shah wrote:
  
  Hi,
  
  I have a JSP page that outputs data using a
  Collection
  using the following section
  
  logic:iterate id=lifeBenefit
 name=lifeBenefits
 type=com.quote.dao.BenefitLineItem
  indexId=classNum

  
  Where do you declare i?  I think you need to use
  
  td class=formtext %=classNum %/td
  
  instead of...
  
  td class=formtext %=i %/td
  % i++; %
  
  Regards, Evan.
  
  
  

  
  
  
  -- 
  Evan Schnell, Technical Lead
  nVISIA, Twin Cities  Digital Architecture and
  Construction
  7701 France Ave. S, Edina, MN 55435
  Voice: 952.837.2577 -- Fax: 952.837.2578 --
 Mobile:
  612.232.5972
  
  
 
  ATTACHMENT part 2 application/x-pkcs7-signature
 name=smime.p7s
 
 
 
 =
 -Samir Shah
 
 __
 Do you Yahoo!?
 Yahoo! Shopping - Send Flowers for Valentine's Day
 http://shopping.yahoo.com
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 

-
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 


__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Indexed properties and form

2003-02-11 Thread Evan Schnell
Samir Shah wrote:


Hi,

I have a JSP page that outputs data using a Collection
using the following section

logic:iterate id=lifeBenefit name=lifeBenefits
	type=com.quote.dao.BenefitLineItem
indexId=classNum
 

Where do you declare i?  I think you need to use

	td class=formtext %=classNum %/td

instead of...

	td class=formtext %=i %/td
	% i++; %

Regards, Evan.




 



--
Evan Schnell, Technical Lead
nVISIA, Twin Cities  Digital Architecture and Construction
7701 France Ave. S, Edina, MN 55435
Voice: 952.837.2577 -- Fax: 952.837.2578 -- Mobile: 612.232.5972




smime.p7s
Description: S/MIME Cryptographic Signature


Re: Indexed properties and form

2003-02-11 Thread Samir Shah
Actually i is just another variable I am using to
display to the user the number of the row.  It is
declared in another scriplet as

% int i = ; %

--- Evan Schnell [EMAIL PROTECTED] wrote:
 Samir Shah wrote:
 
 Hi,
 
 I have a JSP page that outputs data using a
 Collection
 using the following section
 
 logic:iterate id=lifeBenefit name=lifeBenefits
  type=com.quote.dao.BenefitLineItem
 indexId=classNum
   
 
 Where do you declare i?  I think you need to use
 
   td class=formtext %=classNum %/td
 
 instead of...
 
   td class=formtext %=i %/td
   % i++; %
 
 Regards, Evan.
 
 
 
   
 
 
 
 -- 
 Evan Schnell, Technical Lead
 nVISIA, Twin Cities  Digital Architecture and
 Construction
 7701 France Ave. S, Edina, MN 55435
 Voice: 952.837.2577 -- Fax: 952.837.2578 -- Mobile:
 612.232.5972
 
 

 ATTACHMENT part 2 application/x-pkcs7-signature
name=smime.p7s



=
-Samir Shah

__
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Indexed Properties and Population

2003-01-17 Thread Jeff_Mychasiw

David says:
One implementation that should work based on your example
as long as you are willing to create a child factory is in the commons
collection package and is ListUtils.lazyList, which takes a List and
factory.

I have used this as well, in combination with the nested tag library.
We have  a page that displays and updates a List of Value Objects where
each have two internal Lists of Value Objects.
The structure of value objects are sent to me from the back end as such:

CustomerList
  CustomerVo 1
creditVo1   invoiceVo1
creditVo2   invoiceVo2
.   .

  CustomerVo2
creditVo1   invoiceVo1
creditVo2   invoiceVo2
.   .


I would be curious to know  this would done without the nested tags and
lazy list.








David Morris [EMAIL PROTECTED] on 01/16/2003 03:50:10 PM

Please respond to Struts Users Mailing List
   [EMAIL PROTECTED]

To:[EMAIL PROTECTED]
cc:

Subject:Re: Indexed Properties and Population


Matt,

You really don't need to know how many there are, just create them
on demand. You can intercept gets and auto-extend the underlying
Collection. One implementation that should work based on your example
as long as you are willing to create a child factory is in the commons

collection package and is ListUtils.lazyList, which takes a List and
factory.

David Morris

 [EMAIL PROTECTED] 01/16/03 02:31PM 
I have an ArrayList on a form... let's call the form Parent and the
ArrayList Children.

If I have:

private ArrayList children;

public void setChildren(int index, ChildForm childForm) {
 this.children.set(index, childForm);
}

Then saving my form results in a NPE for BeanUtils.copyProperties.  If
I
create a whole bunch of objects in the ArrayList in the constructor -
I
avoid this problem:

public ParentForm () {
children = new ArrayList(100);
for (int i=0; i  100; i++) {
children.add(new ChildForm());
}

But I'm guessing that this fits better into the reset(mapping,
request)
method of my form.  My question is - how do I determine how many there
are?
Is there something in the request this this information - or should I
set a
hidden field with the number of children?

Thanks,

Matt

--
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]








--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties and Population

2003-01-17 Thread Raible, Matt
Here's how I did it:

On my Form:

public ArrayList getKids() {
returns kids;
}

public void setKids(ArrayList kids) {
this.kids = kids;
}

public int getKidsSize() {
return kids.size();
}

In my JSP:

nested:iterate property=kids
...
nested:text property=name/
...
/nested:iterate
html:hidden property=kidsSize/

On my form (relevant for saving)

public void reset(ActionMapping mapping, HttpServletRequest request) {
// make the kids ArrayList the proper size and populate with
// empty objects
int kidsSize = Integer.parseInt(request.getParameter(kidsSize));
kids = new ArrayList(kidsSize);
for (int i=0; i  kidsSize; i++) {
kids.add(new KidForm());
}
}

This seems to work great for me.  Any other suggestions/methods are
encouraged ;)  Is it lunchtime (beertime) yet?

HTH,

Matt

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Friday, January 17, 2003 6:52 AM
To: Struts Users Mailing List
Subject: Re: Indexed Properties and Population



David says:
One implementation that should work based on your example
as long as you are willing to create a child factory is in the commons
collection package and is ListUtils.lazyList, which takes a List and
factory.

I have used this as well, in combination with the nested tag library.
We have  a page that displays and updates a List of Value Objects where
each have two internal Lists of Value Objects.
The structure of value objects are sent to me from the back end as such:

CustomerList
  CustomerVo 1
creditVo1   invoiceVo1
creditVo2   invoiceVo2
.   .

  CustomerVo2
creditVo1   invoiceVo1
creditVo2   invoiceVo2
.   .


I would be curious to know  this would done without the nested tags and
lazy list.








David Morris [EMAIL PROTECTED] on 01/16/2003 03:50:10 PM

Please respond to Struts Users Mailing List
   [EMAIL PROTECTED]

To:[EMAIL PROTECTED]
cc:

Subject:Re: Indexed Properties and Population


Matt,

You really don't need to know how many there are, just create them
on demand. You can intercept gets and auto-extend the underlying
Collection. One implementation that should work based on your example
as long as you are willing to create a child factory is in the commons

collection package and is ListUtils.lazyList, which takes a List and
factory.

David Morris

 [EMAIL PROTECTED] 01/16/03 02:31PM 
I have an ArrayList on a form... let's call the form Parent and the
ArrayList Children.

If I have:

private ArrayList children;

public void setChildren(int index, ChildForm childForm) {
 this.children.set(index, childForm);
}

Then saving my form results in a NPE for BeanUtils.copyProperties.  If
I
create a whole bunch of objects in the ArrayList in the constructor -
I
avoid this problem:

public ParentForm () {
children = new ArrayList(100);
for (int i=0; i  100; i++) {
children.add(new ChildForm());
}

But I'm guessing that this fits better into the reset(mapping,
request)
method of my form.  My question is - how do I determine how many there
are?
Is there something in the request this this information - or should I
set a
hidden field with the number of children?

Thanks,

Matt

--
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]








--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties and Population

2003-01-16 Thread David Morris
Matt,

You really don't need to know how many there are, just create them 
on demand. You can intercept gets and auto-extend the underlying 
Collection. One implementation that should work based on your example 
as long as you are willing to create a child factory is in the commons

collection package and is ListUtils.lazyList, which takes a List and
factory. 

David Morris

 [EMAIL PROTECTED] 01/16/03 02:31PM 
I have an ArrayList on a form... let's call the form Parent and the
ArrayList Children.

If I have:

private ArrayList children;

public void setChildren(int index, ChildForm childForm) {
this.children.set(index, childForm);
}

Then saving my form results in a NPE for BeanUtils.copyProperties.  If
I
create a whole bunch of objects in the ArrayList in the constructor -
I
avoid this problem:

public ParentForm () {
children = new ArrayList(100);
for (int i=0; i  100; i++) {
children.add(new ChildForm());
}

But I'm guessing that this fits better into the reset(mapping,
request)
method of my form.  My question is - how do I determine how many there
are?
Is there something in the request this this information - or should I
set a
hidden field with the number of children?

Thanks,

Matt

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties and Population

2003-01-16 Thread Mark Galbreath
int elements = children.size()
?

Where are you defining this method?


-Original Message-
From: Raible, Matt [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 16, 2003 4:31 PM

If I have:

private ArrayList children;

public void setChildren(int index, ChildForm childForm) {
this.children.set(index, childForm);
}

My question is - how do I determine how many there are? Is there something
in the request this this information - or should I set a hidden field with
the number of children?



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties and Population

2003-01-16 Thread Kris Schneider
Just make sure you've got a way to cap the max number you auto-create...

Quoting David Morris [EMAIL PROTECTED]:

 Matt,
 
 You really don't need to know how many there are, just create them 
 on demand. You can intercept gets and auto-extend the underlying 
 Collection. One implementation that should work based on your example 
 as long as you are willing to create a child factory is in the commons
 
 collection package and is ListUtils.lazyList, which takes a List and
 factory. 
 
 David Morris
 
  [EMAIL PROTECTED] 01/16/03 02:31PM 
 I have an ArrayList on a form... let's call the form Parent and the
 ArrayList Children.
 
 If I have:
 
 private ArrayList children;
 
 public void setChildren(int index, ChildForm childForm) {
   this.children.set(index, childForm);
 }
 
 Then saving my form results in a NPE for BeanUtils.copyProperties.  If
 I
 create a whole bunch of objects in the ArrayList in the constructor -
 I
 avoid this problem:
 
 public ParentForm () {
 children = new ArrayList(100);
 for (int i=0; i  100; i++) {
 children.add(new ChildForm());
 }
 
 But I'm guessing that this fits better into the reset(mapping,
 request)
 method of my form.  My question is - how do I determine how many there
 are?
 Is there something in the request this this information - or should I
 set a
 hidden field with the number of children?
 
 Thanks,
 
 Matt
 
 --
 To unsubscribe, e-mail:  
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]
 


-- 
Kris Schneider mailto:[EMAIL PROTECTED]
D.O.Tech   http://www.dotech.com/

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties and Population

2003-01-16 Thread Raible, Matt
I think what I'll do is to create a new method called getChildrenSize() that
does what Mark suggests below - then I'll put this as a hidden field on my
form.  Since all my form's contents are dumped into a JSP (and gone), I've
lost the size of the children - unless I save it as a hidden field, or count
them in my nested:iterate tag.  So then in my reset method on the form, I
can create x number of children and do set(index, form).

Thanks,

Matt

-Original Message-
From: Mark Galbreath [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 16, 2003 2:57 PM
To: 'Struts Users Mailing List'
Subject: RE: Indexed Properties and Population


int elements = children.size()
?

Where are you defining this method?


-Original Message-
From: Raible, Matt [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 16, 2003 4:31 PM

If I have:

private ArrayList children;

public void setChildren(int index, ChildForm childForm) {
this.children.set(index, childForm);
}

My question is - how do I determine how many there are? Is there something
in the request this this information - or should I set a hidden field with
the number of children?



--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: indexed properties and form help needed

2002-11-13 Thread Karr, David
At end.

 -Original Message-
 From: Andy Kriger [mailto:akriger;greaterthanone.com]
 
 I have a DynaActionForm collecting credit card info. A user 
 can enter up to
 3 credit cards on the form. I want to collect this info in 
 the text fields
 and create new CreditCard objects automatically; ideally, I 
 would get a
 CreditCard[3] once the form is submitted (optionally an 
 ArrayList would be
 fine). I would like to use indexed properties (right now I'm 
 using hard
 coded property names), but I cannot figure out how to set this up.
 
 I am getting either a 'No collection found' error or a 
 'Cannot iterate over
 collection' error (depending on how I mess with this).
 
 What follows is rough code of what I'm trying to do.
 
 A CreditCard object has 5 fields with get/set methods for 
 each: type, name,
 number, expMonth, expYear.
 
 !-- JSP --
 html:form method='post' action='doSomething'
 logic:iterate id='index' property='creditCard' 
 name='registrationForm'
 length='3'
   html:select property='creditCard.type' name='index' 
 indexed='true'
   !-- some options --
   /html:select
   html:text property='creditCard.name' name='index' 
 indexed='true'
   html:text property='creditCard.number' name='index' 
 indexed='true'
   html:text property='creditCard.expMonth' name='index' 
 indexed='true'
   html:text property='creditCard.expYear' name='index' 
 indexed='true'
 /logic:iterate
 /html:form
 !-- Note: I have tried html:text with property='creditCard.field' and
 property='field' Neither worked --
 
 !-- struts-config.xml --
 form-bean name='registrationForm' type='DynaValidatorForm 
 dynamic='true'
   form-property name='creditCard' 
 type='my.package.CreditCard[]'/
 /form-bean

Note that I haven't compiled or run any of this.

I would first expect my loop to look more like this:

logic:iterate id='creditCard' property='creditCards' name='registrationForm'
   length='3'
 html:select name='creditCard' property='type' indexed='true'
  !-- some options --
 /html:select
 html:text name='creditCard' property='name' indexed='true'/
 html:text name='creditCard' property='number' indexed='true'/
 html:text name='creditCard' property='expMonth' indexed='true'/
 html:text name='creditCard' property='expYear' indexed='true'/
/logic:iterate

I would have accessors for name, number, expMonth and expYear in the 
CreditCard class.

At that point, I scratch my head, because I don't know how to represent indexed 
properties in DynaActionForms.  With a regular ActionForm, I would have the following 
in my registrationForm bean:

public  CreditCard getCreditCard(int index) { return (creditCards[index]); }
public  void  setCreditCard(int index, CreditCard creditCard) { creditCard[index] 
= creditCard; }
public  CreditCard[] getCreditCards() { return (creditCards); }

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




RE: indexed properties and form help needed

2002-11-13 Thread Andy Kriger
According to the docs for DynaActionForm, you indicate a property is indexed
by putting [] after the type name. What I think is going on is that the
property is not initalized when the iterator tries to access it, thus the
'No collection found'. But I don't know how to set this up so it works
correctly. Since Struts seems to handle just about everything else, it'd
surprise me if you couldn't iterate over a dynamic form property in order to
setup inputs.

thx

-Original Message-
From: Karr, David [mailto:david.karr;attws.com]
Sent: Wednesday, November 13, 2002 18:02
To: Struts Users Mailing List
Subject: RE: indexed properties and form help needed


At end.

 -Original Message-
 From: Andy Kriger [mailto:akriger;greaterthanone.com]

 I have a DynaActionForm collecting credit card info. A user
 can enter up to
 3 credit cards on the form. I want to collect this info in
 the text fields
 and create new CreditCard objects automatically; ideally, I
 would get a
 CreditCard[3] once the form is submitted (optionally an
 ArrayList would be
 fine). I would like to use indexed properties (right now I'm
 using hard
 coded property names), but I cannot figure out how to set this up.

 I am getting either a 'No collection found' error or a
 'Cannot iterate over
 collection' error (depending on how I mess with this).

 What follows is rough code of what I'm trying to do.

 A CreditCard object has 5 fields with get/set methods for
 each: type, name,
 number, expMonth, expYear.

 !-- JSP --
 html:form method='post' action='doSomething'
 logic:iterate id='index' property='creditCard'
 name='registrationForm'
 length='3'
   html:select property='creditCard.type' name='index'
 indexed='true'
   !-- some options --
   /html:select
   html:text property='creditCard.name' name='index'
 indexed='true'
   html:text property='creditCard.number' name='index'
 indexed='true'
   html:text property='creditCard.expMonth' name='index'
 indexed='true'
   html:text property='creditCard.expYear' name='index'
 indexed='true'
 /logic:iterate
 /html:form
 !-- Note: I have tried html:text with property='creditCard.field' and
 property='field' Neither worked --

 !-- struts-config.xml --
 form-bean name='registrationForm' type='DynaValidatorForm
 dynamic='true'
   form-property name='creditCard'
 type='my.package.CreditCard[]'/
 /form-bean

Note that I haven't compiled or run any of this.

I would first expect my loop to look more like this:

logic:iterate id='creditCard' property='creditCards'
name='registrationForm'
   length='3'
 html:select name='creditCard' property='type' indexed='true'
  !-- some options --
 /html:select
 html:text name='creditCard' property='name' indexed='true'/
 html:text name='creditCard' property='number' indexed='true'/
 html:text name='creditCard' property='expMonth' indexed='true'/
 html:text name='creditCard' property='expYear' indexed='true'/
/logic:iterate

I would have accessors for name, number, expMonth and expYear in the
CreditCard class.

At that point, I scratch my head, because I don't know how to represent
indexed properties in DynaActionForms.  With a regular ActionForm, I would
have the following in my registrationForm bean:

public  CreditCard getCreditCard(int index) { return
(creditCards[index]); }
public  void  setCreditCard(int index, CreditCard creditCard) {
creditCard[index] = creditCard; }
public  CreditCard[] getCreditCards() { return (creditCards); }

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



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




RE: Indexed Properties - soluce :-)

2002-07-18 Thread Arnaud HERITIER

Craig.

Can you give us some news about the JSR 127 ??

Do you have planned a draft for the JavaServer Faces ??

Thx

Arnaud

 -Message d'origine-
 De : Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
 Envoye : mercredi 17 juillet 2002 17:11
 A : Struts Users Mailing List
 Cc : [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
 Objet : RE: Indexed Properties - soluce :-)




 On Wed, 17 Jul 2002 [EMAIL PROTECTED] wrote:

  Date: Wed, 17 Jul 2002 15:30:38 +0200
  From: [EMAIL PROTECTED]
  Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
  To: [EMAIL PROTECTED],
   'Struts Users Mailing List' [EMAIL PROTECTED],
   [EMAIL PROTECTED]
  Cc: [EMAIL PROTECTED]
  Subject: RE: Indexed Properties - soluce :-)
 
  Hi there,
 
  Actually when you are looking at the stuff done in the JSTL
  all three ways pretty much work, because it contains a
  scripting language ;).
 
  Are there any plans on integrating it within Struts? I like
  both libraries very much, and I recall a discussion was going
  on a while ago about it?
 
  If it is done this would make it is either:
 
1. property = all I want to write
 
2. property = %= java expression %
 
3. property = ${myRadios[param.index]}
 

 My current thinking is that we'll make some variant of #3 available in
 Struts tags, in a release after 1.1.  But this will primarily be as a
 transition tool -- subsequent releases of Struts will be designed such
 that you should use JSTL tags directly, as opposed to the
 corresponding
 Struts tags in the bean and logic libraries.  For the html tags,
 we'll end up with JavaServer Faces tags when it's released.

(here with 'index' as a request variable ;))
 
  Manfred.

 Craig McClanahan



 
   -Original Message-
   From: Arnaud HERITIER [mailto:[EMAIL PROTECTED]]
   Sent: Wednesday, July 17, 2002 10:29 AM
   To: 'Struts Users Mailing List'; [EMAIL PROTECTED]
   Subject: RE: Indexed Properties - soluce :-)
  
  
   All suggestions are welcome Eddie.
  
   Your idea and your argumentations are good, but your proposed
   solution doesn't work :-(
  
   Explanations :
  
   In a taglib property you can use either a string value or a
   RunTime Expression (if allowed in the TLD).
  
   If you use a string you have something like :  property=all
   I want to write
  
   If you use a RT Expr you have something like :
   property=%=java expression%
  
   The tag libraries interpreter verify if the content of the
   property begins with %= and ends with % . In this case it
   suppose that it is a RT Expr and values it. In all other case
   it supposes that the content is a string.
  
   With your suggestion, property=myRadios[%= index %] the
   tag libraries interpretor see that there's not %= at the
   begining and % at the end. Then it passes the value
   myRadios[%= index %] as a string to the taglib.
  
   When the taglib get the content of property, it will analize
   it and see that it is a indexed property because of [..] but
   won't be able to interpret it and will launch an exception like :
  
   java.lang.IllegalArgumentException: Invalid indexed property
   'myRadios[%=index%]'
  
   However, it is important to say that your advice is totally
   good if you want to use a dynamic value in standard html tag.
  
   I you have another idea to clean my code, don't hesitate to
   propose it.
  
  
   Arnaud.
  
 


 --
 To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties - soluce :-)

2002-07-18 Thread Craig R. McClanahan



On Thu, 18 Jul 2002, Arnaud HERITIER wrote:

 Date: Thu, 18 Jul 2002 11:09:24 +0200
 From: Arnaud HERITIER [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED],
  [EMAIL PROTECTED]
 To: 'Struts Users Mailing List' [EMAIL PROTECTED]
 Subject: RE: Indexed Properties - soluce :-)

 Craig.

 Can you give us some news about the JSR 127 ??

 Do you have planned a draft for the JavaServer Faces ??


It is currently in Community Review in the JCP process, scheduled to end
on August 12.  Assuming positive votes by the JCP executive committee and
the JSR 127 expert group, the next phase after that is public review.

 Thx

 Arnaud


Craig


  -Message d'origine-
  De : Craig R. McClanahan [mailto:[EMAIL PROTECTED]]
  Envoye : mercredi 17 juillet 2002 17:11
  A : Struts Users Mailing List
  Cc : [EMAIL PROTECTED]; [EMAIL PROTECTED]; [EMAIL PROTECTED]
  Objet : RE: Indexed Properties - soluce :-)
 
 
 
 
  On Wed, 17 Jul 2002 [EMAIL PROTECTED] wrote:
 
   Date: Wed, 17 Jul 2002 15:30:38 +0200
   From: [EMAIL PROTECTED]
   Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
   To: [EMAIL PROTECTED],
'Struts Users Mailing List' [EMAIL PROTECTED],
[EMAIL PROTECTED]
   Cc: [EMAIL PROTECTED]
   Subject: RE: Indexed Properties - soluce :-)
  
   Hi there,
  
   Actually when you are looking at the stuff done in the JSTL
   all three ways pretty much work, because it contains a
   scripting language ;).
  
   Are there any plans on integrating it within Struts? I like
   both libraries very much, and I recall a discussion was going
   on a while ago about it?
  
   If it is done this would make it is either:
  
 1. property = all I want to write
  
 2. property = %= java expression %
  
 3. property = ${myRadios[param.index]}
  
 
  My current thinking is that we'll make some variant of #3 available in
  Struts tags, in a release after 1.1.  But this will primarily be as a
  transition tool -- subsequent releases of Struts will be designed such
  that you should use JSTL tags directly, as opposed to the
  corresponding
  Struts tags in the bean and logic libraries.  For the html tags,
  we'll end up with JavaServer Faces tags when it's released.
 
 (here with 'index' as a request variable ;))
  
   Manfred.
 
  Craig McClanahan
 
 
 
  
-Original Message-
From: Arnaud HERITIER [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, July 17, 2002 10:29 AM
To: 'Struts Users Mailing List'; [EMAIL PROTECTED]
Subject: RE: Indexed Properties - soluce :-)
   
   
All suggestions are welcome Eddie.
   
Your idea and your argumentations are good, but your proposed
solution doesn't work :-(
   
Explanations :
   
In a taglib property you can use either a string value or a
RunTime Expression (if allowed in the TLD).
   
If you use a string you have something like :  property=all
I want to write
   
If you use a RT Expr you have something like :
property=%=java expression%
   
The tag libraries interpreter verify if the content of the
property begins with %= and ends with % . In this case it
suppose that it is a RT Expr and values it. In all other case
it supposes that the content is a string.
   
With your suggestion, property=myRadios[%= index %] the
tag libraries interpretor see that there's not %= at the
begining and % at the end. Then it passes the value
myRadios[%= index %] as a string to the taglib.
   
When the taglib get the content of property, it will analize
it and see that it is a indexed property because of [..] but
won't be able to interpret it and will launch an exception like :
   
java.lang.IllegalArgumentException: Invalid indexed property
'myRadios[%=index%]'
   
However, it is important to say that your advice is totally
good if you want to use a dynamic value in standard html tag.
   
I you have another idea to clean my code, don't hesitate to
propose it.
   
   
Arnaud.
   
  
 
 
  --
  To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]


 --
 To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
 For additional commands, e-mail: mailto:[EMAIL PROTECTED]




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties - soluce :-)

2002-07-17 Thread Arnaud HERITIER

All suggestions are welcome Eddie.

Your idea and your argumentations are good, but your proposed solution
doesn't work :-(

Explanations :

In a taglib property you can use either a string value or a RunTime
Expression (if allowed in the TLD).

If you use a string you have something like :  property=all I want to
write

If you use a RT Expr you have something like : property=%=java
expression%

The tag libraries interpreter verify if the content of the property begins
with %= and ends with % .
In this case it suppose that it is a RT Expr and values it.
In all other case it supposes that the content is a string.

With your suggestion, property=myRadios[%= index %] the tag libraries
interpretor see that there's not %= at the begining and % at the end.
Then it passes the value myRadios[%= index %] as a string to the taglib.

When the taglib get the content of property, it will analize it and see that
it is a indexed property because of [..] but won't be able to interpret it
and will launch an exception like :

java.lang.IllegalArgumentException: Invalid indexed property
'myRadios[%=index%]'

However, it is important to say that your advice is totally good if you want
to use a dynamic value in standard html tag.

I you have another idea to clean my code, don't hesitate to propose it.


Arnaud.


 -Message d'origine-
 De : Eddie Bush [mailto:[EMAIL PROTECTED]]
 Envoye : mardi 16 juillet 2002 17:54
 A : Struts Users Mailing List
 Objet : Re: Indexed Properties - soluce :-)


 May I make a suggestion?  You're causing the implicit
 creation of many
 strings ... and doing it in a loop (bad).  Try this:

 html:form ...
 logic:iterate id=theRadio indexId=index name=myFormBean
 property=myRadios
 html:radio property=myRadios[%= index %] value=A/html:radio
 property=myRadios[%= index %] value=B/
 /logic:iterate
 /html:form

 This way, you don't have the implicit string creation (you
 get one every
 time you use the + to concatenate).  Object creation is slow :-( so
 don't do it if you don't have to.

 Regards,

 Eddie

 Arnaud HERITIER wrote:

 Ok I found myself a solution (it seems) :
 
 I need to modify the JSP page to index manually the property
 and I don't
 need to use the indexed=true which indexes the BEAN and
 not the property :
 html:form ...
 logic:iterate id=theRadio indexId=index name=myFormBean
 property=myRadios
 html:radio property=%=\myRadios[\+index+\]\%
 value=A/html:radio
 property=%=\myRadios[\+index+\]\% value=B/
 /logic:iterate
 /html:form
 
 Arnaud
 



 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]




RE: Indexed Properties - soluce :-)

2002-07-17 Thread mriem

Hi there,

Actually when you are looking at the stuff done in the JSTL
all three ways pretty much work, because it contains a
scripting language ;).

Are there any plans on integrating it within Struts? I like 
both libraries very much, and I recall a discussion was going
on a while ago about it?

If it is done this would make it is either:

  1. property = all I want to write
 
  2. property = %= java expression %

  3. property = ${myRadios[param.index]}
  
  (here with 'index' as a request variable ;))

Manfred.
 
 -Original Message-
 From: Arnaud HERITIER [mailto:[EMAIL PROTECTED]] 
 Sent: Wednesday, July 17, 2002 10:29 AM
 To: 'Struts Users Mailing List'; [EMAIL PROTECTED]
 Subject: RE: Indexed Properties - soluce :-)
 
 
 All suggestions are welcome Eddie.
 
 Your idea and your argumentations are good, but your proposed 
 solution doesn't work :-(
 
 Explanations :
 
 In a taglib property you can use either a string value or a 
 RunTime Expression (if allowed in the TLD).
 
 If you use a string you have something like :  property=all 
 I want to write
 
 If you use a RT Expr you have something like : 
 property=%=java expression%
 
 The tag libraries interpreter verify if the content of the 
 property begins with %= and ends with % . In this case it 
 suppose that it is a RT Expr and values it. In all other case 
 it supposes that the content is a string.
 
 With your suggestion, property=myRadios[%= index %] the 
 tag libraries interpretor see that there's not %= at the 
 begining and % at the end. Then it passes the value 
 myRadios[%= index %] as a string to the taglib.
 
 When the taglib get the content of property, it will analize 
 it and see that it is a indexed property because of [..] but 
 won't be able to interpret it and will launch an exception like :
 
 java.lang.IllegalArgumentException: Invalid indexed property 
 'myRadios[%=index%]'
 
 However, it is important to say that your advice is totally 
 good if you want to use a dynamic value in standard html tag.
 
 I you have another idea to clean my code, don't hesitate to 
 propose it.
 
 
 Arnaud.
 

attachment: winmail.dat
--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]


RE: Indexed Properties - soluce :-)

2002-07-17 Thread Craig R. McClanahan



On Wed, 17 Jul 2002 [EMAIL PROTECTED] wrote:

 Date: Wed, 17 Jul 2002 15:30:38 +0200
 From: [EMAIL PROTECTED]
 Reply-To: Struts Users Mailing List [EMAIL PROTECTED]
 To: [EMAIL PROTECTED],
  'Struts Users Mailing List' [EMAIL PROTECTED],
  [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: Indexed Properties - soluce :-)

 Hi there,

 Actually when you are looking at the stuff done in the JSTL
 all three ways pretty much work, because it contains a
 scripting language ;).

 Are there any plans on integrating it within Struts? I like
 both libraries very much, and I recall a discussion was going
 on a while ago about it?

 If it is done this would make it is either:

   1. property = all I want to write

   2. property = %= java expression %

   3. property = ${myRadios[param.index]}


My current thinking is that we'll make some variant of #3 available in
Struts tags, in a release after 1.1.  But this will primarily be as a
transition tool -- subsequent releases of Struts will be designed such
that you should use JSTL tags directly, as opposed to the corresponding
Struts tags in the bean and logic libraries.  For the html tags,
we'll end up with JavaServer Faces tags when it's released.

   (here with 'index' as a request variable ;))

 Manfred.

Craig McClanahan




  -Original Message-
  From: Arnaud HERITIER [mailto:[EMAIL PROTECTED]]
  Sent: Wednesday, July 17, 2002 10:29 AM
  To: 'Struts Users Mailing List'; [EMAIL PROTECTED]
  Subject: RE: Indexed Properties - soluce :-)
 
 
  All suggestions are welcome Eddie.
 
  Your idea and your argumentations are good, but your proposed
  solution doesn't work :-(
 
  Explanations :
 
  In a taglib property you can use either a string value or a
  RunTime Expression (if allowed in the TLD).
 
  If you use a string you have something like :  property=all
  I want to write
 
  If you use a RT Expr you have something like :
  property=%=java expression%
 
  The tag libraries interpreter verify if the content of the
  property begins with %= and ends with % . In this case it
  suppose that it is a RT Expr and values it. In all other case
  it supposes that the content is a string.
 
  With your suggestion, property=myRadios[%= index %] the
  tag libraries interpretor see that there's not %= at the
  begining and % at the end. Then it passes the value
  myRadios[%= index %] as a string to the taglib.
 
  When the taglib get the content of property, it will analize
  it and see that it is a indexed property because of [..] but
  won't be able to interpret it and will launch an exception like :
 
  java.lang.IllegalArgumentException: Invalid indexed property
  'myRadios[%=index%]'
 
  However, it is important to say that your advice is totally
  good if you want to use a dynamic value in standard html tag.
 
  I you have another idea to clean my code, don't hesitate to
  propose it.
 
 
  Arnaud.
 



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties - soluce :-)

2002-07-17 Thread mriem

Hi Craig,

Cool to hear that you are considering it ;). Can I help out
in any way? 

Manfred Riem

  If it is done this would make it is either:
 
1. property = all I want to write
 
2. property = %= java expression %
 
3. property = ${myRadios[param.index]}
 
 
 My current thinking is that we'll make some variant of #3 
 available in Struts tags, in a release after 1.1.  But this 
 will primarily be as a transition tool -- subsequent releases 
 of Struts will be designed such that you should use JSTL tags 
 directly, as opposed to the corresponding Struts tags in the 
 bean and logic libraries.  For the html tags, we'll end 
 up with JavaServer Faces tags when it's released.
 
(here with 'index' as a request variable ;))
 
  Manfred.
 
 Craig McClanahan


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties - soluce :-)

2002-07-17 Thread Craig R. McClanahan



On Wed, 17 Jul 2002 [EMAIL PROTECTED] wrote:

 Date: Wed, 17 Jul 2002 17:36:57 +0200
 From: [EMAIL PROTECTED]
 To: 'Craig R. McClanahan' [EMAIL PROTECTED],
  'Struts Users Mailing List' [EMAIL PROTECTED]
 Cc: [EMAIL PROTECTED]
 Subject: RE: Indexed Properties - soluce :-)

 Hi Craig,

 Cool to hear that you are considering it ;). Can I help out
 in any way?


Sure.

Short term -- help us get the remaining bugs in 1.1 swatted so we can
release it and pay the appropriate amount of attention to this :-).

Longer term -- subscribe to the STRUTS-DEV mailing list, where the plans
for the future of Struts will be discussed and hammered out.  Example
implementations of this sort of thing (either posted somewhere else or
perhaps in the contrib directory) would motivate more discussion about
exactly which tags and attributes this makes sense for.

 Manfred Riem


Craig


   If it is done this would make it is either:
  
 1. property = all I want to write
  
 2. property = %= java expression %
  
 3. property = ${myRadios[param.index]}
  
 
  My current thinking is that we'll make some variant of #3
  available in Struts tags, in a release after 1.1.  But this
  will primarily be as a transition tool -- subsequent releases
  of Struts will be designed such that you should use JSTL tags
  directly, as opposed to the corresponding Struts tags in the
  bean and logic libraries.  For the html tags, we'll end
  up with JavaServer Faces tags when it's released.
 
 (here with 'index' as a request variable ;))
  
   Manfred.
 
  Craig McClanahan




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties - soluce :-)

2002-07-17 Thread dhay



Why don't you use the Indexed property in the nightly builds?

David





Arnaud HERITIER [EMAIL PROTECTED] on 07/17/2002
04:29:00 AM

Please respond to Struts Users Mailing List
  [EMAIL PROTECTED]; Please respond to
  [EMAIL PROTECTED]

To:   'Struts Users Mailing List'
  [EMAIL PROTECTED],
  [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  RE: Indexed Properties - soluce :-)



All suggestions are welcome Eddie.

Your idea and your argumentations are good, but your proposed solution
doesn't work :-(

Explanations :

In a taglib property you can use either a string value or a RunTime
Expression (if allowed in the TLD).

If you use a string you have something like :  property=all I want to
write

If you use a RT Expr you have something like : property=%=java
expression%

The tag libraries interpreter verify if the content of the property begins
with %= and ends with % .
In this case it suppose that it is a RT Expr and values it.
In all other case it supposes that the content is a string.

With your suggestion, property=myRadios[%= index %] the tag libraries
interpretor see that there's not %= at the begining and % at the end.
Then it passes the value myRadios[%= index %] as a string to the taglib.

When the taglib get the content of property, it will analize it and see that
it is a indexed property because of [..] but won't be able to interpret it
and will launch an exception like :

java.lang.IllegalArgumentException: Invalid indexed property
'myRadios[%=index%]'

However, it is important to say that your advice is totally good if you want
to use a dynamic value in standard html tag.

I you have another idea to clean my code, don't hesitate to propose it.


Arnaud.


 -Message d'origine-
 De : Eddie Bush [mailto:[EMAIL PROTECTED]]
 Envoye : mardi 16 juillet 2002 17:54
 A : Struts Users Mailing List
 Objet : Re: Indexed Properties - soluce :-)


 May I make a suggestion?  You're causing the implicit
 creation of many
 strings ... and doing it in a loop (bad).  Try this:

 html:form ...
 logic:iterate id=theRadio indexId=index name=myFormBean
 property=myRadios
 html:radio property=myRadios[%= index %] value=A/html:radio
 property=myRadios[%= index %] value=B/
 /logic:iterate
 /html:form

 This way, you don't have the implicit string creation (you
 get one every
 time you use the + to concatenate).  Object creation is slow :-( so
 don't do it if you don't have to.

 Regards,

 Eddie

 Arnaud HERITIER wrote:

 Ok I found myself a solution (it seems) :
 
 I need to modify the JSP page to index manually the property
 and I don't
 need to use the indexed=true which indexes the BEAN and
 not the property :
 html:form ...
 logic:iterate id=theRadio indexId=index name=myFormBean
 property=myRadios
 html:radio property=%=\myRadios[\+index+\]\%
 value=A/html:radio
 property=%=\myRadios[\+index+\]\% value=B/
 /logic:iterate
 /html:form
 
 Arnaud
 



 --
 To unsubscribe, e-mail:
 mailto:[EMAIL PROTECTED]
 For additional commands, e-mail:
 mailto:[EMAIL PROTECTED]









--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: Indexed Properties - soluce :-)

2002-07-16 Thread Arnaud HERITIER

Ok I found myself a solution (it seems) :

I need to modify the JSP page to index manually the property and I don't
need to use the indexed=true which indexes the BEAN and not the property :
html:form ...
logic:iterate id=theRadio indexId=index name=myFormBean
property=myRadios
html:radio property=%=\myRadios[\+index+\]\% value=A/html:radio
property=%=\myRadios[\+index+\]\% value=B/
/logic:iterate
/html:form

Arnaud

 -Message d'origine-
 De : Arnaud HERITIER [mailto:[EMAIL PROTECTED]]
 Envoyé : mardi 16 juillet 2002 15:50
 À : Struts Users Mailing List (E-mail)
 Objet : Indexed Properties


 Hi guys.

 I'm trying to use the Indexed properties of Struts 1.1.

 What I understood about indexedProperties is that it allows
 to have a set of
 properties (in a form bean) represented by an array of Strings.

 What I want to do is quite simple.

 I have a form with a dynamic list of radio buttons groups.

 in HTML it is something like this :

 form ...
 input type=radio name=myRadios1 value=Ainput type=radio
 name=myRadios1 value=B checked=checked
 input type=radio name=myRadios2 value=A
 checked=checkedinput
 type=radio name=myRadios2 value=B
 
 input type=radio name=myRadiosN value=A
 checked=checkedinput
 type=radio name=myRadiosN value=B
 /form

 in Java with Struts I wrote a FormBean (class MyFormBean)
 with a property
 using an array of strings : String[] myRadios (with getter and setter)

 in the JSP :

 html:form ...
 logic:iterate id=theRadio name=myFormBean property=myRadios
 html:radio property=myRadios indexed=true value=A/html:radio
 property=myRadios indexed=true value=B/
 /logic:iterate
 /html:form

 If I initialize the property myRadios of my formbean with the
 following
 Array : String[] myRadios = {A,A,B,A};
 the JSP generates the good numbers of radio items like this :

 form ...
 input type=radio name=myRadios1 value=Ainput type=radio
 name=myRadios1 value=B
 input type=radio name=myRadios2 value=Ainput type=radio
 name=myRadios2 value=B
 input type=radio name=myRadios3 value=Ainput type=radio
 name=myRadios3 value=B
 input type=radio name=myRadios4 value=Ainput type=radio
 name=myRadios4 value=B
 /form

 but the problem is that this radios aren't initialized with
 the good checked
 properties.

 What I'm waiting for is somethink like :

 form ...
 input type=radio name=myRadios1 value=A
 checked=checkedinput
 type=radio name=myRadios1 value=B
 input type=radio name=myRadios2 value=A
 checked=checkedinput
 type=radio name=myRadios2 value=B
 input type=radio name=myRadios3 value=Ainput type=radio
 name=myRadios3 value=B checked=checked
 input type=radio name=myRadios4 value=A
 checked=checkedinput
 type=radio name=myRadios4 value=B
 /form

 I don't understand what happens ??

 Can you help me please.

 Thx.

   Arnaud HERITIER
   EAI Consulting
   Sopra Group
   Tél. : +33 (0)1 53 33 44 74
   email : [EMAIL PROTECTED]

   Ce message est exclusivement destiné aux personnes dont le
 nom figure
 ci-dessus. Il peut contenir des informations confidentielles dont la
 divulgation est à ce titre rigoureusement interdite. Dans
 l'hypothèse où
 vous avez reçu ce message par erreur, merci de le renvoyer à l'adresse
 e-mail ci-dessus et de détruire toute copie.

   This message may contain confidential and proprietary
 material for the
 sole use of the intended recipient. Any review or
 distribution by others is
 strictly prohibited. If you are not the intended recipient,
 please contact
 the sender and delete all copies.




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties - soluce :-)

2002-07-16 Thread Eddie Bush

May I make a suggestion?  You're causing the implicit creation of many 
strings ... and doing it in a loop (bad).  Try this:

html:form ...
logic:iterate id=theRadio indexId=index name=myFormBean
property=myRadios
html:radio property=myRadios[%= index %] value=A/html:radio
property=myRadios[%= index %] value=B/
/logic:iterate
/html:form

This way, you don't have the implicit string creation (you get one every 
time you use the + to concatenate).  Object creation is slow :-( so 
don't do it if you don't have to.

Regards,

Eddie

Arnaud HERITIER wrote:

Ok I found myself a solution (it seems) :

I need to modify the JSP page to index manually the property and I don't
need to use the indexed=true which indexes the BEAN and not the property :
html:form ...
logic:iterate id=theRadio indexId=index name=myFormBean
property=myRadios
html:radio property=%=\myRadios[\+index+\]\% value=A/html:radio
property=%=\myRadios[\+index+\]\% value=B/
/logic:iterate
/html:form

Arnaud




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: indexed properties

2002-02-27 Thread Arron Bates

yup.

Arron

Maris Orbidans wrote:

hello

   Do I have to use Nightly Build to get subj. ?

   1.0.2 says 

Lemums1.jsp: Attribute indexed invalid according to the specified TLD
at line 194, column 5

html:text indexed=yes property=labCits  size=20 maxlength=20/



Searched mail archive but didnt find any useful.


Maris Orbidans


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




RE: indexed properties

2002-02-26 Thread Gaulin . David

RTFM
http://jakarta.apache.org/struts/userGuide/struts-html.html

and the mailling list archive which is full of examples

http://www.mail-archive.com/struts-user@jakarta.apache.org/

Have fun!



David Gaulin
Tel / tél :(613) 946-9595 
Email / courriel : [EMAIL PROTECTED] 
Facsimile / télécopieur : (613) 954-6012
Industry Canada | 235 Queen Street, Ottawa, Ontario, K1A 0H5
Industry Canada | 235, rue Queen, Ottawa (Ontario)  K1A 0H5



-Original Message-
From: Maris Orbidans [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 26, 2002 10:06 AM
To: Struts Users Mailing List
Subject: indexed properties



How to use indexed properties?

Please, give me an URL with examples or documents.


Maris Orbidans


--
To unsubscribe, e-mail:
mailto:[EMAIL PROTECTED]
For additional commands, e-mail:
mailto:[EMAIL PROTECTED]

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties

2002-02-22 Thread Arron Bates

Sridhar,

I've had to make one such application of equally nasty size. To get the 
job done the nested tags were made. They made the truly daunting task a 
walk in the park.
They're in the nightly build, or if you're confined to an earlier 
release of Struts you can get them as a separate jar here...

http://www.keyboardmonkey.com/struts

Link above will also provide a primer, tutorial, and some advanced 
tricks. The latest docco is on the nightly build part of the struts site 
documentation.

Arron.

Sridhar M wrote:

Hi,
  I have a requirement wherein my HTML Form contains
around 100 textfields. I want to use struts to handle
this form automatically. But the problem is that I
can't define 100 setter and getter methods.I tried
using indexed properties with form beans but did not
succeed. 

Does Struts support the indexed properties concept
defined by Javabeans. If so how to implement it.

Thanks in advance,
Sridhar

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties

2002-02-22 Thread Erik Tennant

I've had repeated problems with IE and Netscape on win9x platforms using a 
large number of text fields.  The browser display seems to become corrupt 
after a short period of time using the screens.  It might be worth your 
time to mock up some screens on your target platform(s) and make sure you 
don't encounter similar problems.

-Erik

At 08:48 AM 2/22/2002, Sridhar M wrote:
Hi,
   I have a requirement wherein my HTML Form contains
around 100 textfields. I want to use struts to handle
this form automatically. But the problem is that I
can't define 100 setter and getter methods.I tried
using indexed properties with form beans but did not
succeed.

Does Struts support the indexed properties concept
defined by Javabeans. If so how to implement it.

Thanks in advance,
Sridhar

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties

2002-02-22 Thread dhay


loads on this in the archive.




Sridhar M [EMAIL PROTECTED] on 02/22/2002 09:48:36 AM

Please respond to Struts Users Mailing List
  [EMAIL PROTECTED]

To:   [EMAIL PROTECTED]
cc:
Subject:  Indexed Properties


Hi,
  I have a requirement wherein my HTML Form contains
around 100 textfields. I want to use struts to handle
this form automatically. But the problem is that I
can't define 100 setter and getter methods.I tried
using indexed properties with form beans but did not
succeed.

Does Struts support the indexed properties concept
defined by Javabeans. If so how to implement it.

Thanks in advance,
Sridhar

__
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games
http://sports.yahoo.com

--
To unsubscribe, e-mail:   
mailto:[EMAIL PROTECTED]
For additional commands, e-mail: 
mailto:[EMAIL PROTECTED]








--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties

2002-01-22 Thread Jonathan James

Yes, that can be done currently with 1.0 or 1.0.1 using the multibox tag.
Look through the archive and at the docs for multibox. If you still need
more help, let us know.

-Jonathan

- Original Message -
From: Marcus Brito [EMAIL PROTECTED]
To: Struts Users Mailing List [EMAIL PROTECTED]
Sent: Tuesday, January 22, 2002 4:57 AM
Subject: Indexed Properties

Hello, folks. I'm currently using Struts 1.0.1 and was wondering if
there is a way to use indexed properties in ActionForm classes.

I know there is support for this in HEAD, but I'm coding an
enterprise-critical application and I hope not to use 'bleeding edge'
components.

I'll give an example of my need: I have a form dinamically generated
using logic:iterate that contains a checkbox for each iteration. Now I
need an action to process the whole form. As of now, the Action is
defined as having no associated ActionForm, and the perform() method
usess request.getParameterValues() calls to get the form values. There
is a way to do this using ActionForms?

--
Ja ne,
   Pazu
   mailto: [EMAIL PROTECTED]

Anime Gaiden: de fãs para fãs, sempre.



--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed Properties

2002-01-22 Thread Marcus Brito

Em Ter, 2002-01-22 às 10:57, Jonathan James escreveu:
 Yes, that can be done currently with 1.0 or 1.0.1 using the multibox tag.
 Look through the archive and at the docs for multibox. If you still need
 more help, let us know.

I mentioned the checkbox as an example. There aro other forms controls
for each iteration: 2 text inputs.

So, for each iteration I've got a checkbox and 2 input fields. The
number of iterations is variable (it's the number of records in the DB).
And I need a struts action to process them all.

-- 
Ja ne,
   Pazu
   mailto: [EMAIL PROTECTED]

Anime Gaiden: de fãs para fãs, sempre.



signature.asc
Description: This is a digitally signed message part


RE: Indexed Properties

2002-01-22 Thread Tom Klaasen (TeleRelay)

 -Original Message-
 From: Marcus Brito [mailto:[EMAIL PROTECTED]] 
 Sent: dinsdag 22 januari 2002 11:57
 To: Struts Users Mailing List
 Subject: Indexed Properties
 
 
 Hello, folks. I'm currently using Struts 1.0.1 and was wondering if
 there is a way to use indexed properties in ActionForm classes. 
 
 I know there is support for this in HEAD, but I'm coding an
 enterprise-critical application and I hope not to use 'bleeding edge'
 components.
 
 I'll give an example of my need: I have a form dinamically generated
 using logic:iterate that contains a checkbox for each 
 iteration. Now I
 need an action to process the whole form. As of now, the Action is
 defined as having no associated ActionForm, and the perform() method
 usess request.getParameterValues() calls to get the form values. There
 is a way to do this using ActionForms?

I recommend using the taglib from http://www.keyboardmonkey.com/struts
if I were you. This does not force you to use the bleeding-edge struts
version, but I think there's less chance that you'll encounter bugs than
if you would try this on an on-the-fly basis for your own webapp via
ActionForms (I tried both. The ActionForm way was *very* error-prone).

FWIW,
tomK

--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed properties...setters and getters

2002-01-16 Thread Arron Bates

Is table[5].minimumSales the tag's name or its property property?...

Have you tried the nested extension for doing this stuff?...


Arron.

TODD HARNEY wrote:

If I have a html:text field on my form with the property named table[5].minimumSales, 
wouldn't this result in:

1) A getTable(5).getMinimumSales() for displaying the form
2) A getTable(5).setMinimumSales(data) for posting the form through an Action class

I am not seeing this behavior at all in my web application and I am using the Struts 
1.0.1 release. Any ideas? Any suggestions on how to debug this?

Thanks,
Todd Harney


--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]





--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed properties...setters and getters

2002-01-16 Thread Tom Goemaes

Is the indexed feature supported in 1.0.1 ? don't think so... not sure.
Use the nightly builds.


 Struts Users Mailing List [EMAIL PROTECTED] wrote:


If I have a html:text field on my form with the property named table[5].min
imumSales, wouldn't this result in:

1) A getTable(5).getMinimumSales() for displaying the form
2) A getTable(5).setMinimumSales(data) for posting the form through an 
Action class

I am not seeing this behavior at all in my web application and I am using 
the Struts 1.0.1 release. Any ideas? Any suggestions on how to debug this?

Thanks,
Todd Harney


--
To unsubscribe, e-mail:   
For additional commands, e-mail: 




--
To unsubscribe, e-mail:   mailto:[EMAIL PROTECTED]
For additional commands, e-mail: mailto:[EMAIL PROTECTED]




Re: Indexed properties and populate error

2001-10-05 Thread dhay



Yep, just posted link to it earlier...see

http://www.mail-archive.com/struts-user@jakarta.apache.org/msg12084.html


hth,

Dave





Torsten Trzeciak [EMAIL PROTECTED] on 10/05/2001
01:22:20 PM

Please respond to [EMAIL PROTECTED]

To:   struts struts [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  Indexed properties and populate error



Hi,
I like to put values of an array in about 20 input fields.
I can do this with indexed properties (property=element[i] but after
submitting this form I get a beanutil error.
What 's wrong?
Is there an example with indexed properties available?









Re: indexed properties weirdness. I'm desperate...

2001-08-13 Thread dhay



Hi Marcel,

Unfortunately using the indexed tags you cannot currently use nested properties.

This is on my todo list, but I just got back from vacation and may take a while.
Solution with scriptlets was posted a while back, I believe,

Cheers,

Dave





Marcel Maré [EMAIL PROTECTED] on 08/11/2001 11:10:45
AM

Please respond to [EMAIL PROTECTED]

To:   Mailinglist Struts-User
  [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  indexed properties weirdness. I'm desperate...



This is driving me crazy. I've spent days figuring this out. Yes, I have
read other postings about this, but obviously I'm missing something (part of
my brain perhaps).

What I want is the form bean to contain a list of objects, which have some
properties. The jsp will iterate over the objects in the list to display
it's (nested) properties in a form. Sounds simple? It isn't.

I just can't figure out what property getters I *have* to implement.

This is a test case I have created:

=
The Form bean
=

public class EditCartForm extends ActionForm {

// other stuff omitted


private ArrayList indexables = new ArrayList();

public EditCartForm() {
}

public Indexable getIndexable(int index) {
return (Indexable) indexables.get(index);
}

public List getIndexables() {
return indexables;
}

}

==
The Indexable class that is in the list
==

public class Indexable extends Object implements java.io.Serializable {

private String stringProp;
private Integer intObjProp;
private int intProp;

public Indexable() {
}

public Indexable( int value ) {
intProp = value;
intObjProp = new Integer(intProp);
stringProp = String.valueOf(intProp);
}

public String getStringProp() {
return stringProp;
}

public void setStringProp(String value) {
this.stringProp = value;
}

public Integer getIntObjProp() {
return intObjProp;
}

public void setIntObjProp(Integer intObjProp) {
this.intObjProp = intObjProp;
}

public int getIntProp() {
return intProp;
}

public void setIntProp(int intProp) {
this.intProp = intProp;
}
}


===
struts-config
===


action  path=/someAction
   type=com.webtothemax.shop.actions.AddToCartAction
   name=theForm
   scope=session
   validate=false


===
The jsp
===

html:form action=/someAction.do 

TABLE border=1 borderwidth=1 cellspacing=0

logic:iterate id=cartItem name=theForm
type=com.webtothemax.shop.common.CartItem property=cart.cartItems

TR
TDhtml:text name=theForm property=indexable.stringProp
indexed=true //TD
TDhtml:textproperty=indexable.stringProp
indexed=true //TD
TDhtml:text   property=indexableindexed=true
//TD

: This is just an example: I have only 1 of these lines in the real file.
:
: stuff omitted
:
: Note that I iterate over another collection (which has the same size)
===


What I would expect:

 html:text property=indexable.stringProp indexed=true /

to be rendered as something like :

INPUT TYPE=TEXT NAME=theForm.indexable[12]  VALUE=%=
theForm.getIndexable(12).getStringProp() % 

Where because of omitting the name attribute the formbean should be
referenced.

This is what I get in reality:

When I include the name attribute:
   ERROR: No getter method for property indexable.stringProp of bean
theForm
When I omit the name attribute:
   ERROR: No getter method for property indexable.stringProp of bean
org.apache.struts.taglib.html.BEAN
When also omit stringProp:
   ERROR: No getter method for property indexable of bean
org.apache.struts.taglib.html.BEAN



So, if somebody could spell it out for me, real slowly, I would be very
grateful.

TIA

Marcel Maré

WebToTheMax

E [EMAIL PROTECTED]
W http://www.webtothemax.com











RE: Indexed properties

2001-07-26 Thread Mark Mahieu

 Is the indexed property a non-standard struts patch / extension I have
to
 use?
 
 Thanks 
 Nathan

It is non-standard (for Struts 1.0 anyway).  Have a look at
http://husted.com/about/struts/indexed-tags.htm

Best regards,

Mark Mahieu



Re: Indexed properties

2001-07-25 Thread James Howe

At 02:23 PM 7/25/2001 -0400, you wrote:


Nathan,

Hi.  Currently you have to use my changed tags...but it looks like they 
will be
in the nightly build by the end of the week.

You can get them at http://husted.com/about/struts/indexed-tags.htm, and I
attached some example source code to a previous message which was just
mentioned, if you want to look at that.

Cheers,

Dave

I have a couple of questions about your mods.  At our site we are using a 
different set of modifications, posted by some other Struts user which 
seems to accomplish the same thing as your mods.  The major difference 
seems to be that yours requires an additional attribute to specify that the 
particular input field is to use an indexed property accessor.  I'm curious 
as to why you made this choice?  The mods we are using automatically use an 
indexed accessor if the input field is contained inside of an iterate 
tag.  Do you have an example of when you would have an input field inside 
of an iterate tag when you wouldn't want to use an indexed property 
name?  (I'm not trying to argue with your decision, just trying to get a 
better understanding of your thoughts).  The other issue, which we just 
came across today, with the other indexed property mod, is that it would 
fail to work correctly if you had iterators inside of iterators.  We had a 
case where we used an iterator to access a collection of beans, and then 
iterated over the contents of each of the beans.  The resultant HTML needed 
to look like this to work correctly:

input type=text name=firstTable[n].secondTable[m].propertyName

Will your mods handle nested iterators correctly?

Finally, are your mods going to be part of the official build, or are they 
included in some sort of user supplied extensions?  I missed the original 
discussion about your modifications.

Thanks!
James W. Howe   mailto:[EMAIL PROTECTED]
Allen Creek Software, Inc.  pgpkey: http://ic.net/~jwh/pgpkey.html
Ann Arbor, MI 48103




Re: Indexed properties

2001-07-25 Thread James Howe

At 05:20 PM 7/25/2001 -0400, you wrote:


Hi James,

Thanks for your note - made me think a bit!

Would be interested in knowing more about the other indexed tags that were
posted and you are using.  I know either Jeff Trent or Martin Cooper had
produced some tags which had a different name ie IndexedXXXTag.

I believe the mods we have are based on those posted by Niall 
Pemberton.  In those mods, a handful of HTML tags had their doStartTag() 
method modified to be changed from:

results.append( name=\);
results.append(this.property);

to

results.append( name=\);
results.append(propertyName());

where propertyName() was implemented like this:

protected String propertyName() {
 IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, 
IterateTag.class);
 return iterateTag == null
 ? this.property
 : iterateTag.getProperty() + [ + 
iterateTag.getIndex() + ]. + this.property;
}

In the original mods that we had, the getProperty method of IterateTag 
simply returned the property field value.  I modified it to invoke a 
propertyName() method whose implementation is the same as that given 
above.  This allows for a recursive buildup of indexed property fields when 
an HTML tag is included inside of any number of nested iterate tags.


James W. Howe   mailto:[EMAIL PROTECTED]
Allen Creek Software, Inc.  pgpkey: http://ic.net/~jwh/pgpkey.html
Ann Arbor, MI 48103




RE: indexed properties

2001-07-07 Thread Niall Pemberton

Cameron,

Does the Action that is run when you submit the form have CourseList
associated with it?

If that sorts out the issue with not finding CourseList then I think
CourseList should look like this:

public final class CourseList extends ActionForm
{
  private ArrayList courseList = new ArrayList(6);

 public ArrayList getCourseList() {
  return(this.courseList);
 }

 public void setCourseList(ArrayList courseList) {
  this.courseList = courseList;
 }

 public CourseForm getCourseList(int index) {
  return (CourseForm)courseList.get(index);
 }

}

Then in your CourseForm bean you need setters for all the properties (i.e.
crstitle, crsdept, crshrs, crsnum).

Niall



-Original Message-
From: cahana [mailto:[EMAIL PROTECTED]]
Sent: 07 July 2001 21:40
To: [EMAIL PROTECTED]
Subject: indexed properties


Hi everyone-

I need some help on using the indexed properties for html:text option.
I've implemented Dave Hay's modification and can get the input boxes to show
up using the iterate tag.

logic:iterate id=course name=CourseList property=courseList
 tr
td%= courseNumber++ %/td
 tdhtml:text name=course property=crstitle size=25
maxlength=50 indexed=true//td
 tdhtml:text name=course property=crsdept size=6 maxlength=9
indexed=true//td
 tdhtml:text name=course property=crsnum size=5 maxlength=6
indexed=true//td
 tdhtml:text name=course property=crshrs size=5 maxlength=1
indexed=true//td
 /tr
 /logic:iterate

This is what my CourseList bean looks like:

public final class CourseList extends ActionForm
{
  private ArrayList courseList = new ArrayList(6);

 public ArrayList getCourseList() {
  return(this.courseList);
 }

 public void setCourseList(ArrayList courseList) {
  this.courseList = courseList;
 }

 public CourseForm getCourseForm(int index) {
  return (CourseForm)courseList.get(index);
 }

 public void setCourseForm(int index, CourseForm course) {
  this.courseList.add(index, course);
 }
}

The problem i have is that when i try to submit the information and try to
access CourseList.getCourseList(), it bombs and says CourseList cannot be
found. The scope is request. I tried putting it in the session and can
access it that way but it doesn't have the changes that were made on the
form. Anybody know what i'm doing wrong?

thanks,
cameron




Re: indexed properties

2001-07-07 Thread cahana

In my struts-config.xml, i have CourseList as the form associated with the
Action to submit.  I also put a jsp:useBean for CourseList in the jsp. But
it still doesn't work. I'll keep trying.

Do you know if there is a way to associate mulitple forms with a single
action in the struts-config.xml file i.e.
actionpath=/registration
type=DisplayRegistrationAction
name=registrationForm, accountForm
scope=request
validate=false 
  forward name=success path=/acct_create.jsp/

/action

Cameron
- Original Message -
From: Niall Pemberton [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, July 07, 2001 11:10 AM
Subject: RE: indexed properties


 Cameron,

 Does the Action that is run when you submit the form have CourseList
 associated with it?

 If that sorts out the issue with not finding CourseList then I think
 CourseList should look like this:

 public final class CourseList extends ActionForm
 {
   private ArrayList courseList = new ArrayList(6);

  public ArrayList getCourseList() {
   return(this.courseList);
  }

  public void setCourseList(ArrayList courseList) {
   this.courseList = courseList;
  }

  public CourseForm getCourseList(int index) {
   return (CourseForm)courseList.get(index);
  }

 }

 Then in your CourseForm bean you need setters for all the properties
(i.e.
 crstitle, crsdept, crshrs, crsnum).

 Niall



 -Original Message-
 From: cahana [mailto:[EMAIL PROTECTED]]
 Sent: 07 July 2001 21:40
 To: [EMAIL PROTECTED]
 Subject: indexed properties


 Hi everyone-

 I need some help on using the indexed properties for html:text option.
 I've implemented Dave Hay's modification and can get the input boxes to
show
 up using the iterate tag.

 logic:iterate id=course name=CourseList property=courseList
  tr
 td%= courseNumber++ %/td
  tdhtml:text name=course property=crstitle size=25
 maxlength=50 indexed=true//td
  tdhtml:text name=course property=crsdept size=6
maxlength=9
 indexed=true//td
  tdhtml:text name=course property=crsnum size=5 maxlength=6
 indexed=true//td
  tdhtml:text name=course property=crshrs size=5 maxlength=1
 indexed=true//td
  /tr
  /logic:iterate

 This is what my CourseList bean looks like:

 public final class CourseList extends ActionForm
 {
   private ArrayList courseList = new ArrayList(6);

  public ArrayList getCourseList() {
   return(this.courseList);
  }

  public void setCourseList(ArrayList courseList) {
   this.courseList = courseList;
  }

  public CourseForm getCourseForm(int index) {
   return (CourseForm)courseList.get(index);
  }

  public void setCourseForm(int index, CourseForm course) {
   this.courseList.add(index, course);
  }
 }

 The problem i have is that when i try to submit the information and try to
 access CourseList.getCourseList(), it bombs and says CourseList cannot be
 found. The scope is request. I tried putting it in the session and can
 access it that way but it doesn't have the changes that were made on the
 form. Anybody know what i'm doing wrong?

 thanks,
 cameron





Re: indexed properties

2001-07-07 Thread cahana

Niall-

Thanks i got the CourseList to work.

Cameron

- Original Message -
From: Niall Pemberton [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Saturday, July 07, 2001 11:10 AM
Subject: RE: indexed properties


 Cameron,

 Does the Action that is run when you submit the form have CourseList
 associated with it?

 If that sorts out the issue with not finding CourseList then I think
 CourseList should look like this:

 public final class CourseList extends ActionForm
 {
   private ArrayList courseList = new ArrayList(6);

  public ArrayList getCourseList() {
   return(this.courseList);
  }

  public void setCourseList(ArrayList courseList) {
   this.courseList = courseList;
  }

  public CourseForm getCourseList(int index) {
   return (CourseForm)courseList.get(index);
  }

 }

 Then in your CourseForm bean you need setters for all the properties
(i.e.
 crstitle, crsdept, crshrs, crsnum).

 Niall








RE: Indexed Properties

2001-06-28 Thread Rey Francois

The problem is that your getUsers() return an array of User instances while
your getUsers(int i) returns a String.
As a result the PropertyDescriptor class for the users property will
consider the User class as the type of your property, and will check the
existence of User getUsers(int i) and void setUser(int i, User user).

You must make sure that indexed and non-indexed read/write methods use the
same type.

Fr.

-Original Message-
From: Jason Rosenblum [mailto:[EMAIL PROTECTED]]
Sent: 27 June 2001 18:21
To: '[EMAIL PROTECTED]'
Subject: Indexed Properties


Hello all,

I'm trying to get my code to work with indexed properties. Thanks to Dave
Hay and his Struts tweak, I was able to generate input types like this:
input type=text name=users[0].username size=12 value=
input type=text name=users[0].role size=12 value=

using the following Struts tags:
html:text name=users property=username size=12 indexed=true/
html:text name=users property=role size=12 indexed=true/

The problem is that I cannot get my ActionForm to pick up these input
fields. I wrote several setters and getters in my ActionForm:
   /**
 * Return the users.
 */
public String getUsers(int i) {

return (users[i].getUsername());

}


/**
 * Set a user.
 *
 * @param user
 * @param index
 */
public void setUsers(int i, String user) {
this.users[i].setUsername(user);

}
 
 
/**
 * Return the users.
 */
public User[] getUsers() {

return (this.users);

}


/**
 * Set a user.
 *
 * @param user list
 */
public void setUsers(User[] users) {
this.users = users;

}
 
/**
 * Return the roles.
 */
public String getRoles(int i) {

return (users[i].getRole());

}


/**
 * Set a role.
 *
 * @param role
 * @param index
 */
public void setRoles(int i, String role) {

this.users[i].setRole(role);

}
 
 
/**
 * Return the roles.
 */
public User[] getRoles() {

return (this.users);

}


/**
 * Set a role.
 *
 * @param role list
 */
public void setRoles(User[] roles) {

this.users = users;

} 


Do you see anything wrong with this scheme? Currently, the ActionForm
returns null for all items in the User[] when I call any of the get methods.
Please help.

~Jason


The information in this email is confidential and is intended solely
for the addressee(s).
Access to this email by anyone else is unauthorised. If you are not
an intended recipient, you must not read, use or disseminate the
information contained in the email.
Any views expressed in this message are those of the individual
sender, except where the sender specifically states them to be
the views of Capco.

http://www.capco.com
***




Re: Indexed Properties

2001-06-27 Thread dhay



Jason,

I believe you need a
 public User getUser(int index)
 {
  return (users[i]);
 }

For the examples I sent you, I have the following form:

public final class ParametersForm extends ActionForm
{
   // --- Instance Variables

   /**
* The parameter list
*/
   private Vector parameterList = new Vector();
   // --- Properties

   /**
* Return the list of parameters
*/
   public Vector getParameterList()
   {
  return(this.parameterList);
   }

   /**
* Set the list of parameters
*
* @param parameterList The new list
*/
   public void setParameterList(Vector parameterList)
   {
  this.parameterList = parameterList;
   }

   /**
* Get a particular parameter from the parameterList, based on index
*
* @param   index The index of the parameter to retrieve
*/
   public Parameter getParameter(int index)
   {
  return (Parameter)parameterList.elementAt(index);

   }
}

and I obviously have get/set methods in my Parameter object to get the parameter
 variables.

Cheers.

Dave






Jason Rosenblum [EMAIL PROTECTED] on 06/27/2001
12:20:51 PM

Please respond to [EMAIL PROTECTED]

To:   '[EMAIL PROTECTED]'
  [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  Indexed Properties



Hello all,

I'm trying to get my code to work with indexed properties. Thanks to Dave Hay
and his Struts tweak, I was able to generate input types like this:
input type=text name=users[0].username size=12 value=
input type=text name=users[0].role size=12 value=

using the following Struts tags:
html:text name=users property=username size=12 indexed=true/
html:text name=users property=role size=12 indexed=true/

The problem is that I cannot get my ActionForm to pick up these input fields. I
wrote several setters and getters in my ActionForm:
   /**
 * Return the users.
 */
public String getUsers(int i) {

 return (users[i].getUsername());

}


/**
 * Set a user.
 *
 * @param user
 * @param index
 */
public void setUsers(int i, String user) {
 this.users[i].setUsername(user);

}


/**
 * Return the users.
 */
public User[] getUsers() {

 return (this.users);

}


/**
 * Set a user.
 *
 * @param user list
 */
public void setUsers(User[] users) {
 this.users = users;

}

/**
 * Return the roles.
 */
public String getRoles(int i) {

 return (users[i].getRole());

}


/**
 * Set a role.
 *
 * @param role
 * @param index
 */
public void setRoles(int i, String role) {

this.users[i].setRole(role);

}


/**
 * Return the roles.
 */
public User[] getRoles() {

 return (this.users);

}


/**
 * Set a role.
 *
 * @param role list
 */
public void setRoles(User[] roles) {

this.users = users;

}


Do you see anything wrong with this scheme? Currently, the ActionForm returns
null for all items in the User[] when I call any of the get methods. Please
help.

~Jason









Re: Indexed Properties

2001-06-27 Thread David Winterfeldt

Is this all in one class?  It shouldn't even compile
if you have getUsers() returning two different types. 
Here is a snippet on using an array.

public User getUser(int index) {
   return user[index];  
}

public void setUser(int index, User user) {
   this.user[index] = user;
}


Then you could do user[0].userName, which is the
same as getUser(0).getUserName() or
getUser(0).setUserName(Joe).

David

--- Jason Rosenblum [EMAIL PROTECTED] wrote:
 Hello all,
 
 I'm trying to get my code to work with indexed
 properties. Thanks to Dave Hay and his Struts tweak,
 I was able to generate input types like this:
 input type=text name=users[0].username
 size=12 value=
 input type=text name=users[0].role size=12
 value=
 
 using the following Struts tags:
 html:text name=users property=username
 size=12 indexed=true/
 html:text name=users property=role size=12
 indexed=true/
 
 The problem is that I cannot get my ActionForm to
 pick up these input fields. I wrote several setters
 and getters in my ActionForm:
/**
  * Return the users.
  */
 public String getUsers(int i) {
 
   return (users[i].getUsername());
 
 }
 
 
 /**
  * Set a user.
  *
  * @param user
  * @param index
  */
 public void setUsers(int i, String user) {
   this.users[i].setUsername(user);
 
 }
  
  
 /**
  * Return the users.
  */
 public User[] getUsers() {
 
   return (this.users);
 
 }
 
 
 /**
  * Set a user.
  *
  * @param user list
  */
 public void setUsers(User[] users) {
   this.users = users;
 
 }
  
 /**
  * Return the roles.
  */
 public String getRoles(int i) {
 
   return (users[i].getRole());
 
 }
 
 
 /**
  * Set a role.
  *
  * @param role
  * @param index
  */
 public void setRoles(int i, String role) {
 
 this.users[i].setRole(role);
 
 }
  
  
 /**
  * Return the roles.
  */
 public User[] getRoles() {
 
   return (this.users);
 
 }
 
 
 /**
  * Set a role.
  *
  * @param role list
  */
 public void setRoles(User[] roles) {
 
 this.users = users;
 
 } 
 
 
 Do you see anything wrong with this scheme?
 Currently, the ActionForm returns null for all items
 in the User[] when I call any of the get methods.
 Please help.
 
 ~Jason


__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail
http://personal.mail.yahoo.com/



RE: Indexed Properties

2001-06-27 Thread Jason Rosenblum

that did the trick.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, June 27, 2001 9:32 AM
To: [EMAIL PROTECTED]
Subject: Re: Indexed Properties




Jason,

I believe you need a
 public User getUser(int index)
 {
  return (users[i]);
 }

For the examples I sent you, I have the following form:

public final class ParametersForm extends ActionForm
{
   // --- Instance Variables

   /**
* The parameter list
*/
   private Vector parameterList = new Vector();
   // --- Properties

   /**
* Return the list of parameters
*/
   public Vector getParameterList()
   {
  return(this.parameterList);
   }

   /**
* Set the list of parameters
*
* @param parameterList The new list
*/
   public void setParameterList(Vector parameterList)
   {
  this.parameterList = parameterList;
   }

   /**
* Get a particular parameter from the parameterList, based on index
*
* @param   index The index of the parameter to retrieve
*/
   public Parameter getParameter(int index)
   {
  return (Parameter)parameterList.elementAt(index);

   }
}

and I obviously have get/set methods in my Parameter object to get the parameter
 variables.

Cheers.

Dave






Jason Rosenblum [EMAIL PROTECTED] on 06/27/2001
12:20:51 PM

Please respond to [EMAIL PROTECTED]

To:   '[EMAIL PROTECTED]'
  [EMAIL PROTECTED]
cc:(bcc: David Hay/Lex/Lexmark)
Subject:  Indexed Properties



Hello all,

I'm trying to get my code to work with indexed properties. Thanks to Dave Hay
and his Struts tweak, I was able to generate input types like this:
input type=text name=users[0].username size=12 value=
input type=text name=users[0].role size=12 value=

using the following Struts tags:
html:text name=users property=username size=12 indexed=true/
html:text name=users property=role size=12 indexed=true/

The problem is that I cannot get my ActionForm to pick up these input fields. I
wrote several setters and getters in my ActionForm:
   /**
 * Return the users.
 */
public String getUsers(int i) {

 return (users[i].getUsername());

}


/**
 * Set a user.
 *
 * @param user
 * @param index
 */
public void setUsers(int i, String user) {
 this.users[i].setUsername(user);

}


/**
 * Return the users.
 */
public User[] getUsers() {

 return (this.users);

}


/**
 * Set a user.
 *
 * @param user list
 */
public void setUsers(User[] users) {
 this.users = users;

}

/**
 * Return the roles.
 */
public String getRoles(int i) {

 return (users[i].getRole());

}


/**
 * Set a role.
 *
 * @param role
 * @param index
 */
public void setRoles(int i, String role) {

this.users[i].setRole(role);

}


/**
 * Return the roles.
 */
public User[] getRoles() {

 return (this.users);

}


/**
 * Set a role.
 *
 * @param role list
 */
public void setRoles(User[] roles) {

this.users = users;

}


Do you see anything wrong with this scheme? Currently, the ActionForm returns
null for all items in the User[] when I call any of the get methods. Please
help.

~Jason