Navigation using path parameter on Pretty Faces 2.0.8.Final

Splash Forums PrettyFaces Users Navigation using path parameter on Pretty Faces 2.0.8.Final

Tagged: 

This topic contains 5 replies, has 3 voices, and was last updated by  Lincoln Baxter III 2 years, 6 months ago.

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

    Daniel Camargo
    Participant

    Consider the configuration below:

    @URLMapping(id = “programaManter”, parentId = “homeTreinamento”, pattern = “/programa/#{id : programaManter.id}”, viewId = “/pages/treinamento/ProgramaManter.xhtml”)

    Lets say that I need to navigate to **/programa/1**. I’ve tried the following:

    return “/pages/treinamento/ProgramaManter.xhtml?faces-redirect=true&id=” + id;

    But instead of navigating to **/programa/1** it’s navigating to **/programa/?id=1**, how can I force it to build the url using path parameter instead of query parameter?

    Attachments:
    1. sample.zip
    #25822

    Hey Daniel,

    I just had a look at your sample project. The problem is that you have two mapping for /pages/Second.xhtml:

    @URLMappings(mappings = {
      @URLMapping(id = "secondCreate", pattern = "/second", viewId = "/pages/Second.xhtml"),
      @URLMapping(id = "secondUpdate", pattern = "/second/#{id : second.id}", viewId = "/pages/Second.xhtml")
    })
    

    Now if you return something like this:

    return "/pages/Second.xhtml?faces-redirect=true&id=" + id;
    

    PrettyFaces basically search for a mapping with a matching view id. In your case the first mapping which such a view id is secondCreate. And as there is no id parameter in this parameter, it is added as a query parameter.

    To work around that you could use a PrettyFaces navigation string like this:

    this.id = 1;
    return "pretty:secondUpdate";
    

    This way you can tell PrettyFaces exactly which mapping to use for the redirect. With such an navigation outcome will extract the values directly from your bean properties to build the URL. So it is important to set the ID correctly.

    I hope this helps.

    Christian

    #25823

    Daniel Camargo
    Participant

    You were right, PrettyFaces gets the first mapping fo the list. I’ve changed the order of the mappings and it’s working now.

    Thank you!

    #25824

    Gah! Sorry for the delay. I was trying to buy a house. I also had trouble running yoru example. Which server did you use? I got this on JBoss AS7 and was unsure of how to resolve it:

    15:15:37,992 SEVERE [javax.enterprise.resource.webcontainer.jsf.config] (ServerService Thread Pool -- 71) Critical error during deployment: : com.sun.faces.config.ConfigurationException: The tag named passThroughAttribute from namespace http://xmlns.jcp.org/jsf/core has a null handler-class defined
    	at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processHandlerClass(FaceletTaglibConfigProcessor.java:415) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]
    	at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTags(FaceletTaglibConfigProcessor.java:371) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]
    	at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.processTagLibrary(FaceletTaglibConfigProcessor.java:314) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]
    	at com.sun.faces.config.processor.FaceletTaglibConfigProcessor.process(FaceletTaglibConfigProcessor.java:263) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]
    	at com.sun.faces.config.ConfigManager.initialize(ConfigManager.java:363) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]
    	at com.sun.faces.config.ConfigureListener.contextInitialized(ConfigureListener.java:216) [jsf-impl-2.1.19-redhat-2.jar:2.1.19-redhat-2]
    	at org.apache.catalina.core.StandardContext.contextListenerStart(StandardContext.java:3339) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    	at org.apache.catalina.core.StandardContext.start(StandardContext.java:3777) [jbossweb-7.2.2.Final-redhat-1.jar:7.2.2.Final-redhat-1]
    	at org.jboss.as.web.deployment.WebDeploymentService.doStart(WebDeploymentService.java:156) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    	at org.jboss.as.web.deployment.WebDeploymentService.access$000(WebDeploymentService.java:60) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    	at org.jboss.as.web.deployment.WebDeploymentService$1.run(WebDeploymentService.java:93) [jboss-as-web-7.3.0.Final-redhat-14.jar:7.3.0.Final-redhat-14]
    	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) [rt.jar:1.7.0_21]
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334) [rt.jar:1.7.0_21]
    	at java.util.concurrent.FutureTask.run(FutureTask.java:166) [rt.jar:1.7.0_21]
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) [rt.jar:1.7.0_21]
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) [rt.jar:1.7.0_21]
    	at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_21]
    	at org.jboss.threads.JBossThread.run(JBossThread.java:122)
    #25825

    Yeah, I also ran into this. The project includes Mojarra as a compile scoped dependency. And including it in the WAR causes this exception on Wildfly. Changing the scope to provided fixed the problem for me.

    #25834

    Interesting. I’ve opened JIRA issue about this: https://issues.jboss.org/browse/WFLY-2897

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

You must be logged in to reply to this topic.

Comments are closed.