Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

struts indexed question

Thread view: 
Tim B - 01 Feb 2006 06:54 GMT
Can anyone point me to an example of using Struts indexed properties in a
situation with a formbean contaning a list of objects, each containing a
further list of objects, or point out if there is an error in the code
below? I would like to be able to round-trip to the server with full
repopulation without having to resort to doing what I did for textbox 4.

I have the following code in a jsp

<logic:iterate id="bean"  name="myFormBeanName"
               property="beanList" type="mypackage2.OuterBean"
               scope="request" indexId="ind">

   <%--  these 2  textboxes repopulate correctly --%
  <html:text name="bean" property="label" indexed="true" />
  <html:text name="bean" property="value" indexed="true"/>

  <logic:iterate id="nestedBean" name="bean" property="nestedBeanList"
                   type="mypackage2.NestedBean" indexId = "ind2" >

    <%-- textbox 3-  this textbox repopulates correctly --%>
   <input type="text"

name="bean[<%=ind.intValue()%>].nestedBean[<%=ind2.intValue()%>].beanValue"
    value="<%=nestedBean.getBeanValue()%>"/>

     <%-- textbox 3- this textbox does not repopulate correctly --%>
   <html:text name="nestedBean" property="beanValue" indexed="true"/>
  </logic:iterate>

</logic:iterate>

the html generated for textbox 3 is :
<input type="text" name="bean[0].nestedBean[0].beanValue" value="foo"/>

the html generated for textbox 4 is:
<input type="text" name="nestedBean[0].beanValue" value="foo">
Tim B - 01 Feb 2006 06:56 GMT
oops - made a typo - last textbox is textbox 4, not 3
Tim B - 03 Feb 2006 02:49 GMT
> Can anyone point me to an example of using Struts indexed properties in a
> situation with a formbean contaning a list of objects, each containing a
> further list of objects, or point out if there is an error in the code
> below?

answering my own question here - the <html:text> tag and its kin do not
support indexing beyond one level. So I wrote my own version that does


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.