Author: mgrigorov
Date: Sat Jul 24 18:37:49 2010
New Revision: 978923
URL: http://svn.apache.org/viewvc?rev=978923&view=rev
Log:
WICKET-2963 Add examples for the new request mappers in 1.5
Add two examples of request mappers:
* custom home page
* encode/decode the session url as first parameter in the url (the mapper is
created by Igor Vaynberg/Matej Knopp).
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java
(with props)
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleFirstMapper.java
(with props)
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java
(with props)
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocalizedPage.java
(with props)
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperApplication.java
(with props)
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.java
(with props)
wicket/trunk/wicket-examples/src/main/resources/org/
wicket/trunk/wicket-examples/src/main/resources/org/apache/
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage.html
(with props)
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_bg_BG.xml
(with props)
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_en_US.properties
(with props)
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.html
(with props)
Modified:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExamplePage.java
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/library/AuthenticatedWebPage.java
wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml
wicket/trunk/wicket-examples/src/main/webapp/index.html
Modified:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExamplePage.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExamplePage.java?rev=978923&r1=978922&r2=978923&view=diff
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExamplePage.java
(original)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/WicketExamplePage.java
Sat Jul 24 18:37:49 2010
@@ -18,6 +18,7 @@ package org.apache.wicket.examples;
import org.apache.wicket.markup.html.WebPage;
import org.apache.wicket.model.IModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.util.string.Strings;
/**
@@ -32,10 +33,19 @@ public class WicketExamplePage extends W
*/
public WicketExamplePage()
{
- this(null);
+ this(new PageParameters());
}
/**
+ * Constructor
+ */
+ public WicketExamplePage(final PageParameters pageParameters)
+ {
+ super(pageParameters);
+ }
+
+
+ /**
* Construct.
*
* @param model
@@ -43,6 +53,16 @@ public class WicketExamplePage extends W
public WicketExamplePage(IModel<?> model)
{
super(model);
+ }
+
+ /**
+ * @see org.apache.wicket.Component#onInitialize()
+ */
+ @Override
+ protected void onInitialize()
+ {
+ super.onInitialize();
+
final String packageName = getClass().getPackage().getName();
add(new WicketExampleHeader("mainNavigation",
Strings.afterLast(packageName, '.'), this));
explain();
Modified:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/library/AuthenticatedWebPage.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/library/AuthenticatedWebPage.java?rev=978923&r1=978922&r2=978923&view=diff
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/library/AuthenticatedWebPage.java
(original)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/library/AuthenticatedWebPage.java
Sat Jul 24 18:37:49 2010
@@ -42,14 +42,28 @@ public class AuthenticatedWebPage extend
*/
public AuthenticatedWebPage()
{
+ border = new LibraryApplicationBorder("border");
+ }
+
+ /**
+ * @see org.apache.wicket.examples.WicketExamplePage#onInitialize()
+ */
+ @Override
+ protected void onInitialize()
+ {
+ super.onInitialize();
+
// Create border and add it to the page
- add(border = new LibraryApplicationBorder("border"));
+ add(border);
// The WicketExamplePage constructor already created and added
it. We need to move it into
// the border.
- border.addToBorder(get("mainNavigation"));
+ Component mainNavigation =
border.getFromBorderBody("mainNavigation");
+
+ border.addToBorder(mainNavigation);
}
+
/**
* Get downcast session object
*
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java
(added)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,104 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.requestmapper;
+
+import java.util.List;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.IRequestMapper;
+import org.apache.wicket.request.Request;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.handler.PageProvider;
+import org.apache.wicket.request.handler.RenderPageRequestHandler;
+import org.apache.wicket.request.mapper.AbstractComponentMapper;
+import org.apache.wicket.request.mapper.HomePageMapper;
+
+/**
+ * An {...@link IRequestMapper} that overrides the behavior of {...@link
HomePageMapper} and appends the
+ * string representation of the current session locale in the url
+ *
+ * <p>
+ * I.e. a request to http://example.com/app will end up in
http://example.com/app/en_US
+ *
+ * @author mgrigorov
+ */
+public class CustomHomeMapper extends AbstractComponentMapper
+{
+ /**
+ * If there is just one url segment (the locale?!) then return a bigger
compatibility score than
+ * {...@link HomePageMapper#getCompatibilityScore(Request)}
+ *
+ * @see
org.apache.wicket.request.mapper.HomePageMapper#getCompatibilityScore(org.apache.wicket.request.Request)
+ */
+ public int getCompatibilityScore(Request request)
+ {
+ return request.getUrl().getSegments().size() == 1 ? 1 : 0;
+ }
+
+ /**
+ * @see
org.apache.wicket.request.mapper.HomePageMapper#mapHandler(org.apache.wicket.request.IRequestHandler)
+ */
+ public Url mapHandler(IRequestHandler requestHandler)
+ {
+ String locale = Session.get().getLocale().toString();
+ Url homeUrl = new Url();
+ homeUrl.getSegments().add(0, locale);
+ return homeUrl;
+ }
+
+ /**
+ * @see
org.apache.wicket.request.mapper.HomePageMapper#mapRequest(org.apache.wicket.request.Request)
+ */
+ public IRequestHandler mapRequest(Request request)
+ {
+ if (isHomeUrl(request))
+ {
+ return new RenderPageRequestHandler(new
PageProvider(getContext().getHomePageClass()));
+ }
+ else
+ {
+ return null;
+ }
+ }
+
+ /**
+ * A home URL is considered a URL without any segments or with one
segment and its value is
+ * valid locale
+ *
+ * @param request
+ * @return
+ */
+ private boolean isHomeUrl(Request request)
+ {
+ boolean isHomeUrl = false;
+
+ List<String> segments = request.getUrl().getSegments();
+ if (segments.isEmpty())
+ {
+ isHomeUrl = true;
+ }
+ else if (segments.size() == 1)
+ {
+ String localeCandidate = segments.get(0);
+ isHomeUrl = LocaleHelper.isLocale(localeCandidate);
+ // on success the Session's locale can be changed here
+ }
+
+ return isHomeUrl;
+ }
+}
Propchange:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/CustomHomeMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleFirstMapper.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleFirstMapper.java?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleFirstMapper.java
(added)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleFirstMapper.java
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,111 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.requestmapper;
+
+import java.util.List;
+import java.util.Locale;
+
+import org.apache.wicket.Session;
+import org.apache.wicket.request.IRequestHandler;
+import org.apache.wicket.request.IRequestMapper;
+import org.apache.wicket.request.Request;
+import org.apache.wicket.request.Url;
+import org.apache.wicket.request.mapper.AbstractComponentMapper;
+import org.apache.wicket.util.string.Strings;
+
+/**
+ * A {...@link IRequestMapper} that reads the session locale from the first
url segment
+ *
+ * @author ivaynberg
+ * @author matej.knopp
+ */
+public class LocaleFirstMapper extends AbstractComponentMapper
+{
+
+ private final IRequestMapper chain;
+
+ /**
+ * Construct.
+ *
+ * @param chain
+ */
+ public LocaleFirstMapper(final IRequestMapper chain)
+ {
+ this.chain = chain;
+ }
+
+ /**
+ * @see
org.apache.wicket.request.IRequestMapper#getCompatibilityScore(org.apache.wicket.request.Request)
+ */
+ public int getCompatibilityScore(final Request request)
+ {
+ // since we match all urls the score is simply delegated to the
chain
+ return chain.getCompatibilityScore(request);
+ }
+
+ /**
+ * @see
org.apache.wicket.request.IRequestMapper#mapRequest(org.apache.wicket.request.Request)
+ */
+ public IRequestHandler mapRequest(Request request)
+ {
+ // locale is the first segment in the url
+ List<String> segments = request.getUrl().getSegments();
+ if (segments != null && segments.size() > 1)
+ {
+ String localeAsString = segments.get(0);
+ if (!Strings.isEmpty(localeAsString))
+ {
+ Locale locale =
LocaleHelper.parseLocale(localeAsString);
+ Session.get().setLocale(locale);
+
+ // now that we have proccessed the first
segment we need to strip from the url
+ Url url = request.getUrl();
+ url.getSegments().remove(0);
+
+ // create a request based on the new url
+ request = request.requestWithUrl(url);
+ }
+ }
+
+ // chain url processing
+ return chain.mapRequest(request);
+ }
+
+ /**
+ * @see
org.apache.wicket.request.IRequestMapper#mapHandler(org.apache.wicket.request.IRequestHandler)
+ */
+ public Url mapHandler(IRequestHandler handler)
+ {
+
+ // let the chain create the url
+ Url url = chain.mapHandler(handler);
+
+ if (url != null)
+ {
+ Locale locale = Session.get().getLocale();
+ if (locale == null)
+ {
+ locale = Locale.US;
+ }
+ url.getSegments().add(0, locale.toString());
+ }
+
+ return url;
+ }
+
+
+}
Propchange:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleFirstMapper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java
(added)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,78 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.requestmapper;
+
+import java.util.Locale;
+
+/**
+ * A helper class to deal with {...@link Locale} as string
+ *
+ * @author mgrigorov
+ */
+public class LocaleHelper
+{
+ static Locale parseLocale(final String localeAsString)
+ {
+ return parseLocale(localeAsString, null);
+ }
+
+ static Locale parseLocale(final String localeAsString, final Locale
defaultLocale)
+ {
+ Locale result = null;
+
+ final int idxOfUnderbar = localeAsString.indexOf('_');
+ if (idxOfUnderbar > 0)
+ {
+ String lang = localeAsString.substring(0,
idxOfUnderbar);
+ String country = localeAsString.substring(idxOfUnderbar
+ 1);
+ result = new Locale(lang, country);
+ }
+
+ if (result == null)
+ {
+ result = defaultLocale;
+ }
+
+ return result;
+ }
+
+ /**
+ * Checks whether the passed parameter can be parsed to an existing
locale
+ *
+ * @param localeCandidate
+ * @return
+ */
+ static boolean isLocale(String localeCandidate)
+ {
+ boolean isLocale = false;
+
+ Locale locale = parseLocale(localeCandidate);
+ if (locale != null)
+ {
+ for (final Locale l : Locale.getAvailableLocales())
+ {
+ if (l.equals(locale))
+ {
+ isLocale = true;
+ break;
+ }
+ }
+ }
+
+ return isLocale;
+ }
+}
Propchange:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocaleHelper.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocalizedPage.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocalizedPage.java?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocalizedPage.java
(added)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocalizedPage.java
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.requestmapper;
+
+import org.apache.wicket.examples.WicketExamplePage;
+import org.apache.wicket.examples.ajax.builtin.Index;
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.model.ResourceModel;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+/**
+ * @author mgrigorov
+ */
+public class LocalizedPage extends WicketExamplePage
+{
+
+ /**
+ * Construct.
+ *
+ * @param pageParameters
+ */
+ public LocalizedPage(final PageParameters pageParameters)
+ {
+ add(new BookmarkablePageLink<Void>("back",
Index.class).setAutoEnable(true));
+
+ add(new Label("localizedLabel", new
ResourceModel("localizedLabel")));
+ }
+}
Propchange:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/LocalizedPage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperApplication.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperApplication.java?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperApplication.java
(added)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperApplication.java
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.requestmapper;
+
+import org.apache.wicket.Application;
+import org.apache.wicket.Page;
+import org.apache.wicket.examples.WicketExampleApplication;
+import org.apache.wicket.request.mapper.MountedMapper;
+
+/**
+ * @author mgrigorov
+ */
+public class RequestMapperApplication extends WicketExampleApplication
+{
+
+ /**
+ * @see org.apache.wicket.Application#getHomePage()
+ */
+ @Override
+ public Class<? extends Page> getHomePage()
+ {
+ return RequestMapperHomePage.class;
+ }
+
+ /**
+ *
+ * @see org.apache.wicket.examples.WicketExampleApplication#init()
+ */
+ @Override
+ public void init()
+ {
+ super.init();
+
+ getRootRequestMapperAsCompound().add(new CustomHomeMapper());
+
+ getRootRequestMapperAsCompound().add(
+ new LocaleFirstMapper(new MountedMapper("/localized",
LocalizedPage.class)));
+ }
+
+ /**
+ * @see
org.apache.wicket.protocol.http.WebApplication#getConfigurationType()
+ */
+ @Override
+ public String getConfigurationType()
+ {
+ return Application.DEVELOPMENT;
+ }
+
+
+}
Propchange:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperApplication.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.java
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.java?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.java
(added)
+++
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.java
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.wicket.examples.requestmapper;
+
+import org.apache.wicket.examples.WicketExamplePage;
+import org.apache.wicket.examples.ajax.builtin.Index;
+import org.apache.wicket.markup.html.link.BookmarkablePageLink;
+import org.apache.wicket.request.mapper.parameter.PageParameters;
+
+/**
+ * @author mgrigorov
+ */
+public class RequestMapperHomePage extends WicketExamplePage
+{
+
+ /**
+ *
+ * Construct.
+ *
+ * @param pageParameters
+ */
+ public RequestMapperHomePage(final PageParameters pageParameters)
+ {
+ super(pageParameters);
+
+ add(new BookmarkablePageLink<Void>("back",
Index.class).setAutoEnable(true));
+ }
+}
Propchange:
wicket/trunk/wicket-examples/src/main/java/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage.html?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage.html
(added)
+++
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage.html
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,34 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Request Mappers demo</title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+ </head>
+
+ <body>
+ <span wicket:id="mainNavigation"/>
+ <a href="Index.html" wicket:id="back">[go back]</a><p/>
+ <wicket:child/>
+
+ <p>
+ <span wicket:id="localizedLabel">[I am a localized depending on
the URL's first segment]</span>
+ </p>
+ </body>
+
+</html>
\ No newline at end of file
Propchange:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage.html
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_bg_BG.xml
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_bg_BG.xml?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_bg_BG.xml
(added)
+++
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_bg_BG.xml
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="localizedLabel">Ðз ÑÑм на бÑлгаÑÑки,
заÑоÑо пÑÑÐ²Ð¸Ñ ÑÐµÐ³Ð¼ÐµÐ½Ñ Ð² URL-а е 'bg_BG'</entry>
+</properties>
\ No newline at end of file
Propchange:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_bg_BG.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_en_US.properties
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_en_US.properties?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_en_US.properties
(added)
+++
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_en_US.properties
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,15 @@
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+localizedLabel=I'm in English because the value of the first URL segment is
'en_US'
\ No newline at end of file
Propchange:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/LocalizedPage_en_US.properties
------------------------------------------------------------------------------
svn:eol-style = native
Added:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.html?rev=978923&view=auto
==============================================================================
---
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.html
(added)
+++
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.html
Sat Jul 24 18:37:49 2010
@@ -0,0 +1,43 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Request Mappers demo</title>
+ <link rel="stylesheet" type="text/css" href="style.css"/>
+ </head>
+
+ <body>
+ <span wicket:id="mainNavigation"/>
+ <a href="Index.html" wicket:id="back">[go back]</a><p/>
+ <wicket:child/>
+
+ <wicket:link>
+ <a href="en_US/localized">en_US Localized</a><br/>
+ <a href="bg_BG/localized">bg_BG Localized</a>
+ </wicket:link>
+
+ <p>This page uses custom home page request mapper. Loading
http://localhost:8080/wicket-examples/mappers/ automatically appends
+ a preconfigured locale:
http://localhost:8080/wicket-examples/mappers/en_US</p>
+
+ <p>Clicking to any of the links above will lead to a page mounted
at "localized" path but the session locale will be automatically set
+ depending on the locale in the url. I.e. loading
http://localhost:8080/wicket-examples/mappers/bg_BG/localized will show the
page with
+ text localized in Bulgarian.</p>
+
+ </body>
+
+</html>
\ No newline at end of file
Propchange:
wicket/trunk/wicket-examples/src/main/resources/org/apache/wicket/examples/requestmapper/RequestMapperHomePage.html
------------------------------------------------------------------------------
svn:eol-style = native
Modified: wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml?rev=978923&r1=978922&r2=978923&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml (original)
+++ wicket/trunk/wicket-examples/src/main/webapp/WEB-INF/web.xml Sat Jul 24
18:37:49 2010
@@ -423,6 +423,16 @@
</init-param>
</filter>
+ <filter>
+ <filter-name>RequestMapperApplication</filter-name>
+
<filter-class>org.apache.wicket.protocol.http.WicketFilter</filter-class>
+ <init-param>
+ <param-name>applicationClassName</param-name>
+
<param-value>org.apache.wicket.examples.requestmapper.RequestMapperApplication</param-value>
+ </init-param>
+ </filter>
+
+
<filter-mapping>
<filter-name>WicketExamplesMenuApplication</filter-name>
<url-pattern>/examples/*</url-pattern>
@@ -431,6 +441,7 @@
</filter-mapping>
<!-- couple the session filter to the helloworld servlet -->
+
<filter-mapping>
<filter-name>WicketSessionFilter</filter-name>
<url-pattern>/helloworldservlet/*</url-pattern>
@@ -700,6 +711,13 @@
<dispatcher>INCLUDE</dispatcher>
</filter-mapping>
+ <filter-mapping>
+ <filter-name>RequestMapperApplication</filter-name>
+ <url-pattern>/mappers/*</url-pattern>
+ <dispatcher>REQUEST</dispatcher>
+ <dispatcher>INCLUDE</dispatcher>
+ </filter-mapping>
+
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
Modified: wicket/trunk/wicket-examples/src/main/webapp/index.html
URL:
http://svn.apache.org/viewvc/wicket/trunk/wicket-examples/src/main/webapp/index.html?rev=978923&r1=978922&r2=978923&view=diff
==============================================================================
--- wicket/trunk/wicket-examples/src/main/webapp/index.html (original)
+++ wicket/trunk/wicket-examples/src/main/webapp/index.html Sat Jul 24 18:37:49
2010
@@ -58,6 +58,7 @@
<tr class="section"><td align="right"><a
href="spring">spring</a></td><td> - Demonstrates integration options with the
Spring framework.</td></tr>
<tr><td align="right"><a href="guice">guice</a></td><td> -
Integration with the Google Guice IoC container.</td></tr>
<tr><td align="right"><a href="velocity">velocity</a></td><td>
- Shows a Velocity panel in action.</td></tr>
+ <tr><td align="right"><a href="mappers">Wicket 1.5 Request
Mappers</a></td><td> - Shows custom request mappers.</td></tr>
</tbody>
</table>
</div>