Friday 15 March 2013

java/spring/tiles - elegant way to display data from multiple entities? -


I have java / spring / tiles app - basically a collection of forms, at the end of this, a user Would have filled the figures of at least one unit or more than five.

I need to display a summary screen, which displays all the data entered by the user. At this point, I will know which objects the user has inserted and I have access to them. I was trying to come back in a clear way to display all that data. My initial idea was that it spit dynamically to use the Justil / L, but it got faster by hand I am trying to do this for each object:

  & lt; C: If test = "$ {empty object1}" & gt; $ {Object1.field1} $ {object1.field2} & lt; / C: If & gt; ... & lt; C: If test = "$ {Null object 5}" & gt; $ {Object5.field1} $ {object5.field2} & lt; / C: if & gt;   

I think it is necessary to have an account for five things like this worthless - it seems just unnecessary (plus more than two fields per object). Is there a better way to go about this kind of thing? I'm really very open to any solution, I just went down the JSTL path here because I thought there was a way to iterate on each object's fields, but if I did not get any examples. So some greasy, or just bash through it with jstl like this? Any suggestions would be most appreciated.

You can create an interface (example: GenericFormObject ) Objects are implemented by, and there is a method to display them as HTML (like: getHtmlString () ).

Then you store all of your form objects in one, and you do something similar in your JSP:

  & lt; C: forEach var = "formObj" item = "$ {formObjCollection}" & gt; $ {FormObj.html String} & lt; / C: forEach & gt;    

No comments:

Post a Comment