Outbound rewriting with El.property not working

Splash Forums Rewrite Users Outbound rewriting with El.property not working

This topic contains 1 reply, has 2 voices, and was last updated by  Christian Kaltepoth 1 year, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #26354

    Donatas
    Participant

    I’m running on Rewrite 2.0.12.Final (with faces and cdi integration modules), JSF 2.2, CDI (OWB), TomEE 1.7.0.
    I have a rule:

    .addRule(
        Join.path("/{lang}/index").to("/index.xhtml")
    ).where("lang").bindsTo(
        El.property("localeBean.language")
    )
    

    This rule is called during an inbound call (and property is set), yet is not called during outbound call, that is, the link:

    <h:link value="Link to index" outcome="/index.xhtml" />
    

    is rendered as “/index.xhtml”. I would assume that this link had to be rendered as “/lang/index”, where “lang” would be outjected from “localeBean.language”. localeBean is an CDI ApplicationScoped bean (for testing):

    import javax.enterprise.context.ApplicationScoped;
    
    @Named
    @ApplicationScoped
    public class LocaleBean implements Serializable {
        private String language = LANGUAGE_LT;
        // Getter and setter
    }
    

    Or should I write separate rule for outbound direction?

    #26392

    Hey,

    sorry for the very late reply. I was on vacation.

    Outjection won’t work this way. You have to make sure that JSF renders the correct query parameter value to the URL. If the query parameter is present, the rewriting will work as expected. So you will have to do something like this:

    <h:link value="Link to index" outcome="/index.xhtml">
      <f:param name="lang" value="#{localeBean.lang}" />
    </h:link>
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Comments are closed.