Search code examples
htmlprimefacesjsf-2.2glassfish-4eclipse-kepler

jsf2.2 application with primefaces


I am a beginner in developping web applications i am trying to use jsf2.2 with primefaces4.0 and html5 for the design of the pages but i don't know how to start and what to do. i read some books but i still can't figure out how to create the pages and control them ( i have a prior knowledge on html, css,php and javascript). Can some one please give me some references of tutoriels on the internet beacause i did search alot but i still have no idea. I look to know how the structure of the pages? how to work with facelets and how to use the primefaces components? just an example will get me to the point. I am using eclipse Kepler and glassfish 4.


Solution

  • What i have done to start programming the jsf and primefaces was:

    1. Decide the IDE. I have chosen Netbeans because i find it more to my liking with some serious help at many tasks with wizzards and so on.
    2. Download the documentation for primefaces for certain! u will need it like hell to find out at least the basics and keep coding with the same examples it contains. Take a sample code and then make small changes the time as to see what u have changed and how it behaves with the changes.
    3. It is absolutely necessity to find an ebook or printing of the : Java EE 6 with GlassFish 3 Application Server (from packt publishing). It refers to the Netbeans IDE but the main idea of programming jsf 2 is the same. it may have some outdated info but u need to start only.
    4. U do not have the immediate need of css or html 5 when using primefaces and jsf 2 but only the basics of html which the ide is helping alot. Off course u may need it for advanced pages but...leave it after u learn the basics 1st!
    5. Use paper pencil draw paper pencil draw paper pencil draw! Draw the page at paper 1st! the old school isnt DEAD yet! While u learning use easy styling and not complicated design. Develop it step by step. Always start with the Layout 1st!

    That were the general and a very fast advice!

    As for the main Programming jsf u should know that :

    • For start u will always have 1 java class that will maintain all your fields shown in the page. U Call it Backing bean.
    • You will always have a xhtml or jsf for the graphic display(what u see in the browser) that will use the backing beans info to show anything u want. (if it is just a page with static data then the backing bean may not be in need)
    • If u have a backing bean u will surely need anothe java class called controller. This one navigates and becomes the intermediate of what u will display with where will fetch it to display.
    • U used to have a configuration file called web.xml. With Jsf 2.2 u dont have to use it but only for special situations.

    All of the above can be summarised to these steps as start for netbeans:

    1. Create a web Application with Netbeans Wizzard
    2. In the project window (left side) create a new folder called resource
    3. in that new folder create at least 2 new folders. Called images, css. At the images folder u will put all your images (how suprising!)
    4. You project will already have an index page. This is the starting page for all web applicatons. Even it is just a site or an online Web application.
    5. Build the index page as u want it. and run the project.

    Assuming u have installed the netbeans with the Glassfish or Tomcat Application Server ( I prefer Glassfish, yes i forgot to mention that u need an application server to get the web pagesand genrally the web application to run) enabled then after a while the browser will be displaying the page u just changed!

    Hope u get the idea...but it is only the 0.01%. After doing the reading and experimenting u will reach at least the 30%! Just dont be dissapointed at first.

    One last Advice is to start creating Web Site designs with little volatile things on it so that u get accustomed to the behavior. Then move on to the databases and even later to the security of a web application. If it absolutely necessity for u to learn the jsf 2 and primefaces and so try searching for a webminar or seminar. But u already know that right? Good luck to your studies!