Re: JSF code generation

Discussion in 'Java' started by David Segall, Dec 26, 2008.

  1. David Segall

    David Segall Guest

    "Ken T." <> wrote:

    >Using NetBeans one can put together a JSF user interface very quickly
    >using drag and drop controls and clicking on buttons to add actions.
    >
    >This is very much like the GUI code generation tool that is included in
    >NetBeans for the development of Swiing applications.
    >
    >I don't use the Swing GUI builder because it seldom works out exactly
    >like you want it too and the code is fairly ugly. In addition, I'm
    >concerned that I will have to edit the code by hand at some point because
    >it quits working with NetBeans either due to an upgrade of NetBeans or a
    >problem with the code or for whatever reason.
    >
    >So, I thought I'd ask in this group. How many of you use this kind of
    >code generation tool for your development in either Swing or for Web
    >applications? Do you find the positives to outweigh the negatives? What
    >are the positives and negatives in your opinion? Under what conditions
    >would you avoid these code generation tools?
    >
    >I looked the JSP output from using the JSF generation tool and I was very
    >disappointed by the result. I can't really tell what is going on when I
    >look at the JSP code. Of course I'm new to JSF, but this doesn't look at
    >all like I would expect it too. Does one get used to this code or is it
    >write only code?

    Don't look! Between the time you write your program and your user is
    interacting with it on their computer it has probably been encoded in
    a dozen different ways. Why single out the way NetBeans converts your
    instructions to HTML/JSF/JSP/Java for special attention?
    David Segall, Dec 26, 2008
    #1
    1. Advertising

  2. On Fri, 26 Dec 2008 13:51:27 +0000, David Segall wrote:

    > "Ken T." <> wrote:
    >

    [ SNIP ]
    >>I looked the JSP output from using the JSF generation tool and I was
    >>very disappointed by the result. I can't really tell what is going on
    >>when I look at the JSP code. Of course I'm new to JSF, but this doesn't
    >>look at all like I would expect it too. Does one get used to this code
    >>or is it write only code?

    > Don't look! Between the time you write your program and your user is
    > interacting with it on their computer it has probably been encoded in a
    > dozen different ways. Why single out the way NetBeans converts your
    > instructions to HTML/JSF/JSP/Java for special attention?


    Seems to me that if you're going to embrace NetBeans Visual Web JSF you
    may as well go whole hog, and *not* look too much at the generated JSP.
    Although to be fair to NetBeans, a fair bit of the messiness of the pages
    is due to the fact that it's JSP.

    As I've explained already, I prefer the cleanness of Facelets. I don't
    have a visual designer but I find that one is not needed. As much as
    possible I try to use the JSF standard tag libraries - Core & HTML. This
    takes care of a lot. For the rest of it, Facelets is much better at
    creating tags, which may or may not involve Java and/or JavaScript
    (frequently a Facelets tag is just more XHTML). In general the individual
    XHTML pages are much easier to read.

    I also find it possible to readily map the rendered HTML to my JSF source.

    As an aside, I note that Project Woodstock is now deprecated, and Sun is
    pushing ICEFaces. I've used ICEFaces some, and like it, but I haven't
    used it in NetBeans. Judging by this article (http://www.ensode.net/
    roller/dheffelfinger/entry/netbeans_icefaces_plugin_first_impressions) I
    guess that you'll still be using JSPs, _if_ visually designing, although
    one can of course set up ICEFaces to work with Facelets (I'll have to try
    that in NB 6.5).

    AHS
    Arved Sandstrom, Dec 27, 2008
    #2
    1. Advertising

  3. David Segall

    David Segall Guest

    "Ken T." <> wrote:

    >On Fri, 26 Dec 2008 13:51:27 +0000, David Segall wrote:
    >
    >>>I looked the JSP output from using the JSF generation tool and I was
    >>>very disappointed by the result. I can't really tell what is going on
    >>>when I look at the JSP code. Of course I'm new to JSF, but this doesn't
    >>>look at all like I would expect it too. Does one get used to this code
    >>>or is it write only code?

    >
    >> Don't look! Between the time you write your program and your user is
    >> interacting with it on their computer it has probably been encoded in a
    >> dozen different ways. Why single out the way NetBeans converts your
    >> instructions to HTML/JSF/JSP/Java for special attention?

    >
    >Because this might be the form the code takes in which I need to maintain
    >it. If I can't easily read and maintain the code, I really don't want
    >it.

    If you believe that a language may be abandoned by its promoters that,
    by itself, is a good reason for not using it. It happens that the
    intermediate output of NetBeans Visual Web Developer is human readable
    and even alterable but I think you should ignore that in exactly the
    same way that you ignore the readability of a class file written by
    javac. In practice, it could be difficult to maintain the JSF code
    written by NetBeans without the support of NetBeans developers because
    it contains tags written by them.

    Even if you ultimately decide not to use NetBeans Visual Web Developer
    I would still recommend it as a learning tool. It does its best to
    enforce a strict separation of JSF, HTML, CSS and Java and it tries to
    ensure that each is written to conform to Sun's conventions.
    David Segall, Dec 27, 2008
    #3
  4. David Segall

    David Segall Guest

    Arved Sandstrom <> wrote:

    >As an aside, I note that Project Woodstock is now deprecated, and Sun is
    >pushing ICEFaces. I've used ICEFaces some, and like it, but I haven't
    >used it in NetBeans. Judging by this article (http://www.ensode.net/
    >roller/dheffelfinger/entry/netbeans_icefaces_plugin_first_impressions) I
    >guess that you'll still be using JSPs, _if_ visually designing, although
    >one can of course set up ICEFaces to work with Facelets (I'll have to try
    >that in NB 6.5).

    Please post an account of your experience although I don't think I
    could handle producing a GUI or a printed report without a visual
    designer.
    David Segall, Dec 27, 2008
    #4
  5. On Sat, 27 Dec 2008 13:36:52 +0000, David Segall wrote:

    > Arved Sandstrom <> wrote:
    >
    >>As an aside, I note that Project Woodstock is now deprecated, and Sun is
    >>pushing ICEFaces. I've used ICEFaces some, and like it, but I haven't
    >>used it in NetBeans. Judging by this article (http://www.ensode.net/
    >>roller/dheffelfinger/entry/netbeans_icefaces_plugin_first_impressions) I
    >>guess that you'll still be using JSPs, _if_ visually designing, although
    >>one can of course set up ICEFaces to work with Facelets (I'll have to
    >>try that in NB 6.5).

    > Please post an account of your experience although I don't think I could
    > handle producing a GUI or a printed report without a visual designer.


    For NB 6.5 Facelets development with ICEFaces, do the following (I banged
    out a simple user login project out this morning, so essentially a single
    page app with a single managed bean, Facelets XHTML containing ICEFaces
    components. In fact I did it twice to reassure myself on the steps):

    0) Prerequisites: install the 2 ICEFaces plugins (they're in the standard
    plugins list). Also, obtain the latest ICEFaces binary - for the life of
    me I can't find icefaces-facelets.jar anywhere with NB proper.

    1) create new Web project and add ICEFaces (not Visual Web
    ICEFaces...that'll give you JSPs) and Facelets. No need for clicking off
    JavaServer Faces. Interestingly enough, when you check project Properties
    > Frameworks later on, it'll say ICEFaces and JavaServer Faces, and

    sometimes leave out Facelets...apparently not anything to worry about
    though.

    2) You'll get an ICEFaces welcome JSP, plus a template.xhtml and template-
    client.xhtml for Facelets. This is the first clue that NB is behaving OK
    so far. Go ahead and zap the JSP.

    3) Go into project Properties > Libraries, and zap jsf-facelets.jar. Add
    the icefaces-facelets.jar from the ICEFaces distro.

    4) We'll work with template.xhtml & template-client.xhtml for now. Add
    this namespace to both:

    xmlns:ice="http://www.icesoft.com/icefaces/component"

    (Strictly speaking you'll only need it in Facelets pages that use
    ICEFaces components).

    4) Our start page is template-client, so in project Properties > Run
    change that to "template-client.iface". You can also edit the welcome
    file list in web.xml to remove the welcome JSP and put in template-
    client.iface instead. No real changes to web.xml are required.

    5) In faces-config.xml, change the view-handler from
    com.sun.facelets.FaceletViewHandler to
    com.icesoft.faces.facelets.D2DFaceletViewHandler.

    6) After putting some content into template-client.xhtml (into the
    <ui:define name="body"> bit), and adding my managed bean to faces-
    config.xml, I'm able to deploy and run it. I've included the template-
    client.xhtml and the faces-config.xml below for verification purposes.
    The managed bean is called LoginBean and has String fields for "name" and
    "password", corresponding accessors, and one action method called
    "doLogin" (for now it's printing out the fields and returning null to
    bring us back to the login page).

    NOTE: in real life I wouldn't bother using ICEFaces for anything like in
    this example. I'd use standard JSF HTML. As it happens with this setup
    JSF Core/HTML and ICEFaces tags coexist peacefully.

    Also, no guarantees that this project configuration is absolutely problem-
    free. I just set it up this morning. In particular, at the moment when
    you create a new Facelets file (simple, template client or template) it
    only has the namespace for Facelets, none for ICEFaces or JSF, so I'd
    have to manually add those in right now. I'll experiment a bit and see
    what I can figure out.

    AHS

    A. Important chunk of template-client.xhtml:

    <ui:define name="body">
    <h:messages/>
    <ice:form>
    <ice:panelGrid columns="2">
    <ice:eek:utputLabel value="Username: "/>
    <ice:inputText id="name" value="#{loginBean.name}" required="#
    {true}"/>
    <ice:eek:utputLabel value="Password: "/>
    <ice:inputSecret id="password" value="#{loginBean.password}"
    required="#{true}"/>
    </ice:panelGrid>
    <ice:commandButton id="saveBtn" value="Enter" action="#
    {loginBean.doLogin}"/>
    </ice:form>
    </ui:define>

    B. faces-config.xml (less header):

    <application>
    <view-handler>com.icesoft.faces.facelets.D2DFaceletViewHandler</view-
    handler>
    </application>
    <managed-bean>
    <managed-bean-name>loginBean</managed-bean-name>
    <managed-bean-class>org.ahs.beans.LoginBean</managed-bean-class>
    <managed-bean-scope>request</managed-bean-scope>
    </managed-bean>
    Arved Sandstrom, Dec 27, 2008
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. dudu
    Replies:
    0
    Views:
    366
  2. Sebastian Fey

    JSF debugging / JSF newsgroup

    Sebastian Fey, Apr 7, 2006, in forum: Java
    Replies:
    1
    Views:
    7,613
    Danno
    Apr 7, 2006
  3. BlackIce
    Replies:
    1
    Views:
    17,153
  4. Arved Sandstrom

    Re: JSF code generation

    Arved Sandstrom, Dec 25, 2008, in forum: Java
    Replies:
    3
    Views:
    1,295
    Arved Sandstrom
    Dec 26, 2008
  5. John W. Long

    HTML Generation (Next Generation CGI)

    John W. Long, Nov 22, 2003, in forum: Ruby
    Replies:
    4
    Views:
    319
    John W. Long
    Nov 24, 2003
Loading...

Share This Page