Hi - could someone please point me to a definitive guide to get() and set()
conventions for indexed properties in Struts? I've seen and tried plenty of
variations; there doesn't seem to be one standard solution that works every
time.

E.g. for the property
List books = new ArrayList();   // assume will contain Strings

I've seen variations as shown below. What combination of the getters and
setters below does one use? If it varies according to how the property is
being used in the JSP (e.g. html:options, logic:iterate), how so? And does
it make a difference if you're using an array instead of a list?

(Note: I've omitted the required range-checks for clarity.)

GETTERS:

1.
public List getBooks() { 
  return books;
}

2. (Saw this one at http://jakarta.apache.org/struts/faqs/indexedprops.html,
makes no sense to me)
public List getBooks(int index) { 
  return books;
}

3.
public String getBooks(int index) { 
  return (String) books.get(index);
}

SETTERS:

1.
public void setBooks(List books) {
  this.books = books;
}

2.
public void setBooks (int index, String book) {
  books.set(index, book);
}

Thanks for your help,
Sunil

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

Reply via email to