JSF2 environment set up

I am a new web developer who is struggling to even set up local development environment with Eclipse. My goal is to eventually put my idea into a cool website that could be hosted on 64MB private JVM Tomcat 6 server (here).

I tried everything I could last 4 days reading bunch of tutorial sites and came up with an Eclipse project which could be downloaded. download.

I am overwhelmed with integrating so many frameworks (I wasn't an open source guy before), I feel that I'm stuck. Following are some questions I have.

  1. How come when I run above project on Tomcat 6 server on local machine, I have to access it with "http://localhost/richfaces-tomcat6/" I want to be able to access it with "http://localhost/Namo/". Because "Namo" is going to be my website name.
  2. How come "http://localhost/richfaces-tomcat6/index.xhtml" is not showing the inputText at all?
  3. How come I cannot use "@Named" annotation for the managed beans? Instead I have to use "@ManagedBean". I read some where that @ManagedBean is really for the legacy system. Does this matter?
  4. I am trying to code in JSF 2 with a bit of Ajax features on the site. I read some where Richfaces is useful. Am I even on the right track with setting these up?

I know I am asking a lot of questions. I am so ready to have something set up locally and hit the books for JSF but I can't even get started on it which is very frustrating. I would really appreciate it if somebody could help me or guide me to right direction.

Answers


How come when I run above project on Tomcat 6 server on local machine, I have to access it with "http://localhost/richfaces-tomcat6/" I want to be able to access it with "http://localhost/Namo/". Because "Namo" is going to be my website name.

The context path defaults to the Eclipse project name. You should have edited the context path in one of the last steps of the Eclipse project creation wizard. You can always edit it afterwards in the Web Project Settings section of the project's properties (rightclick project and choose Properties).


How come "http://localhost/richfaces-tomcat6/index.xhtml" is not showing the inputText at all?

Apparenty the request URL did not match the URL pattern of the FacesServlet as definied in web.xml. The given URL expects it to be mapped on an <url-pattern> of *.xhtml. Eclipse defaults to /faces/* and/or *.jsf and would require you to open the page by either http://localhost/richfaces-tomcat6/faces/index.xhtml or http://localhost/richfaces-tomcat6/index.jsf. But mapping the FacesServlet on *.xhtml is much better.


How come I cannot use "@Named" annotation for the managed beans? Instead I have to use "@ManagedBean". I read some where that @ManagedBean is really for the legacy system. Does this matter?

The @Named annotation is part of CDI which is part of Java EE 6. Tomcat is however a simple JSP/Servlet container and not a full fledged Java EE container. You'd either need to install CDI yourself if you want to use it on Tomcat, or to replace Tomcat by a fuller fledged Java EE container, such as Glassfish 3 or JBoss AS. See also the Weld documentation (Weld is the codename of the CDI reference implementation). Note that you don't necessarily need CDI to get JSF to run. Using @ManagedBean ought to be sufficient for a simple web application.


I am trying to code in JSF 2 with a bit of Ajax features on the site. I read some where Richfaces is useful. Am I even on the right track with setting these up?

JSF2 already supports Ajax out the box with the <f:ajax> tag. RichFaces is just a component library which offers more enhanced components and skinnability support on top of the standard component set. See also Communication in JSF 2.0.


1, 2 JSF 2.0 tutorial with eclipse tomcat

3 @ManagedBean makes sense for applications that use JSF but do not use JSR 299

4 yes you can do some cool stuff using RF, also jsf 2.0 has support of <f:ajax> so without RF using default implementation you could also do the AJAX stuff


You have severe memory constraints, so I'd better recommend to look at lightweight templating engines like Velocity or Freemarker for your pages and MVC frameworks like Struts/Struts 2 or Spring MVC.


Need Your Help

iOS - Using Search API for Google Shopping

ios xcode json google-shopping-api google-shopping

My ultimate goal is to search for an item (using a query in code) and display some information from a JSON object using the Google Shopping API - Objective-C Client.