This post originated from an RSS feed registered with Java Buzz
by Weiqi Gao.
Original Post: Dan Troesser: JSF and ASP.NET Side By Side
Feed Title: Weiqi Gao's Weblog
Feed URL: http://www.weiqigao.com/blog/rss.xml
Feed Description: Sharing My Experience...
Dan Troesser is this month's OCI Java lunch speaker. He'll be talking about something that I've been interested in but haven't has a chance to get into deeply: JSF and ASP.NET
First person is Dan now.
We are going to talk about ASP.NET and compare it with JSF. I have been learning about JSF for the past year and a half. I have heard people talking about ASP.NET as something that's similar to JSF. So I investigated ASP.NET myself. I also looked into NetBeans 5.5 Beta. If you haven't looked at NetBeans, you should.
I'm just going to demo some stuff.
Dan has installed NetBeans 5.5 Beta 2 and GlassFish, the Sun Java EE server in the demo machine. It also have MS SQL Server Express and Visual Web Developer Express.
Dan is starting up the SQL Server service now. And it is started now.
Dan is bringing up the Microsoft SQL Server tool, showing the data that is prepopulated: some inventory data.
Dan is startign up Visual Studio 2005 now.
I got a free copy of VS 2005 from a Microsoft event for free last year.
From VS 2005, Dan is creating a website: Shopping. Just a couple of clicks.
With ASP.NET, they try to get you to do stuff in the GUI designer and hide the code. You can get at the code, you they want you to use the GUI.
Dan drags a grid view onto the form, and maps it to data. You create a data source for each component on the form.
Now Dan hit Control-F5 to run it. And the data showed up.
If I wanted to edit the data, I can go back to the design view of the form to "enable paging", "enable sorting", and "enable editing", "enable deleting." Unfortunately, we can't enable deleting from the GUI.
Now I can sort, edit a row and delete a row.
I a few steps, I had just created a simple app that does simple editing.
I can also format the columns.
I do have to turn HTML encoding off. That was listed as an ASP.NET issue.
The next thing I want to do is to create a page that allows me to insert a new column.
Dan drags a details view control onto the form and set up a data source. When generate the data source, Dan uses an advanced feature that has a check box that says "generate INSERT ..."
Then Dan enabled enserting on the control, and made the default mode to be inserting.
A Control-F5 and the page showed up.
Dan drags a hyper link on to one of the pages.
I wish using the hyper link is easier.
We also want to enable an event in the details view, onItemInsert and hook it up with a method.
Dan then added the method to the .cs file of the page.
I'm going to call Server.Transfer() to transfer the control to the other page.
Dan hit a snag upon running this page and resorted to using a pre-build version of the demo.
Now I can edit, I can delete items.
That's just a simple little idea of how you can do thing in Visual Studio.
Now I'm going to switch to NetBeans.
Dan starts NetBeans 5.5 Beta 2. It's turning on modules now.
The release candidate works pretty good now. When I installed the SQL Server JDBC driver, I have to install it into the proper "domain".
I'm going to start a new project. I'm creating an enterprise project.
I don't really need an EJB module, just want to create the web application.
We have some configuration files. It actually created two projects, an enterprise project and a war project. The configuration files doesn't contain much.
I want to enable JSF. With JSF, everything is within a "f:view" tag. For the most part, it's a code centric approach. The JSF project has a simple little start page.
Now I want to create some database connections. I create "entities from databases".
Dan picks the tables and the columns from some wizard screens.
I selected the inventory table. I want to create a persistence unit. I choose the TopLink. I haven't tried anything else.
Dan shows us the data bound classes that's created for us. It's a JPA annotated POJO class. NetBeans also warns us that one of our names is a SQL-92 keyword.
Dan now creates JSP pages from a wizard.
Dan starts the GlassFish application server.
Dan shows the pages in IE.
I can select each item, edit it. I can delete things. I can add a new inventory item. And so forth.
So we are able to create a view of this database table pretty easily.
Now let's take a look at what was created.
Dan gives a lesson on JSF. The message tag, the form tag with its action attribute.
Dan clicks on the method name on the JSF page and NetBeans moves to the method in a generated InventoryControler class.
The navigation rules are specified in configuration files.
We can bind input fields to the fields on the generated entity classes.
The data table on the JSF page is the most complicated component. It uses collections from inventory.inventoriys.
It's pretty neat what it created for us. And it's pretty easy to go forward from here.
Brian now want Dan to change the getInventorys to a properly spelled out method name. NetBean's refactoring doesn't go as far as to also change what's on the JSP.
I just want to compare what JSF and ASP.NET in a very simple application. And they come out pretty much even.
Theron asked if JSF is taking off. Dan sais it is.
Brian brought up the Google Web Toolkit and has some very good word for it.
The lunch is over. First person is Weiqi now.
What Dan showed is on par with what the Ruby on Rails folks showed.