| Author |
Message |
|
|
Post subject: JSF Tutorial
Posted: Jul 02, 2009 - 07:08 PM
|
|
Joined: Jul 02, 2009
Posts: 1
|
|
After much pain in trying to figure out why the JSF wasn't working for me, I found a few things to help those going through the same thing:
1) Make sure your web.xml file has the following in it (excluding the code tags, if they show up):
| Code: | <context-param>
<param-name>javax.faces.CONFIG_FILES</param-name>
<param-value>/WEB-INF/faces-config.xml</param-value>
</context-param> |
2) Make sure your faces-config.xml file has the correct root tag (again excluding the code tags), where I had to change all j2ee to javaee, and 1-up some versions (else my SAX parser would blow up on loading the .faces file):
| Code: | <faces-config xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
version="1.2"> |
3) If using Tomcat, use the MyEclipse Tomcat first.
4) If you're still having trouble, download the JSF demo example and see that it works first. Then work backwards from there, comparing yours to it and seeing where the deltas may be.
Lastly, this took me about 2 days to get working, but it was all due to deltas in version changes between JSF code/parsers. It was ugly, but with persistence you can WIN too !!!! |
|
|
| |
|
|
|
 |
|
|
Post subject: RE: JSF Tutorial
Posted: Jul 06, 2009 - 08:57 AM
|
|
Registered Member


Joined: Apr 18, 2007
Posts: 8013
|
|
Im sorry you ran into all these problems but you took the correct steps to trouble shoot the issue. Glad everything is working fine now. |
_________________ Nipun
MyEclipse Support
|
| |
|
|
|
 |
|
|
Post subject: RE: JSF Tutorial
Posted: Aug 06, 2009 - 10:02 PM
|
|

Joined: Oct 22, 2004
Posts: 22
|
|
Thanks for pointing out the updates. One more minor note regarding faces-config.xml: removed the DOCTYPE line.
Unfortunately, I'm still having trouble with this tutorial. I downloaded the zip, created a new Web Project from existing source, adding JSF capabilities, and made your modifications. The login page displays okay, and if I enter the proper credentials, I see the message "Hello myeclipse, you successfully logged in!" But when I enter some invalid credentials, I see the following in the console log:
| Code: |
Aug 6, 2009 4:57:02 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent
WARNING: Unable to find component with ID 'userName' in view.
Aug 6, 2009 4:57:03 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent
WARNING: Unable to find component with ID 'password' in view.
Aug 6, 2009 4:57:11 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent
WARNING: Unable to find component with ID 'userName' in view.
Aug 6, 2009 4:57:11 PM com.sun.faces.renderkit.html_basic.HtmlBasicRenderer getForComponent
WARNING: Unable to find component with ID 'password' in view.
|
I'd appreciate some pointers to get this working. I have a Pulse-based installation running MyEclipse 7.5. Thanks.
Later ...
Ok, I figured this one out myself using Google, which found this post:
http://www.manning-sandbox.com/thread.jspa?messageID=51841
The warnings I'm seeing above come from JSP and JSF lifecycle differences. For purposes of this quick tutorial, the easiest solution is just to remove the "for" clauses from the labels. The option suggested in the reference is to wrap contents in a PanelGrid, which I did not try.
My next issue was that if I added bad credentials, it simply came back to the userLogin page without the password showing, so I couldn't really tell what had happened. I addressed this by adding the following to UserBean.loginUser, before returning failure:
| Code: |
FacesContext facesContext = FacesContext.getCurrentInstance();
facesContext.addMessage(null, new FacesMessage(
FacesMessage.SEVERITY_ERROR, "Login failed, bad username or password", null));
|
and then adding this in userLogin.jsp after the commandButtons:
| Code: |
<br/>
<h:messages infoClass="infoClass" errorClass="errorClass"
layout="table" globalOnly="true"/>
|
Hope this helps others. |
_________________ Guy Rouillier
|
| |
|
|
|
 |
|
|
Post subject: RE: JSF Tutorial
Posted: Aug 07, 2009 - 11:10 AM
|
|
Registered Member


Joined: Feb 03, 2009
Posts: 3364
|
|
Thank you Guy for sharing your notes. Appreciate you taking time to post this, this sure will help other forum users. |
_________________ Joy
MyEclipse Support
|
| |
|
|
|
 |
|
|
|