You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Mikulicic, Vladimir" <Vl...@br.de> on 2014/04/25 11:03:37 UTC

Redirect to mounted Page

Hi,

I'am using Wicket v6.14.

In my MainApplication.java  in the init Method I've got something like this:  mountPage("/weather/${region}/", RegionPage.class);
My Question is: "How to redirect to that mounted Page, when a user uses a url like this:    http://mydomain.com/weather  -> redirect to -> http://mydomain.com/weather/europe ?"
(region parameter should be an default e.g. "europe")
Thanks,
Vladimir
--------------------------------------------------------------------------------------------------
Bayerischer Rundfunk; Rundfunkplatz 1; 80335 München
Telefon: +49 89 590001; E-Mail: info@BR.de; Website: http://www.BR.de

AW: Redirect to mounted Page

Posted by "Mikulicic, Vladimir" <Vl...@br.de>.
Thank you!!
 
________________________________________
Von: Martin Grigorov [mgrigorov@apache.org]
Gesendet: Freitag, 25. April 2014 11:26
An: users@wicket.apache.org
Betreff: Re: Redirect to mounted Page

Hi,

Usually all you need is:  pageParameters.get("region").toString("europe");
This will get the value and fallback to "europe" if it is not provided.

But in your case you have to do:
public RegionPage(PageParameters pageParameters) {
  super(pageParameters);  // 1

  String region = pageParameters.get("region").toString();
  if (region == null || isInvalid(region)) {
    region = "europe";
    pageParameters.set("region", region);  // 2
   }
  ....
}

1. will set the passed parameters as page's parameters (see
Page#getPageParameters()) so any updates (like in 2.) will be used for url
renderings later
2. will update the parameters



Martin Grigorov
Wicket Training and Consulting


On Fri, Apr 25, 2014 at 12:03 PM, Mikulicic, Vladimir <
Vladimir.Mikulicic@br.de> wrote:

> Hi,
>
> I'am using Wicket v6.14.
>
> In my MainApplication.java  in the init Method I've got something like
> this:  mountPage("/weather/${region}/", RegionPage.class);
> My Question is: "How to redirect to that mounted Page, when a user uses a
> url like this:    http://mydomain.com/weather  -> redirect to ->
> http://mydomain.com/weather/europe ?"
> (region parameter should be an default e.g. "europe")
> Thanks,
> Vladimir
>
> --------------------------------------------------------------------------------------------------
> Bayerischer Rundfunk; Rundfunkplatz 1; 80335 München
> Telefon: +49 89 590001; E-Mail: info@BR.de; Website: http://www.BR.de
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Redirect to mounted Page

Posted by Martin Grigorov <mg...@apache.org>.
Hi,

Usually all you need is:  pageParameters.get("region").toString("europe");
This will get the value and fallback to "europe" if it is not provided.

But in your case you have to do:
public RegionPage(PageParameters pageParameters) {
  super(pageParameters);  // 1

  String region = pageParameters.get("region").toString();
  if (region == null || isInvalid(region)) {
    region = "europe";
    pageParameters.set("region", region);  // 2
   }
  ....
}

1. will set the passed parameters as page's parameters (see
Page#getPageParameters()) so any updates (like in 2.) will be used for url
renderings later
2. will update the parameters



Martin Grigorov
Wicket Training and Consulting


On Fri, Apr 25, 2014 at 12:03 PM, Mikulicic, Vladimir <
Vladimir.Mikulicic@br.de> wrote:

> Hi,
>
> I'am using Wicket v6.14.
>
> In my MainApplication.java  in the init Method I've got something like
> this:  mountPage("/weather/${region}/", RegionPage.class);
> My Question is: "How to redirect to that mounted Page, when a user uses a
> url like this:    http://mydomain.com/weather  -> redirect to ->
> http://mydomain.com/weather/europe ?"
> (region parameter should be an default e.g. "europe")
> Thanks,
> Vladimir
>
> --------------------------------------------------------------------------------------------------
> Bayerischer Rundfunk; Rundfunkplatz 1; 80335 München
> Telefon: +49 89 590001; E-Mail: info@BR.de; Website: http://www.BR.de
>