Katie,
You are doing only one thing wrong -- this is the developer's list, and
usage questions should be addressed to the users list. For your
question, the problem is not with the tags, but rather with your bean:
In your scenario, the populate() method does the equivalent of
mainForm.getItemList(index).setItemName(name)
Notice that it is getItemList(), _not_ setItemList().
To solve this, instead of
private ArrayList _itemList = new ArrayList();
in the MainForm class, use
import org.apache.commons.collections.ListUtils;
import org.apache.commons.collections.Factory;
class ItemBeanFactory implements Factory {
// Make new BeanItem's
}
private ArrayList _itemList = ListUtils.getLazyList(new ArrayList(), new
ItemBeanFactory()) ;
And things might look better.
Have fun,
Shai.
-----Original Message-----
From: Katie Wright [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 31, 2003 20:41
To: '[EMAIL PROTECTED]'
Subject: Help Please with usage of nested tags
Hi,
I am new to this mailing list (i.e. I am sorry if I do something wrong,
please don't flame me). I am not new to struts but I am new to the more
advanced tags. I have run into this problem. I think that I am close but
just not understanding a key concept.
I am trying to create an HTML form like so:
Item1Label Item1Textbox
Item2Label Item2Textbox
Item3Label Item3Textbox
What is new to me is the fact that in this case, the number of items
vary
and the item labels vary.
I can display the page fine with the populated values for edit but when
I
try to do a save, I get the following struts exception:
javax.servlet.ServletException:BeanUtils.populate at
org.apache.struts.util.RequestUtils.populate RequestUtils.java:1254) at
org.apache.struts.action.RequestProcessor.processPopulate(RequestProcess
or.j
ava:821) at
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
254)
at
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
It seems to be having trouble activating my setter in my form but not
sure
why. I think because I have setup something improperly but don't know
what.
I have done some research on the Internet and by following by example I
have
developed the following:
<html:form action="MainFormSave.do">
<nested:iterate property="itemList">
<nested:hidden property="itemName" />
<nested:write property="itemName" />
<nested:text property="itemDescription" />
</nested:iterate>
</html:form>
I have a MainForm class which includes the following:
private ArrayList _itemList = new ArrayList();
public void setItemList(int index, ItemBean item) {
if (index < this._itemList.size()) {
this._itemList.set(index, item);
} else {
this._itemList.add(item);
}
}
public ArrayList getItemList() {
return (this._itemList) ;
}
And I have an ItemBean which includes the following:
private String _itemName = null;
private String _itemDescription = null;
public void setItemName(String name) {
this._itemName=name;
}
public String getItemName() {
return (this._itemName) ;
}
public void setItemDescription(String desc) {
this._itemDescription=desc;
}
public String getItemDescription() {
return (this._itemDescription) ;
}
Thanks in advance,
Katie Wright (who is hoping that it is not something completely obvious)
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---
Confidentiality Notice: This email transmission may contain confidential or legally
privileged information that is intended only for the individual or entity named in the
e-mail address. If you are not the intended recipient, you are hereby notified that
any disclosure, copying, distribution, or reliance upon the contents of this e-mail is
strictly prohibited. If you have received this e-mail transmission in error, please
reply to the sender, so that arrangements can be made for proper delivery, and then
please delete the message from your inbox.
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]