• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Presenting Data to User

 
Ranch Hand
Posts: 2206
2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have remote data in the form of parent child records. My idea is to get this data into a class as array objects. Then present this to the user in a table where the parent data is in the left cell of a table with the child records in the right cells. Then I need to the parent cell to be dynamic in nature so that part of the table could expand and colapse. Is this doable? So far I have the class creating two arrays. One array in a one dimensional array holding the parent records. The second array is a three dimensional array holding the parent, child field1, child field2. I am stuck on haow to get this into my servlet and thn to be presentd on my JSP. I do arrays of arrays all the time with two dimensional arrays but this seems tricky.
 
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To start with, I would try first to create the HTML for the page with a servlet, rather than a JSP page. I'm not sure if you could present such a complex, homegrown data structure with a commercial JSP tag library, or if it is even worth it to develop your own set of JSP tags.

Writing the HTML directly from the servlet code seems like a good way to start.
[ September 30, 2008: Message edited by: James Clark ]
 
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I advice you to write a taglib yourself to build the data presentation. Thus, the servlet build the Arrays, the presentation logic will be placed into the Taglib and your JSP will stay "clear". If you need any changes in the future, you go directly to the taglib.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by James Clark:
Writing the HTML directly from the servlet code seems like a good way to start.

I'll respectfully, but strongly, disagree. The only thing worse than putting Java code in a JSP, is moving HTML markup to Java.

I';d start by writing, by hand, the desired HTML construct. And then see if I could use the existing JSTL tags to "JSP-ify" it. If not, I'd then design custom tags to handle it.
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree with the statements about having Java code write the HTML from a servlet.

The key part of my sentence was "...seems like a good way to start." There is no need to find the perfect solution on the first try or to get bogged down with all the details, but get nothing accomplished.

The OP seems a bit lost with "how" he can get his data structure to display in an HTML table. The first thing to verify is that this array-based data structure can be manipulated to populate one or more HTML tables. If he can do it in a servlet, he could then move the code into a custom JSP tag at a later point in time. This is the better solution.

There could be other good ways to start, as indicated, e.g. via JSTL tags.
[ September 30, 2008: Message edited by: James Clark ]
 
Whose rules are you playing by? This tiny ad doesn't respect those rules:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic