On 11/22/06, Adam K <[EMAIL PROTECTED]> wrote:
If you might be able to provide a sample I would be very greatful. As it stands I have come up with the following : changing the JSP to : <logic:notEmpty name="ProdSelectionForm" property="results"> <logic:iterate name="ProdSelectionForm" property="results" id="Result"> <tr>
<td> <html:text property="result.description"
indexed="true" /> </td> </tr> </logic:iterate> </logic:notEmpty>
Hmm.. As i said try something like this <logic:notEmpty name="ProdSelectionForm" property="results"> <logic:iterate name="ProdSelectionForm" property="results" id="Result"> <tr> <!--Note the change in the following line.--> <td> <html:text property="result.description" indexed="true" /> </td> </tr> </logic:iterate> </logic:notEmpty> In case you dont encounter any error while loading the page. please post the HTML generated. That would give a good idea of what is going wrong. Result seemed more natural as it is a single element of the results.
All I want to be able to do is pull 3 things out of an object, display them in a scope of request, and allow the user to update the list and submit the form and have the changes be picked up - who would have thought that would be so incredibly complex ? *Note* The part that leads me to believe it's a misunderstanding of the tags involved is that I can get a single textfield to work perfectly, with all the requirements (other than it being an object with multiple properties). On 11/21/06, Raghuveer <[EMAIL PROTECTED]> wrote: > > hi Adam, > > I understand description,numProducts are properties in User defined > Object/java bean in results(getResults(),setResults(..)) Collection in > your > actionForm. > > For this kind of requirments there will not be any change in actionform > even > though ,complixety increases in nesting.. > > Solution is to use Nested Tags. > > Nested tags are used for nesting a object inside the other. > > In your requirment "results" is a nested property in your actionform. > "results" collection has a collection of objects. > > I have used Nested tags for most complex requirments and succeeded. > > Nested Tags is the real power of Struts... > > > Regards > Raghu > > > > > > -----Original Message----- > From: Adam K [mailto:[EMAIL PROTECTED] > Sent: Saturday, November 18, 2006 2:55 AM > To: Struts Users Mailing List > Subject: Re: Indexed Properties > > > Thanks for the suggestion I'll keep trying things and see what I can get > from it. > > > On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: > > > > Lots of people have done it. Search the archives [1]. Search for > > "indexed" and "lazyList". I've done it with both ActionForm and > > DynaActionForm. > > > > Hubert > > > > [1] http://struts.apache.org/mail.html > > > > On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > > > I think I have found the problem - or at least a potential > cause. Would > > it > > > be correct in stating that this will not work using ActionForm (what I > > was > > > using) and that I must instead use DynaActionForm ? > > > > > > Thanks for the time thus far. > > > > > > > > > On 11/17/06, Hubert Rabago <[EMAIL PROTECTED]> wrote: > > > > > > > > Adam, > > > > > > > > Try adding a getResultsPage() that doesn't take params and always > > > > returns a valid collection. (Throw in the setResultsPage() that > > > > accepts a collection as well.) > > > > > > > > Hubert > > > > > > > > On 11/17/06, Adam K <[EMAIL PROTECTED]> wrote: > > > > > This has been driving me nuts for the past little bit. > > > > > I have a page that is populated using indexed properties. The > > > > prepopulation > > > > > works fine, and I get the results as I would expect them, but > > trying to > > > > > submit the form I get an index out of bounds exception. I know > that > > it > > > > is > > > > > being caused because the page doesn't have the arrayList to use in > > the > > > > > indexed properties. I guess my question boils down to using > > indexed > > > > > properties properly. I will start by putting in an explanation of > > what > > > > I > > > > > have and what I am trying to do: > > > > > > > > > > The following is what I am working with : > > > > > JSP: > > > > > > > > > > <logic:notEmpty name="ProdSelectionForm" property="results"> > > > > > <logic:iterate name="ProdSelectionForm" property="results" > > > > > id="ResultsPage"> > > > > > <tr> > > > > > <td> <bean:write name="ResultsPage" > > > > property="description" > > > > > /> </td> > > > > > <td > <html:text name="ResultsPage" > > > > property="numProducts" > > > > > indexed="true" /> </td> > > > > > </tr> > > > > > </logic:iterate> > > > > > </logic:notEmpty> > > > > > > > > > > What I am trying to achieve is that a user clicks on a link, they > > are > > > > sent > > > > > to page, and all of the values are prepopulated. The page is then > > > > displayed > > > > > and the user has the option to modify any of the variables that > they > > > > want to > > > > > before resubmitting the page. (When they resubmit the form has a > > url > > > > > parameter attached to it). What is happening (or at least what I > > > > believe is > > > > > happening is the following: link is clicked, reset is called > action > > > > sets > > > > > the variables, page is displayed, user can modify the page and > > resubmit, > > > > > reset is called on the form, the action is called (this is where > it > > dies > > > > as > > > > > there is no longer an ArrayList) to modify. My question is am I > > going > > > > about > > > > > this in a manner that seems sensible or am I way off base ? I > have > > the > > > > > values being prepopulated, but when trying to use the values that > > the > > > > user > > > > > puts in I can't use them in the action, nor can I pull the values > > from > > > > the > > > > > form without again setting the values in the form. I am hoping > it > > is > > > > that > > > > > I have over looked something, but it's possible that I don't > > understand > > > > > something as well. > > > > > > > > > > Here is the Action code (This is the entire execute method) : > > > > > HttpSession session = request.getSession(); > > > > > ProdSelectionForm prodSelection = (ProdSelectionForm) > form; > > > > > User user ; > > > > > user = (User)session.getAttribute("User"); > > > > > Order order = new Order(); > > > > > ArrayList products = new ArrayList(); > > > > > ArrayList pageRes = new ArrayList(); > > > > > ArrayList results = new ArrayList(); > > > > > > > > > > String action = (request.getParameter("Dest") == null ? > > > > "populate" : > > > > > request.getParameter("Dest") ); > > > > > > > > > > order = user.getCurrOrder(user); > > > > > > > > > > if(action.equals("populate")) > > > > > { > > > > > prodSelection.setResults(order.getProducts()); > > > > > } > > > > > > > > > > if(action.equals("Delete")) > > > > > { > > > > > ArrayList p = new ArrayList(); > > > > > p = prodSelection.getResults(); > > > > > > > > > > int count = 0; > > > > > while (count < p.size()) > > > > > { > > > > > Product t = (Product) p.get(count); > > > > > t.setDescription("" +t.getNumProducts() +">" > > > > +pageRes.size() > > > > > +"<"); > > > > > p.set(count, t); > > > > > count++; > > > > > } > > > > > > > > > > t.setDescription("" +t.getNumProducts() +">" +p.size() > > > > +"<"); > > > > > p.set(0, t); > > > > > > > > > > user.setOrder(p , user); > > > > > prodSelection.setResults(p); > > > > > prodSelection.setTest(prodSelection.getTest()+" + " + > > p.size > > > > ()); > > > > > > > > > > return mapping.findForward("success"); > > > > > } > > > > > return mapping.findForward("success"); > > > > > > > > > > > > > > > > > > > > > > > > > Form code: (In the form code is an ArrayList called results. This > > > > arraylist > > > > > contains a bunch of Product ) > > > > > > > > > > public Product getResultsPage(int index) > > > > > { > > > > > if(this.results == null) > > > > > { > > > > > this.results = new ArrayList(); > > > > > } > > > > > > > > > > while(index >= this.results.size()) > > > > > { > > > > > this.results.add(new Product()); > > > > > } > > > > > return (Product) results.get(index); > > > > > } > > > > > > > > > > public void setResultsPage(int index, Product p) > > > > > { > > > > > if(this.results == null) > > > > > { > > > > > this.results = new ArrayList(); > > > > > } > > > > > > > > > > while(index >= this.results.size()) > > > > > { > > > > > this.results.add(new Product()); > > > > > } > > > > > results.set(index, p); > > > > > //return (Product) results.get(index); > > > > > } > > > > > > > > > > public void setResults(ArrayList results) > > > > > { > > > > > this.results=results; > > > > > } > > > > > > > > > > public ArrayList getResults() > > > > > { > > > > > return this.results; > > > > > } > > > > > > > > > > > > > > > > > > > > Products is an object that stores various things about a product > > with > > > > > numProducts, and description being two of those things. > > > > > Within Products is both getter and setter methods for the > > numProducts as > > > > > well as description. > > > > > > > > > > > > > > > > > > > > Thanks so much for any help you may be able to provide. > > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > > > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > >
-- Puneet