Reply To: Problem with curly braces while migrating from PrettyFaces 3.3.4 to Rewrite 2.0

Splash Forums PrettyFaces Users Problem with curly braces while migrating from PrettyFaces 3.3.4 to Rewrite 2.0 Reply To: Problem with curly braces while migrating from PrettyFaces 3.3.4 to Rewrite 2.0

#26611

deepak
Participant

I have a sample application but unfortunately the forum does not allow me to upload files greater than 2MB. I am therefore pasting the code here:

Curly.java


import java.io.Serializable;

@javax.faces.bean.ManagedBean
@javax.faces.bean.ViewScoped
@com.ocpsoft.pretty.faces.annotation.URLMappings(mappings = {
    @com.ocpsoft.pretty.faces.annotation.URLMapping(
        id = "curly",
        pattern = "/#{curly.value}",
        viewId = "/curly.xhtml")
})
public class Curly implements Serializable {
    private static final long serialVersionUID = 2710681365383078191L;

    private String _value;

    public Curly() {
        System.out.println("Curly ctor");
    }

    public String getValue() {
        return _value;
    }

    public void setValue(String value) {
        _value = value;
    }
}

Curly.xhtml


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:ice="http://www.icesoft.com/icefaces/component">

    <h:head>
        <title>Curly braces in path parameters</title>
    </h:head>

    <h:body>
        <ice:outputText value="value of parameter: #{curly.value}"/>
    </h:body>
</html>

web.xml

<?xml version="1.0" encoding="UTF-8"?>

<web-app
    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-app_3_0.xsd"
    version="3.0">

    <context-param> 
        <param-name>javax.faces.PROJECT_STAGE</param-name>
        <param-value>Development</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.DEFAULT_SUFFIX</param-name>
        <param-value>.xhtml</param-value>
    </context-param>

    <context-param>
        <description>
                Set this flag to true, if you want the JavaServer Faces Reference
                Implementation to validate the XML in your faces-config.xml
                resources against the DTD. Default value is false.
        </description>
        <param-name>com.sun.faces.validateXml</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <description>
                Set this flag to true, if you want the JavaServer Faces Reference
                Implementation to verify that all of the application objects you
                have configured (components, converters, renderers, and
                validators) can be successfully created. Default value is false.
        </description>
        <param-name>com.sun.faces.verifyObjects</param-name>
        <param-value>false</param-value>
    </context-param>

    <context-param>
        <param-name>com.icesoft.faces.debugDOMUpdate</param-name>
        <param-value>false</param-value>
    </context-param>

    <!-- Faces Servlet -->
    <servlet>
        <servlet-name>Faces Servlet</servlet-name>
        <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>*.xhtml</url-pattern>
    </servlet-mapping>

    <servlet>
        <servlet-name>Resource Servlet</servlet-name>
        <servlet-class>com.icesoft.faces.webapp.CompatResourceServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>Resource Servlet</servlet-name>
        <url-pattern>/xmlhttp/*</url-pattern>
    </servlet-mapping>

    <servlet-mapping>
        <servlet-name>Faces Servlet</servlet-name>
        <url-pattern>/icefaces/*</url-pattern>
    </servlet-mapping>

    <context-param>
        <param-name>javax.faces.FACELETS_SKIP_COMMENTS</param-name>
        <param-value>true</param-value>
    </context-param>

    <context-param>
        <param-name>javax.faces.VALIDATE_EMPTY_FIELDS</param-name>
        <param-value>false</param-value>
    </context-param>
          
    <!-- Welcome files -->
    <welcome-file-list>
        <welcome-file>index.jsp</welcome-file>
        <welcome-file>index.html</welcome-file>
    </welcome-file-list>
</web-app>

faces-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<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_2_0.xsd"
    version="2.0">
 
</faces-config>

———————————————-

With this, the URL http://localhost:8181/curly/foo works

while http://localhost:8181/curly/{foo} throws:

java.lang.IllegalStateException: No parameter [foo] was set in the pattern [/curly/{foo}]. Call address.set(“foo”, value); or remove the parameter from the pattern.

Let me know if you need more information regarding my setup.

Thanks!