NetBeans Forums
| View previous topic :: View next topic |
| Author |
Message |
krahe
Joined: 11 Aug 2011 Posts: 6 Location: Rockford, Michigan
|
Posted: Sat Aug 13, 2011 4:58 am Post subject: What is the simplest way to get started developing a web application with NetBeans? |
|
|
I'm an ace at developing client/server applications in Java Swing, and am also an expert at designing databases and crafting SQL for all of the popular DBMSs. I am now, however, tasked with developing a web application with a database back-end. It will include several CRUD forms, and will also access some web services. The end product will most often be a document or report that is downloaded to the user or displayed in their browser.
Can anyone provide at least a rough outline of how I might go about developing such an application, including which technologies might be recommended? I did develop a simple web application a few years ago using NetBeans and Woodstock components. However, Woodstock seems to be no longer an active project, so I think I should look elsewhere for the functionality it provided. I think I want to stick with JavaServer Faces, which I believe was also the mechanism behind Woodstock. I have a basic understanding of application, session and request beans, as well as most of the other back-end stuff (e.g. database access using JDBC resources defined in Glassfish). I used to think I had a pretty good understanding of JSF itself, too (I have Core JavaServer Faces, Second Edition by David Geary and Cay Horstman). However, when I look at some of the more current NetBeans tutorials and some of the file types that NetBeans (7.0) will create, my mind is just boggled. I've found something called PrimeFaces that seems to a possible replacement for Woodstock, but unlike Woodstock, with PrimeFaces NetBeans seems to offer almost no help for the process of defining web pages and assembling components for the user to use. Then there are Facelets, Facelets templates, Cascading Style Sheets, Facelets Composite Components, JSP, XHTML vs. HTML, JSF Pages, etc. I'm sure that someone had a good reason to come up with all these technologies, but each one seems to add a layer of abstraction that makes it difficult to comprehend the operation of even a simple application. Is there just one or two presentation/interaction technologies that I might start with that will let me at least accomplish the basics, even if they lead me into the sort of problems some of these other technologies were designed to address? Are there any good tutorials or books that might help me figure it all out? Thank you for any help you can offer. |
|
| Back to top |
|
 |
mdeggers
Joined: 28 Jan 2009 Posts: 208
|
Posted: Sat Aug 13, 2011 9:45 pm Post subject: |
|
|
That's a tall order.
Yes, there are a lot of technologies out there. Picking one versus the
other is likely to start a religious war on the scale of emacs versus
vi (or in this forum's case, NetBeans versus Eclipse).
That being said, here's one approach.
First Steps
1. Start with the basics.
Understand the plumbing first before you go with the eye candy and
framework of the day. A good book that I've found is:
Head First Servlets and JSP, 2nd Edition by Basham, Sierra, Bates
It doesn't cover the lastest servlet specification, but it's a great
place to start. I have the first edition.
All of the frameworks are designed to make building large applications
using this technology easier, more repeatable, more manageable, and
more maintainable.
2. Learn basic HTML and CSS
This is the basic presentation layer. All of the other stuff (various
toolkits, frameworks, javascript, ajax, REST, etc.) build on this.
I imagine that the Head First books are good places to start, but I've
not used them. I mostly glean information from the following two web
sites:
http://www.alistapart.com/
http://www.csszengarden.com/
While neither of these two web sites are tutorial in approach, they
both show what good HTML and CSS are all about (and what's possible).
Writing clean and valid HTML and CSS is a good habit to get
into. Various browser bugs will make life a bit frustrating, but
welcome to the web.
With the above two understood, you should be able to write small to
medium web applications fairly easily.
Next Steps
You'll find at least two problems with the above simple approach.
1. The web applications aren't very "interactive"
2. Maintaining large web applications is painful
Interactivity - Basics
Interactivity can be improved by JUDICIOUS use of javascript. Websites
that aren't useful without javascript should be scrapped (IMHO). That
being said, learning javascript is probably the next step.
I've not used the Head First books for this, but I imagine they're
good. I have a copy of Javascript, the Definitive Guide. This works
well for me.
Javascript by itself is a general purpose scripting language. What
you'll be interested in is manipulating the DOM (document object
model), and AJAX.
For basic Javascript / DOM instruction, you might try the following
web site:
http://www.learn-javascript-tutorial.com/
It's not bad, but you will have to pay for the solutions. Most of the
stuff is not difficult, so that should be no problem.
I'm sure there are many other sites available with a tutorial approach
to Javascript.
Interativity - Responsiveness
While the above will give you lots of eye candy and local form
validation, it will not get you the responsiveness you desire. To do
this, you'll need AJAX.
Learning javascript in detail is not a prerequisite for learning about
AJAX, but it does help.
A good book for learning AJAX is the following:
Head Rush Ajax by McLaughlin
Much like the Head First Servlets and JSP book, this will give you the
ability to write AJAX by hand. It uses PHP instead of Java, so
translating the examples to servlets and JSP should be a good exercise
of your new-found servlet/jsp knowledge.
Building and Maintaining Large Web Sites
Now, finally the fun part.
You have the basics down:
1. Servlets and JSP
2. HTML and CSS
3. Some javascript and AJAX
Reinventing the wheel and managing the complexity can be pretty
painful for large projects. Fortunately there are many frameworks to
help out with this.
Java Frameworks
There are a lot. NetBeans has good support for a few:
Spring - this seems to be the most widely used.
I like Spring for the most part. There are some idiosyncrasies that
I'm not happy with, but I can work around them. The Spring testing
libraries have recently been integrated with NetBeans, so unit testing
Spring applications is no longer a major challenge.
JSF / JSF 2
I think that JSF (especially JSF 2) is in many ways more elegant than
Spring. Unfortunately JSF 2 outputs XHMTL by default. While I like
XHTML, Microsoft (currently, but that apparently will change)
doesn't. There are work-arounds, but none are really completely
satisfactory.
Struts
This is an older framework, but many still swear by (or at) it. Struts
2 is the way to go, but you'll need to enable the development /
community plugin repository to get Struts 2 support. The Struts 2
libraries that come with the Struts 2 plugin are out of date, so it's
best to use the Struts 2 support combined with a Maven Struts 2
project.
My major challenge with Struts 2 is its dependence on Freemarker as a
styling language. I'm not so happy with coupling a programming
language to styling.
ORM (Object - Relational Mapping) Frameworks
If you end up writing database-driven web applications, you'll find
the tedium of JDBC to be . . . tedious. Hopefully you'll at least use
JNDI and connection pools, but you'll still end up writing lots of
boilerplate code. Fortunately there are two platforms with good
NetBeans support.
Hibernate - this seems to be the most widely used
I end up using Hibernate in most of my large projects. There are
several good tutorials online, for example:
http://netbeans.org/kb/docs/web/hibernate-webapp.html
Some people have noted issues with this tutorial. Check the forums to
make sure.
My major issue with Hibernate is its cavalier attitude towards
Tomcat. Some of the assumptions made by Hibernate don't play well with
Tomcat. Some of the suggestions (use of ThreadLocal and filters) can
be pretty dangerous and create memory leaks if not used carefully.
A wiki article for getting Hibernate to play nicely with Tomcat's JNDI
pool can be found here:
http://wiki.apache.org/tomcat/TomcatHibernate
It's a bit dated, but it should work.
JPA 2 - EclipseLink
This is a fairly new standard for ORM. Since it's a standard,
hopefully there will be many implementations of it. I've not used this
yet, since I have not figured out how to get the unmanaged JNDI pool
of Tomcat to play nicely with JPA 2. By default, JPA 2 expects a
managed JNDI pool (such as provided by Glassfish, JBoss, etc.). Tomcat
is a servlet container (not an application server), and does not
provide the complete J2EE functionality.
I like Tomcat. It's lightweight, easy to configure, and support for it
in NetBeans is solid. I suspect that there are some JNDI tricks to get
this to work, but I've not investigated.
Javascript Frameworks / Libraries
The most popular one seems to be jsQuery. NetBeans has support for
this in the development / community plugin repository. I'm not a huge
fan of Javascript, so I cannot comment on this library.
All in One Frameworks
Again, putting all of these components together in one application can
be a bit confusing. Fortunately there are some frameworks that manage
to do all of this out of the box.
One framework that I've briefly looked at is ICEfaces. The home page
can be found here:
http://www.icefaces.org/main/home/home.iface
There are plenty of tutorials, a NetBeans plugin, and lots of
libraries.
While it is tempting to just start developing in ICEFaces, that's
probably not a good idea. ICEFaces does a lot for you under the
covers, and a solid grounding in the basics (servlets, jsp, html, css,
javascript, ajax, jdbc/orm, jsf) will be helpful.
Summary:
1. Basics
JSP and Servlets
HTML and CSS
Javascript / AJAX
2. ORM
Hibernate
JPA 2
3. Frameworks
Spring
Struts 2
JSF 2
4. Platforms
ICEFaces
This of course is my opinion. Debating all of these issues will start
multiple flame wars. However, do not avoid learning the basics.
. . . . just my two cents.
/mde/ |
|
| Back to top |
|
 |
Glenn Holmer Posted via mailing list.
|
Posted: Mon Aug 15, 2011 6:05 pm Post subject: Re: What is the simplest way to get started developing a web application with NetBeans? |
|
|
On Sat, 2011-08-13 at 04:58 +0000, krahe wrote:
| Quote: | I've found something called PrimeFaces that seems to a possible
replacement for Woodstock, but unlike Woodstock, with PrimeFaces
NetBeans seems to offer almost no help for the process of defining web
pages and assembling components for the user to use. Then there are
Facelets, Facelets templates, Cascading Style Sheets, Facelets
Composite Components, JSP, XHTML vs. HTML, JSF Pages, etc. I'm sure
that someone had a good reason to come up with all these technologies,
but each one seems to add a layer of abstraction that makes it
difficult to comprehend the operation of even a simple application.
|
Welcome to the world of web programming! Personally, I hate it. I've
been a programmer for 25 years, and coding web apps is worse than coding
CICS apps in COBOL and assembler. I envision a brave new world where all
the horrible web apps are thrown away and everything is done with
networked Swing programs that run on the desktop. Of course, that
doesn't help you...
Re. visual web development, it's not as easy to provide as some people
seem to think. This presentation by one of the NetBeans developers gives
some good insight:
http://netbeans.org/project_downloads/www/NetBeans%20JavaOne%202010%
20Slides/netbeans-javaone2010-s314648-give-me-jsf-editor.pdf
The fanbois who keep asking for the visual web editor to come back tend
to ignore its obvious shortcomings. Rumor has it that it was originally
a prototype shown to a manager who said "Ship it!".
As far as current technologies go, I'd say you're on the right track.
IMHO, the best technologies for developing web apps right now are:
Java EE 6: this gives you JPA (object-relational mapping) and easy
configuration using annotations. For injection, you can use either JSF
managed beans (old-fashioned) or CDI ("Contexts and Dependency
Injection", see part V in the Java EE 6 tutorial linked below).
JSF and Facelets (using either PrimeFaces or ICEfaces components):
probably as easy as it's going to get, and Facelets templating can save
you a whole lot of time. PrimeFaces is under heavy development and tends
to be a bit of a moving target compared to ICEfaces, which is more
conservative. PrimeFaces has sexier components, but makes you do more
work compared to ICEfaces.
| Quote: | Are there any good tutorials or books that might help me figure it all
out?
|
http://netbeans.org/kb/trails/java-ee.html
http://download.oracle.com/javaee/6/tutorial/doc/index.html
A book I'd highly recommend for learning JPA is Pro EJB 3 by Mike Keith
and Merrick Schincariol.
--
____________________________________________________________
Glenn Holmer address-removed
Software Engineer phone: 414-908-1809
Weyco Group, Inc. fax: 414-908-1601 |
|
| Back to top |
|
 |
Jeffrey Rubinoff Posted via mailing list.
|
Posted: Mon Aug 15, 2011 11:51 pm Post subject: Re: What is the simplest way to get started developing a web application with NetBeans? |
|
|
I suggest you look at the multi-part NetBeans ECommerce tutorial,
although that uses JSP instead of JSF
http://netbeans.org/kb/docs/javaee/ecommerce/intro.html
http://netbeans.org/kb/trails/java-ee.html also includes several JSF 2.0
tutorials.
Jeff
On 8/13/2011 6:58 AM, krahe wrote:
| Quote: | I'm an ace at developing client/server applications in Java Swing, and am also an expert at designing databases and crafting SQL for all of the popular DBMSs. I am now, however, tasked with developing a web application with a database back-end. It will include several CRUD forms, and will also access some web services. The end product will most often be a document or report that is downloaded to the user or displayed in their browser.
Can anyone provide at least a rough outline of how I might go about developing such an application, including which technologies might be recommended? I did develop a simple web application a few years ago using NetBeans and Woodstock components. However, Woodstock seems to be no longer an active project, so I think I should look elsewhere for the functionality it provided. I think I want to stick with JavaServer Faces, which I believe I was also the mechanism behind Woodstock. I have a basic understanding of application, session and request beans, as well as most of the other back-end stuff (e.g. database access). I used to think I had a pretty good understanding of JSF itself, too (I have Core JavaServer Faces, Second Edition by David Geary and Cay Horstman). However, when I look at some of the more current NetBeans tutorials and some of the file types that NetBeans (7.0) will create, my mind is just boggled. I've found something called PrimeFaces that seems to a pos
sible replacement for Woodstock, but unlike Woodstock, with PrimeFaces NetBeans seems to offer almost no help for the process of defining web pages and assembling components for the user to use. Then there are Facelets, Facelets templates, Cascading Style Sheets, Facelets Composite Components, JSP, XHTML vs. HTML, JSF Pages, etc. I'm sure that someone had a good reason to come up with all these technologies, but each one seems to add a layer of abstraction that makes it difficult to comprehend the operation of even a simple application. Is there just one or two presentation/interaction technologies that I might start with that will let me at least accomplish the basics, even if they lead me into the sort of problems some of these other technologies were designed to address? Are there any good tutorials or books that might help me figure it all out? Thank you for any help you can offer.
|
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|