• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Urgent: How to use Indexed Properties

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
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);
bb.setTxtLeftValue("leftvalue");
bb.setTxtRightValue("rightvalue");
this.myBeanList.add(bb);
}

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++) {
this.myBeanList.add(newMyBeanList[i]);
}
}

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


}
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="com.chase.xmlcoe.xmltoolkit.codegenerator.mappingservice.MyBean" %>
<%@page import="com.chase.xmlcoe.xmltoolkit.codegenerator.mappingservice.TestBean" %>

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

<jsp:useBean id="bean" class="com.chase.xmlcoe.xmltoolkit.codegenerator.mappingservice.TestBean"/>
<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" />
</nested:iterate>
</nested:nest>
</form>
</html>
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.
regards
prashant
reply
    Bookmark Topic Watch Topic
  • New Topic