how to use param of h:commandLink with rewrite module

Splash Forums Rewrite Users how to use param of h:commandLink with rewrite module

This topic contains 6 replies, has 3 voices, and was last updated by  facilus 1 year, 5 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #26962

    facilus
    Participant

    Hello,

    I’ve commandLink with action and param like this :

    <h:commandLink value="#{item.nomRecette.toUpperCase()}" action="#{recette.detailRecette}">
         <f:param name="idRecette" value="#{item.idRecette}" />
    </h:commandLink>

    this action generater this url :

    localhost:8080/myapp/detail.xhtml

    i want to change it with rewrite module like this :

    localhost:8080/myapp/recette/detail/{param-value}

    is it possible ?

    I’m trying this :

    .addRule(Join.path("/recette/detail/{p}").to("/detail.xhtml")).where("p").bindsTo(El.property("recette.idRecette"))

    it doesn’t work

    thank’s

    • This topic was modified 1 year, 5 months ago by  facilus.
    #26964

    Don’t use a commandLink here. Use a h:link instead. commandLinks will ALWAYS do postbacks. h:link instead will create simple HTML links.

    <h:link outcome="/detail.xhtml">
      <f:param name="p" value="#{item.idRecette}" />
      Click me
    </h:link>
    
    #26965

    facilus
    Participant

    I try in first to use h:link, but i must call method in managed bean before redirect ton detail.xhtml

    #26967

    If your commandLink is calling an action method, then your action method must return a redirecting navigation string. We have a utility for this:

    https://github.com/ocpsoft/rewrite/blob/master/integration-faces/src/main/java/org/ocpsoft/rewrite/faces/navigate/Navigate.java#L34

    return Navigate.to("/some/other/page.xhtml")

    #26968

    facilus
    Participant

    I must get my parametre.

    I’m trying do include spring with :

    <dependency>
    	<groupId>org.ocpsoft.rewrite</groupId>
    	<artifactId>rewrite-integration-spring</artifactId>
    	<version>2.0.12.Final</version>
    </dependency>

    and in my ExampleConfigurationProvideri’ve add the ManagedBean like this :

    @Autowired
    private MyBean bean;

    but when i start tomcat server, i’ve this error in log console :

    java.lang.RuntimeException: Could not instantiate service class org.ocpsoft.rewrite.spring.SpringExpressionLanguageProvider
    	at org.ocpsoft.common.services.ServiceLoader.loadEnriched(ServiceLoader.java:334)
    	at org.ocpsoft.common.services.ServiceLoader.loadClass(ServiceLoader.java:243)
    	at org.ocpsoft.common.services.ServiceLoader.loadService(ServiceLoader.java:234)
    	at org.ocpsoft.common.services.ServiceLoader.loadServiceFile(ServiceLoader.java:196)
    	at org.ocpsoft.common.services.ServiceLoader.reload(ServiceLoader.java:145)
    	at org.ocpsoft.common.services.ServiceLoader.iterator(ServiceLoader.java:394)
    	at org.ocpsoft.common.util.Iterators.asList(Iterators.java:40)
    	at org.ocpsoft.rewrite.servlet.RewriteFilter.init(RewriteFilter.java:115)
    	at org.apache.catalina.core.ApplicationFilterConfig.initFilter(ApplicationFilterConfig.java:279)
    	at org.apache.catalina.core.ApplicationFilterConfig.getFilter(ApplicationFilterConfig.java:260)
    	at org.apache.catalina.core.ApplicationFilterConfig.<init>(ApplicationFilterConfig.java:105)
    	at org.apache.catalina.core.StandardContext.filterStart(StandardContext.java:4830)
    	at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5510)
    	at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:150)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1575)
    	at org.apache.catalina.core.ContainerBase$StartChild.call(ContainerBase.java:1565)
    	at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
    	at java.util.concurrent.FutureTask.run(FutureTask.java:166)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    	at java.lang.Thread.run(Thread.java:722)
    Caused by: java.lang.NoClassDefFoundError: org/springframework/expression/ExpressionParser
    	at java.lang.Class.getDeclaredConstructors0(Native Method)
    	at java.lang.Class.privateGetDeclaredConstructors(Class.java:2413)
    	at java.lang.Class.getConstructor0(Class.java:2723)
    	at java.lang.Class.getDeclaredConstructor(Class.java:2004)
    	at org.ocpsoft.common.services.ServiceLoader.loadEnriched(ServiceLoader.java:312)
    	... 20 more
    Caused by: java.lang.ClassNotFoundException: org.springframework.expression.ExpressionParser
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1720)
    	at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1571)
    	... 25 more
    #26969

    Looks like you are missing the spring-expression dependency.

    #26971

    facilus
    Participant

    Thank’s Christian

    I resolve error of rewrite with changing the return value of action bean like this :

    return "detail.xhtml?faces-redirect=true&idBean=" + getId();

    And in rewrite class, i’ve add this rule and it works

    .addRule(Join.path("/bean/detail/{idBean}").to("/detail.xhtml"));

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

You must be logged in to reply to this topic.

Comments are closed.