facebook

JSF Tutorial

  1. MyEclipse Archived
  2.  > 
  3. Documentation
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #300116 Reply

    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):

      <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):

    <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 !!!!

    #300159 Reply

    Loyal Water
    Member

    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.

    #301190 Reply

    guyr
    Member

    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:

    
    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:

    
            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:

    
            <br/>
            <h:messages infoClass="infoClass" errorClass="errorClass"
                layout="table" globalOnly="true"/>
    

    Hope this helps others.

    #301214 Reply

    support-joy
    Member

    Thank you Guy for sharing your notes. Appreciate you taking time to post this, this sure will help other forum users.

Viewing 4 posts - 1 through 4 (of 4 total)
Reply To: JSF Tutorial

You must be logged in to post in the forum log in