Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2006

Tip: Looking for answers? Try searching our database.

JSP and Java Swings reuse of code

Thread view: 
ashish - 29 Jun 2006 07:15 GMT
I am doing an NMS project which is going to be swing based application,
as well as JSP based Web application. Swing as well as JSP based front
ends should be doing almost same things having similar look and feel.

I want to reuse maximum possible code between web based and swing based
application. Any suggestions for reuse are welcome.

Thanks in advance.
Andrew T. - 29 Jun 2006 18:31 GMT
> I am doing an NMS ..

And that would be a ..network management system?

>..project which is going to be swing based application,
> as well as JSP based Web application. Swing as well as JSP based front
> ends should be doing almost same things having similar look and feel.

Is the web user expected to have JavaScript enabled?

> I want to reuse maximum possible code between web based and swing based
> application. Any suggestions for reuse are welcome.

http://www.google.com.au/search?hl=en&q=acronym+kiss&meta=

Keep your interface as simple as possible, especially given
you are going to use web pages as one interface.

For a browser with no JavaScript, that would suggest
limiting your GUI design to text fields and text areas,
buttons, radio buttons, checkboxes and drop down
boxes/lists.  All of theses components are standard
HTML FORM elements.

They would correspond to Swing components
JTextField, JTextArea, JButton, ButtonGroup,
JCheckBox and JComboBox/JList.

If the web based user is expected to have JS enabled,
that expands the range of GUI elements available.
A tree structure can be created using a nested listed
and a little JS/styles.  Sliders and spinners are also
relatively simple.

That adds JTrees, JSlider and JSpinner.

Layout is a different matter - I would be interested to hear
other people's experiences, but for my part, I would approach
it as nested layouts in the Swing GUI, and replicate that in
HTML (JSP) as nested tables.

HTH

Andrew T.
ashish - 30 Jun 2006 05:44 GMT
Thanks Andrew,

Yes it is going to be a Network Management System. We can enable Java
Script if it is not much resource consuming.

If I have option to go either for "Swing based stand alone application"
or "JSP based Web application", which one is going to be more efficient
in terms of performance/ resource consumption (CPU/ memory etc.) ?

Anybody had any good/ bad experiences ?

In terms of convenience there is no doubt, Web based application is a
better choice.

Regards
--ASHISH

> > I am doing an NMS ..
>
[quoted text clipped - 40 lines]
>
> Andrew T.
Andrew T. - 30 Jun 2006 11:52 GMT
> Thanks Andrew,

You're welcome - could I get you to post in-line as I do?

> Yes it is going to be a Network Management System. We can enable Java
> Script if it is not much resource consuming.

Unfortunately, you cannot do any such thing, that is the problem.

JavaScript is something the end-users's browser either has enabled
or has disabled (though some browsers and screen readers do not support
JS at all).

You at the server end can take measures to check if JS is enabled
and provide a 'Sorry this app requires JS' message or such, but you
simply cannot force it on the end user.  (Same with Java itself).

If the user has JS enabled, you're in luck.
It is not a resource hog, it is very quick and lightweight (the JS
in a page usually needs to wait for the JVM to load in applet/JS
interactions).

> If I have option to go either for "Swing based stand alone application"
> or "JSP based Web application", which one is going to be more efficient
> in terms of performance/ resource consumption (CPU/ memory etc.) ?

First - if I had the option of going either stand alone application or
web based application, I would definitely choose stand-alone.
There is a much richer set of GUI components available.
A stand alone app. also opens up new opportunities such
as restoring the application state at start-up, Drag-n-Drop,
multi-threading of the GUI, custom/animated components,
breaking you out of the linear model of web applications...

I would only consider the web-based app. if Java could not be
guaranteed on the target deployment machines.

The web-based application that requires a browser with
no Java is relatively resource light.  The Swing application
might be more weighty with the JVM, but not significantly so
(not on any PC built within the last 5-6 years).

> Anybody had any good/ bad experiences ?
>
> In terms of convenience there is no doubt, Web based application is a
> better choice.

Convenience for the end user?  Sure.  Not so much for the
developer - coding for web based GUI involves accounting
for browser incompatibilities.  By far the most difficult thing
to get right X-browser/X-plat is look and feel - which is a
matter Sun has devoted a lot of attention to.

Andrew T.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.