Annotation config issues concerning the parentId attribute

Splash Forums PrettyFaces Users Annotation config issues concerning the parentId attribute

This topic contains 7 replies, has 3 voices, and was last updated by  scarnett 6 years ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #17932

    scarnett
    Participant

    I’m not real sure what it is that i’m doing wrong here, but I cannot get the parentId attribute to work consistently with the @URLMapping annotation. I have multiple mappings defined in one bean like so:

    @URLMappings(mappings = {
    @URLMapping(id = "goods_home", pattern = "/goods", viewId = "/content/goods/home.xhtml"),
    @URLMapping(id = "goods_create", pattern = "/create", parentId = "goods_home", viewId = "/content/goods/maintain.xhtml"),
    @URLMapping(id = "goods_update", pattern = "/update/#{goods.goodId}", parentId = "goods_home", viewId = "/content/goods/maintain.xhtml")
    })
    public class GoodsBean {
    ...
    }

    Based off of the configuration shown above, the url’s should be the following:

    /goods

    /goods/create

    /goods/update/#{goods.goodId}

    But I am not getting the expected results. The two mappings that use the parentId aren’t being rendered with the prepended parent pattern:

    /goods

    /create

    /update/#{goods.goodId}

    Can someone fill me in on what I’m doing wrong here?

    My specs:

    prettyfaces 3.3.0-SNAPSHOT

    jsf 2.1.1-b04

    spring 3.0.5

    hibernate 3.6.1

    tomcat 6.0.32

    web.xml snippet

    <context-param>
    <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name>
    <param-value>com.foo</param-value>
    </context-param>
    <context-param>
    <param-name>com.ocpsoft.pretty.SCAN_LIB_DIRECTORY</param-name>
    <param-value>true</param-value>
    </context-param>
    <filter>
    <filter-name>hibernateFilter</filter-name>
    <filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>
    <init-param>
    <param-name>singleSession</param-name>
    <param-value>true</param-value>
    </init-param>
    </filter>
    <filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>
    <filter>
    <filter-name>prettyFacesFilter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
    </filter>

    <filter-mapping>
    <filter-name>hibernateFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    <filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>
    <filter-mapping>
    <filter-name>prettyFacesFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>ERROR</dispatcher>
    </filter-mapping>

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

    <servlet-mapping>
    <servlet-name>facesServlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
    <url-pattern>/faces/*</url-pattern>
    </servlet-mapping>

    #20952

    I don’t see any obvious configuration problem here. And I don’t think that it has something to do with the annotation-based configuration. But you could try (just for a test) to do the same configuration via the XML configuration file. But I really don’t think that this will make a difference.

    It seems like there is some other thing wrong here. You could try to debug the application and set a breakpoint at ParentingPostProcessor.createAncestry().

    This method performs the parenting postprocessing and is really straightforward. The interesting question is if this method gets executed correctly and what it does with your mappings.

    If you don’t want to spend much time on debugging you could create a ticket and attach a small sample application so I can start the debugging.

    http://code.google.com/p/prettyfaces/issues/list

    #20953

    scarnett
    Participant

    I was able to get my mappings to render correctly by modifying line #56 of the ParentingPostProcessor class.

    Original

    if (m.hasParent() && !seen.contains(m))

    Changed to

    if (m.hasParent())

    #20954

    This sounds like a bugaboo. I’ll take a look.

    #20955

    Bugaboo! ;)

    I just had a look at the code. UrlMapping implements equals() and hashcode() by just comparing the viewId property. I guess thats it!

    #20956

    scarnett
    Participant

    woohoo

    #20957

    I just committed a fix for this issue. I think it will work now as expected.

    Could you give the latest snapshots a try?

    https://github.com/ocpsoft/prettyfaces/wiki/Snapshots

    Thanks for debugging this! ;)

    #20958

    scarnett
    Participant

    Works great! Thanks!

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.

Comments are closed.