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.
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......
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.
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 ]