JSP and Java Swings reuse of code

Discussion in 'Java' started by ashish, Jun 29, 2006.

  1. ashish

    ashish Guest

    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.
     
    ashish, Jun 29, 2006
    #1
    1. Advertisements

  2. ashish

    Andrew T. Guest

    And that would be a ..network management system?
    Is the web user expected to have JavaScript enabled?
    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.
     
    Andrew T., Jun 29, 2006
    #2
    1. Advertisements

  3. ashish

    ashish Guest

    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
     
    ashish, Jun 30, 2006
    #3
  4. ashish

    Andrew T. Guest

    You're welcome - could I get you to post in-line as I do?
    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).
    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).
    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.
     
    Andrew T., Jun 30, 2006
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.