Wrox Home  
Search P2P Archive for: Go

  Return to Index  

servlets thread: Servlets


Message #1 by "manish verma" <manish_verma_vk@r...> on Mon, 18 Feb 2002 09:21:38
Hi there Manish,

I've been experimenting with something similar to your
gui servlet spec.

What I did first was to create classes to describe the html gui
objects that I wanted to draw onto the page.
For example: class Textbox, class Table ...etc etc.
These classes implement a common interface called "Drawable"
that contains 1 method: public String draw() {...};
containing code that creates html code for the gui-object.
Then I created an 2 XML files, 1 to load all my different
gui-object's properties from and 1 to contain the layout template.
The layout template is a mix of regular html code and my own
tags indicating where I want the named gui objects to appear
in the template.
As the gui-objects properties are loaded from the first XML file, the objects are initialized, instanciated and put into a
Hashtable.
Then the servlet iterates through the Hashtable of gui-objects
and calls each objects draw() to make it render itself into html like:
Drawable gui_object = (Drawable) my_hashtable.get(object_name_from_xml);
String gui_html_code = gui_object.draw();
This way I don't have to care what gui-object I'm dealing with as
it knows how to draw itself into html (that's the beauty of interfaces
in java).
Then I parse the layout template to find a tag containing the
name of the gui-object (same name as it is indexed in the Hashtable)
and then replace the tag with the gui_html_code string, ie. the html
code that the gui-object produced itself.

Hope this helps you and if you need any example code as how to
load your gui-objects from XML into a Hashtable or how to parse
a template then send me a mail at: hte@e...
and I'll be happy to share some code.

regards
 - Henrik


> Dear Friends,
>              Hi!
> I giving the spec for the servlet that i need to develop.Give me ur view 
> as tohow this could be developed using servlets and not jsp.
> 
> 1.To be able to design the GUI using variou classes available in servlets.
> 2.If you want to design the page all u need to do is call the servlet for 
> approprite job say for drawing table,border,textbox etc.
> Guide me about how should i dersign my application so that i am able to 
> draw a page.
> 
> Manish

  Return to Index