This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Struts and the fly likes Urgent: How to use Indexed Properties Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Urgent: How to use Indexed Properties " Watch "Urgent: How to use Indexed Properties " New topic

Urgent: How to use Indexed Properties

Prashant Vasudeo
Ranch Hand

Joined: Mar 25, 2003
Posts: 38
I am trying to use the nested tags in form bean . please help me on this.
I have a form which will have 8 element (textbox,radio box,...) in one row
and user have (add and delete buton) after the user clicks on + button one row should be displayed in the screen.
I tried this using nested tags.but giving some errors. also
It is possible that after user has entered the data the formbean will be populated with the user data?
please help as i have trying it for 3 days ..and i have to delivery on monday.
the code is as follows
Form Bean
public class TestBean extends XmlCoeActionForm {
private MyBean myBean;
private String attb = "attribute";
public TestBean() {
Logger.writeDebug("creating TestBean.............");
this.myBean = new MyBean(this);
public MyBean getMyBean() {
Logger.writeDebug("getting MyBean.............");
return this.myBean;
public void setMyBean(MyBean mybean) {
Logger.writeDebug("setting MyBean.............");
this.myBean = mybean;
public String getAttb() {
Logger.writeDebug("getting arrb.............");
return this.attb;
public void setAttb(String attb) {
Logger.writeDebug("setting arrb.............");
this.attb = attb;
my MyBean class
public class MyBean {
private TestBean testbean;
private ArrayList myBeanList= new ArrayList();
private String newButton;

public MyBean(TestBean testBean) {
Logger.writeDebug("creating MyBean.........");
/* set the master bean */
this.testbean = testBean;
this.myBeanList = new ArrayList();
ActualBean bb = new ActualBean(this);

public Object[] getMyBeanList() {
Logger.writeDebug("getting MyBeanList.........");
return this.myBeanList.toArray();

public void setMyBeanList(Object[] newMyBeanList) {
Logger.writeDebug("setting MyBeanList.........");
this.myBeanList = new ArrayList();
for (int i = 0; i < newMyBeanList.length; i++) {

public void setNewButton(String empty) {
Logger.writeDebug("setting NewButton.........");
ActualBean bb = new ActualBean(this);

my ActualBEan class
public class ActualBean {

private String txtLeftValue;
private String txtRightValue;
private MyBean myBean;
public ActualBean(MyBean myBean){
this.myBean = myBean;
* @return
public String getTxtLeftValue() {
return this.txtLeftValue;
* @return
public String getTxtRightValue() {
return this.txtRightValue;
* @param string
public void setTxtLeftValue(String txtLeftValue) {
this.txtLeftValue = txtLeftValue;
* @param string
public void setTxtRightValue(String txtLeftValue) {
this.txtRightValue = txtLeftValue;
my Jsp is
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@page import="" %>
<%@page import="" %>

<form name="test" action="/xmlcoe/" method="post">
<input type="hidden" name="actionKey" value="SUBMIT">

<jsp:useBean id="bean" class=""/>
<jsp:getProperty name="bean" property="myBean"/>
<% MyBean myBean = bean.getMyBean();
out.print("myBean is:"+myBean);
System.out.println("myBean is:"+myBean);
Object obj[] = myBean.getMyBeanList();
out.print("obj.length is:"+obj.length);
System.out.println("obj.length is:"+obj.length);
System.out.println("obj is:"+obj);
<nested:nest property="myBean">
<nested:submit property="newButton" >NEW Button</nested:submit>
<nested:iterate property="myBeanList">
<nested:text property="txtLeftValue" />
<nested:text property="txtRightValue" />
The error shoen is myBean is not found in any scope.
if i comment the iterator for myBeanList it shows the button generated
but if try to get values for txtLeftValue,txtrightValue , it is giving error.
I agree. Here's the link:
subject: Urgent: How to use Indexed Properties
It's not a secret anymore!