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

This topic contains 5 replies, has 2 voices, and was last updated by  deepak 1 year, 7 months ago.

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #26591

    deepak
    Participant

    Hi,

    I am trying to migrate from PrettyFaces 3.3.4 to Rewrite 2.0 using the Rewrite PrettyFaces compatibility module.

    For the most part it works, except for URLs with curly braces.

    The annotation was something like this:
    @com.ocpsoft.pretty.faces.annotation.URLMapping(
    id = “some-page”,
    pattern = “/myUrl/#{backingBean.param}”,
    viewId = “/myUrl.xhtml”)

    With PrettyFaces 3.3.4, a URL with curly braces in the parameter, for example, /myUrl/{curly}, was getting parsed but with Rewrite, the same URL throws this error:

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

    I believe that PrettyFaces 3.3.3 couldn’t handle this as well but PrettyFaces 3.3.4 did.

    Am I missing something to make it work with Rewrite?

    #26600

    Hmmmm. Looks like there is some issue with processing curly braces as path parameter values. Could you provide a minimal Maven app the reproduces this?

    #26604

    deepak
    Participant

    I don’t use Maven often. I could put together a small program that would use ANT. Would that work? I think I don’t have anything complicated, just a URL parameter that could expect a value with the curly braces.

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

    #26614

    Awesome, thanks. Could you perhaps file an issue for this?

    https://github.com/ocpsoft/rewrite/issues?q=is%3Aopen

    #26619

    deepak
    Participant
Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.

Comments are closed.