facebook

facelets -> JSF 1.2

  1. MyEclipse Archived
  2.  > 
  3. UML Development
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #235305 Reply

    The Facelets project uses the JSF 1.2 XML schema instead of the JSF 1.1 DTD inside the faces-config.xml file. Unfortunately, the ME faces-config.xml editor displays an error: “cvc-elt.1: Cannot find the declaration of element ‘faces-config'”. It would be very nice if the editor supported the updated schema in the ME 4.0 release.

    Here is a sample faces-config.xml file:

    
    <?xml version='1.0' encoding='UTF-8'?>
    
    <faces-config xmlns="http://java.sun.com/xml/ns/j2ee"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-facesconfig_1_2.xsd"
        version="1.2">
                
      <!-- from project setup -->
      <application>
        <view-handler>
          com.sun.facelets.FaceletViewHandler
        </view-handler>    
      </application>
      
      <!-- our NumberBean we created before -->
      <managed-bean>
        <managed-bean-name>NumberBean</managed-bean-name>
        <managed-bean-class>tutorial.NumberBean</managed-bean-class>
        <managed-bean-scope>session</managed-bean-scope>
        <managed-property>
          <property-name>min</property-name>
          <value>1</value>
        </managed-property>
        <managed-property>
          <property-name>max</property-name>
          <value>10</value>
        </managed-property>
      </managed-bean>
      
      <!-- going from guess.xhtml to response.xhtml -->
      <navigation-rule>
        <from-view-id>/guess.xhtml</from-view-id>
        <navigation-case>
          <from-outcome>success</from-outcome>
          <to-view-id>/response.xhtml</to-view-id>
        </navigation-case>
      </navigation-rule>
    
      <!-- going from response.xhtml to guess.xhtml -->
      <navigation-rule>
        <from-view-id>/response.xhtml</from-view-id>
        <navigation-case>
            <from-outcome>success</from-outcome>
          <to-view-id>/guess.xhtml</to-view-id>
        </navigation-case>
      </navigation-rule>
    
    </faces-config>
    

    Thank you and keep up the great work!

    #235306 Reply

    This example file seems to open up okay in XMLSpy. However, I get the following stack trace when I run it within Tomcat:

    
    SEVERE: Parse Error at line 2 column 59: cvc-elt.1: Cannot find the declaration of element 'faces-config'.
    org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element 'faces-config'.
        at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(ErrorHandlerWrapper.java:236)
    

    That can’t be good…

    #236103 Reply

    tarantula
    Participant

    You have two separate but related issues here. The first is getting MyEclipse to validate your faces-config.xml file against the JSF 1.2 XML schema and the other is getting Tomcat to validate the same file.

    You can add user-defined DTDs to the MyEclipse XML catalog (Window > Preferences > MyEclipse > Editors > XML > XML Catalog) but I’m not sure about XML schemas. I’m reasonably sure that validation is failing in your Tomcat application for the same reason because your XML parser can’t find the schema. Maybe if you deployed the XML schema along with your project you might have better luck.

    A good test is to actually visit the URL used in the namespace of your DTDs/schemas. If you get a 404 or similar error, there’s a good chance that this is what’s causing your validation to fail. A workaround is to find a copy of the DTD/schema, save it locally, and change the key type from PUBLIC to SYSTEM.

    Also, keep in mind that out Facelets uses JSF 1.2, which is not supported by Tomcat, so if you want to use this version of JSF you should look at Sun’s glassfish project. Facelets also works with JSF 1.1 so I would recommend you use that version instead if you are deploying to Tomcat.

Viewing 3 posts - 1 through 3 (of 3 total)
Reply To: facelets -> JSF 1.2

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