Rewrite conflict with HTTP request

Splash Forums Rewrite Users Rewrite conflict with HTTP request

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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #26860

    dg0s
    Participant

    Hi Folks,

    I’m coding a language selector for my application. I define the follow rule in my pretty configuration:

    
    <rewrite match="^/admin$" trailingSlash="append" toCase="lowercase" />
    <url-mapping id="admin">
    	<pattern value="/admin/" />
    	<view-id value="/pages/admin/dashboard/dashboard.xhtml" />
    	<action>#{dashboardController.index}</action>
    </url-mapping>
    

    The index method load the translation for my page, selected by the user. However I have a selector component that allow the user change the language:

    
    <h:panelGroup layout="block" id="selectCountry">
    <p:selectOneMenu id="countryLocale" widgetVar="countryLocale" value="#{language.localeCode}">
    <f:selectItems value="#{language.countriesInMap}" />
    <p:ajax event="change" listener="#{language.onChangeCountryLocaleCode}" />
    </p:selectOneMenu>
    </h:panelGroup>
    

    When I change the language the select component first request dashboardController.index and after request the language.onChangeCountryLocaleCode. I need to call language.onChangeCountryLocaleCode before dashboardController.index to update the language and the controller load the correct translation.

    Any suggestion?

    #26861

    There are two ways to fix this.

    First you could simply redirect the user in onChangeCountryLocaleCode. This would result in a new request which would get the correct locale.

    The second option would be to configure PrettyFaces to execute the page action in a later JSF phase like RENDER_RESPONSE. See this part of the documentation for details:

    http://www.ocpsoft.org/docs/prettyfaces/3.3.3/en-US/html/Configuration.html#config.actions.phases

    #26862

    dg0s
    Participant

    Thanks a lot!

    #26863

    You are too fast, Christian! 🙂

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

You must be logged in to reply to this topic.

Comments are closed.