• 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

Generating Html

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a class that generates html
I then included that class in a servlet and call the methods to generate the page. This Page contains a standard two column layout with several div's on the left hand side. Each div contains either a radiobutton list or a checkbox list that receives information from a database.
The last div has four buttons: Submit,Reset,Export,Menu.

Now for the actual question.
How can I get the checkbox lists and Radio button lists to maintain the state of the items checked after the submit button is clicked.

The Reason.
The state needs to be maintained so the user can see what they have selected and also see the table the appears on the right hand side.

The Right hand Side.
The right hand side of the two column layout is a table that show the results of the the options selected on the left hand side. So in essence the left hand side is building the query.

This is a basic page that I have written several different modules for in asp.net.

Our Company is switching to java and I am trying to simplify the process by writting classes to generate the pages either html or jsp.
I have gotten the classes to generate the html out of the way but the question above is now the problem that I am running into.

Thank you in advance for your help.
Josh
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll need to pass the state of these objects to your HTML generator and then add the 'checked' attribute to the correct checkbox/radiobutton.

Assuming you're writing all this with a stringBuffer and you're passing the state of the last div as a string......


etc.....

Out of curiosity, since this is a new project, have you looked into any of the existing Server Side Java frameworks already out there, like Struts or Java Server Faces, before deciding to roll your own?

The MVC architecture does a fine job of separating Java and HTML code and, thus, simplifying development for the different parts of your team.
 
Josh Holt
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the help.

I haven't looked at the other frameworks.
I was trying to write one specific to what I am doing
but I guess I could take a look at those to see if this can be simplified.
 
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
Don't misconstrue Ben's reply to think that you must adopt a framework in order to create a well-structured MVC application.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bear Bibeault:
Don't misconstrue Ben's reply to think that you must adopt a framework in order to create a well-structured MVC application.



Absolutely.
If, however, your project can fit into one of the existing frameworks, you could possibly save yourself a lot of time working out issues that other people have already solved. There are threads in both the Servlets and JSP forums on this site debating the merits of the various frameworks.

The project I'm working on now is built on a home rolled MVC framework. I had just come of off a fairly large Struts project when I started this one. For various reasons, it wasn't a good fit here so I build my own, lighter framework.

I've published a VERY simple example MVC application at http://simple.souther.us called SimpleMVC that you can download and run if your interested in getting a basic idea of what MVC is about.

My main point was not to re-invent the wheel if you can get around it and, if are going to, know what you're getting yourself into. If you're new to Java and you haven't explored any of the frameworks out there, you should before making that kind of a decision, especially for large projects.

-Ben
[ January 04, 2005: Message edited by: Ben Souther ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic