Tuesday, May 12, 2009

Using Maven's Apache MyFaces archetype with GlassFish v3

I've faced a simple task to create a component that will render a recursive unordered list that can be later on turned into an accordion. Nothing really fancy.

Since there's no such component that I know of to do the rendering in the way I want it to I've decided to create my own component.

Using Maven I've created a new project from MyFaces archetype available in the default Maven repository. Armed with an example application I started my work.

The shock came right after running the generated app for the first time. Here's a snippet of the jsp page:


<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
<html>
<head>
<title>Hello World</title>
</head>
<body>
<f:view>
<h:form id="mainForm">
<h:panelGrid columns="2">
<h:outputLabel for="name"
value="Please enter your name" />
<h:inputText id="name"
value="#{helloWorld.name}"
required="true"/>
<h:commandButton value="Press me"
action="#{helloWorld.send}"/>
<h:messages showDetail="true"
showSummary="false"/>
</h:panelGrid>
</h:form>
</f:view>
</body>
</html>


Using NetBeans (the only freely available IDE that makes sense for Java development) I've started GlassFish v3 and deployed my newly generated application to the server.
The "Run" option on project has opened Firefox with the right address and everything looked OK. So I thought: let's take a look at the generated Html before I start adding something to it. And that was the moment when the fun begun!

The generated HTML has the following structure:

1. Form (as a top-level element) with all the controls
2. Html with Head and Body containing some JavaScript code and nothing more.

Can someone explain to me the reason it is so difficult to produce some proper output even from the simplest application??? Is this something you'd put your money into (I mean like more than one dollar of course)?

2 comments:

  1. I'm just reading your post, this is (I think) the third comment I post (don't know if you are going to read it). But I got to ask, if you had ever try to post a comment in the richface website, I get so confuse about how in the "peoples" right mind can use this kind of garbae of framework, when I think I have found a work arround to do what I want to do the framwork (and that is why we use frameworks, to do what I want and not what they want me to do), it brokes in other part... and the output like you mention... It's Just Garbage!!!!!

    My company is actualy investing some money to develop an application with this frameworks, and I'm really seing just putting the money to the garbage can.

    Any suguestion about how can I open my companies eyes?

    thank you in advance.

    ReplyDelete
  2. Well,... The easiest part is to do nothing. If they'll find it out by themselves that what they've set out to do is not doable with the tools they've chosen they will have to do whatever it takes to make it right.

    As for you - if you don't feel well with the decisions someone else is making - change your position/job! It's so easy these days! And great job opportunities are all around the world.

    ReplyDelete