Riemann Robert (Platinion) wrote:
Hello everyone,
(a second post since my mail editor just made the posting unreadable...
sorry!)
I need your help with a tricky problem, where I do not see any explanation
currently:
I try to construct a table with all data items stored in a database using
Hibernate.
There is a Form bean for the data items themselves and a form bean with a
Collection (ArrayList) with the list of all such data items.
Here is the relevant JSP code
...
logic:present name=InterfacesOverviewForm
logic:notEmpty name=InterfacesOverviewForm property=interfacesItems
table
logic:iterate id=InterfacesOverviewData
name=InterfacesOverviewForm
property=interfacesItems
type=Presentation.form.InterfacesInputForm
tr
td
!-- put a property of the interfaces item in table cell --
html:text name=InterfacesOverviewData
property=mainId size=2/ !-- (**) --
/logic:notEmpty
logic:empty name=InterfacesOverviewForm
property=interfacesItems
No Interfaces data items stored yet. br /
/logic:empty
/logic:present
logic:notPresent name=InterfacesOverviewForm
No Interfaces data items available. br /
/logic:notPresent
In my OverviewInterfacesAction I do the following:
...
// read data from the persistence layer
Collection lDTOList = lService.readData();
// the list of form beans
ArrayList lFormInterfacesList = new ArrayList();
// convert DTO's to form beans
lFormInterfacesList = (ArrayList) convert(lDTOList);
// set the form bean collection into the form
lForm.setInterfacesItems(lFormInterfacesList);
// place the form with the collection into the request
pRequest.setAttribute(InterfacesOverviewForm,lForm);
// done
return (pMapping.findForward(Constants.SUCCESS));
}
I would expect that in my JSP, The iterate gets in each iteration one form
after the other out of the collection and that I have access to the
properties of the collection elements as in line (**)
Unfortunately there are two effects that I cannot explain:
1) With the code as above I get an Exception stating, that bean
InterfacesOverviewData cannot be found in any scope
Maybe convert() is returning null?
2) If I start the JSP with a
bean:define id=InterfacesOverviewData
name=InterfacesOverviewForm
type=Presentation.form.InterfacesOverviewForm/
I still get a different exception, but this time stating, that there is no
getter method for property mainId in form InterfacesOverviewForm, which is
correct since that form contains a Collection with elements which all have
a property mainId and getter getMainId().
Yes, but your bean:define binds IngerfacesOverviewData to an instance of
interfacesOverviewForm, not to the element type.
3) If I try to access the Collection instead of a property in line (**),
i.e. I change the line to:
html:text name=InterfacesOverviewData
property=interfacesItems
size=150/
Then I see the the ArrayList printed (I provided a toString() method in the
InterfacesInputForm (i.e. the form which represents an element of the
Collection), thoug obviously the Collection is there and can be accessed.
With or without the bean:define? Shouldn't that be
name=InterfacesOverviewForm?
4) A further observation which I cannot explain might indicate that the
heart of my error in not caused by the logic:iterate tag itself:
both branches of the surrounding logic:present and logic:empty checks,
i.e.,logic:present and logic:notPresent and logic:empty and logic:notEmpty
are executed (with the code as described until (3))
That sounds a bit odd... I'd suggest adding some debugging code to the JSP to
print out everything in the various scopes to make sure everything's as you
expect it.
L.
--
Laurie, Open Source advocate, Java geek and novice blogger:
http://www.holoweb.net/~laurie/
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]