Using struts-nested tags
Hi folks, I'm new to the list, so forgive me if I'm not respecting Netiquette or asking off-topics. I'm trying to render pieces of html using the following syntax: from struts-config.xml the definition of the form follows: into the jsp I wrote (MyBeanContainer has the method getListaDanneggiati() which returns a ArrayList of beans): The html I actually get is: ... ... which is nice but not satisfying. I'd like to get something like: where the name property of the input text includes the root name, ie "beanContainer". I need this to manage the interactivity correctly. Infact what I actually get when I submit the form is the following: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 at java.util.ArrayList.RangeCheck(Unknown Source) at java.util.ArrayList.get(Unknown Source) at org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298) at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:474) at org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:428) at Thank you in advance... -- Paride Perazzolo [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using struts-nested tags
Thanks for your answer. >> > scope="session">> > You shouldn't need the above on the page. You should set > MyBeanContainer with the id "beanContainer" into session or request > scope in the Action you are in "BEFORE" you get to this JSP page. The > page will have it. No need to use the useBean stuff.> the point is: 1) beanContainer was put into session by another jsp previously. 2)I need to fetch his values, display them in a form, let the user modifying them. 3) Finally, I have to post data to an action which will make some stuff and update beanContainer into session. >> which is nice but not satisfying. I'd like to get something like: >> >> >> > value="SDFSDF" class="inputText">> > I don't sew why you would want this? The form bean property is the > ArrayList listaDanneggiati so that's what will get set when you submit > the form. Your form bean doesn't have a bean property "beanContainer" so > you wouldn't even want that trying to be added.. you'd get a "no > property 'beanContainer" found in form.." error.> ok, I was not even able to test sufficently this aspect of the problem. > What scope is your canalizzazioneCLDForm given in the ActionMapping. The > quick way to avoid this problem is to make sure it has Session scope. I've checked, it has session scope. > If you don't give it session scope you'll have to do some other things > to make sure their are the proper number of fields available to set in > your nested arrays (annoying I know, but this comes up a lot on the > list so search the archives some or in the mean time just use Session > scope for your form to get it working). As I told you before, I deal with the ArrayList property of a bean which is already in session. My problem is I don't actually realize what is the object which is submitted by the form. You told it is the ArrayList itself, but how is it mapped onto the (Dynamic) form I've defined in stuts-config.xml? I don't understand why I get the IndexOutOfBoundsExceptions. It seems the ArrayList which is passed to the form-bean is null or empty. thanks -- Paride Perazzolo [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using struts-nested tags
>> > scope="session"> > > You shouldn't need the above on the page. You should set > MyBeanContainer with the id "beanContainer" into session or request > scope in the Action you are in "BEFORE" you get to this JSP page. The > page will have it. No need to use the useBean stuff. > ok, now I understand what you mean. I should never access session beans in my jsp, but being aware of the 1-1 relationship between the page form and the one which I defined in the struts-config.xml So I'm going to update the form beans (using objects like containers and navigators in session) in the related actions before passing control to JSPs and/or after submitting the form. I think this is the correct procedure to use. thanks for your help -- Paride Perazzolo [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Using struts-nested tags
Hello folks 2 days ago I wrote: > from struts-config.xml the definition of the form follows: > > > type="org.apache.struts.validator.DynaValidatorActionForm"> > > the definition of the associated action is (note the scope parameter): My approach: I extract from session the bean I use to initialize the form. I do this in the action which is called before passing the request to the JSP which implements canalizzazioneCLDForm: //this bean defines the listaDanneggiati property PartiteDanneggiatiView partite = new PartiteDanneggiatiView(); // extract from session the bean which returns the listaDanneggiati ArrayList SessionBeanContainer beanContainer= getSessionContainer(request);if (beanContainer != null) { //this is obvious partite.setListaDanneggiati((ArrayList)beanContainer.getListaDanneggiati());} // puts form into the request setFormIntoTheRequest("canalizzazioneCLDForm", partite, request); // Now the request is passed to the JSP: . when I submit the form I get the following > I need this to manage the interactivity correctly. Infact what I > actually get when I submit the form is the following:> > java.lang.IndexOutOfBoundsException: Index: 0, Size: 0 > at java.util.ArrayList.RangeCheck(Unknown Source) > at java.util.ArrayList.get(Unknown Source) > at > org.apache.struts.action.DynaActionForm.get(DynaActionForm.java:298) at > > org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:474) > at > > org.apache.commons.beanutils.PropertyUtils.getIndexedProperty(PropertyUtils.java:428) > at> > but if I change the scope of the action above to "session" and I call setFormIntoTheSession() instead of setFormIntoTheRequest() all works nice. This is obvius, but my problem is: I don't like to set the action scope to "session". Is there a way to set it to "request" and let all working right? thanks in advance -- Paride Perazzolo [EMAIL PROTECTED] - To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]