Skip to content
Browse files

Added sample app using XML configuration.

  • Loading branch information...
1 parent d9a9154 commit 6376c9ae2e70d4421c11d0f3364addc1b3d852f7 @royclarkson royclarkson committed
Showing with 553 additions and 6 deletions.
  1. +3 −0 README.md
  2. +25 −0 lite-device-delegating-view-resolver-xml/README.md
  3. +16 −0 lite-device-delegating-view-resolver-xml/pom.xml
  4. +41 −0 ...elegating-view-resolver-xml/src/main/java/org/springframework/showcases/lite/AboutController.java
  5. +41 −0 ...delegating-view-resolver-xml/src/main/java/org/springframework/showcases/lite/HomeController.java
  6. +41 −0 lite-device-delegating-view-resolver-xml/src/main/resources/log4j.xml
  7. +3 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/META-INF/MANIFEST.MF
  8. +12 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
  9. +45 −0 ...device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
  10. +8 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/spring/root-context.xml
  11. +23 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/about.jsp
  12. +23 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/home.jsp
  13. +24 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/mobile/about.jsp
  14. +24 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/mobile/home.jsp
  15. +24 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/tablet/about.jsp
  16. +24 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/tablet/home.jsp
  17. +32 −0 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/web.xml
  18. +48 −0 ...ating-view-resolver-xml/src/test/java/org/springframework/showcases/lite/AboutControllerTest.java
  19. +48 −0 ...gating-view-resolver-xml/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
  20. +41 −0 lite-device-delegating-view-resolver-xml/src/test/resources/log4j.xml
  21. +1 −1 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/about.jsp
  22. +1 −1 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/home.jsp
  23. +1 −1 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/about.jsp
  24. +1 −1 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/home.jsp
  25. +1 −1 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/about.jsp
  26. +1 −1 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/home.jsp
  27. +1 −0 pom.xml
View
3 README.md
@@ -15,6 +15,8 @@ The following sample applications demonstrate the capabilities of [Spring Mobile
* [lite-device-delegating-view-resolver] - example showing view names adjusted based on device.
+* [lite-device-delegating-view-resolver-xml] - example using XML based configuration, showing view names adjusted based on device.
+
* [lite-showcase] - combines all features of Spring Mobile to showcase the use of the "urlPath" site switching.
* [thorax-lumbar-client] - showcases the use of Spring Mobile with JavaScript libraries
@@ -57,6 +59,7 @@ See a [screencast demonstration] based on [Spring Mobile 1.0.0.M2].
[lite-site-preference-handler]: https://github.com/SpringSource/spring-mobile-samples/tree/master/lite-site-preference-handler
[lite-site-switcher-handler]: https://github.com/SpringSource/spring-mobile-samples/tree/master/lite-site-switcher-handler
[lite-device-delegating-view-resolver]: https://github.com/SpringSource/spring-mobile-samples/tree/master/lite-device-delegating-view-resolver
+[lite-device-delegating-view-resolver-xml]: https://github.com/SpringSource/spring-mobile-samples/tree/master/lite-device-delegating-view-resolver-xml
[lite-showcase]: https://github.com/SpringSource/spring-mobile-samples/tree/master/lite-showcase
[thorax-lumbar-client]: https://github.com/SpringSource/spring-mobile-samples/tree/master/thorax-lumbar-client
[Pull requests]: http://help.github.com/send-pull-requests
View
25 lite-device-delegating-view-resolver-xml/README.md
@@ -0,0 +1,25 @@
+# lite-device-delegating-view-resolver-xml
+
+A [Spring Mobile] sample app demonstrating many of the capabilities of the Spring Mobile Device module, including:
+
+* "Lite" device resolution through the use of DeviceResolverHandlerInterceptor
+* Site preference management
+* View resolution with LiteDeviceDelegatingViewResolver
+
+
+## Build and Deploy
+
+Access the project at the following URL:
+
+ [http://localhost:8080/lite-device-delegating-view-resolver-xml]
+
+_Note: Accessing this URL from your browser versus an Android emulator or iOS simulator will demonstrate the functionality_
+
+
+## License
+
+[Spring Mobile] is released under version 2.0 of the [Apache License].
+
+[http://localhost:8080/lite-device-delegating-view-resolver-xml]: http://localhost:8080/lite-device-delegating-view-resolver-xml
+[Spring Mobile]: http://www.springsource.org/spring-mobile
+[Apache License]: http://www.apache.org/licenses/LICENSE-2.0
View
16 lite-device-delegating-view-resolver-xml/pom.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.springframework.mobile</groupId>
+ <artifactId>spring-mobile-samples</artifactId>
+ <version>1.1.0-BUILD-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>lite-device-delegating-view-resolver-xml</artifactId>
+ <packaging>war</packaging>
+ <name>lite-device-delegating-view-resolver-xml</name>
+
+</project>
View
41 ...g-view-resolver-xml/src/main/java/org/springframework/showcases/lite/AboutController.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010-2013 the original author or authors.
+ *
+ * Licensed 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.springframework.showcases.lite;
+
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Handles requests for the About page.
+ * @author Roy Clarkson
+ */
+@Controller
+public class AboutController {
+
+ /**
+ * Show the About page to the user.
+ * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
+ * This controller renders a different version of the about view if the user has a mobile site preference.
+ */
+ @RequestMapping("/about")
+ public String home(SitePreference sitePreference, Model model) {
+ return "about";
+ }
+
+}
View
41 ...ng-view-resolver-xml/src/main/java/org/springframework/showcases/lite/HomeController.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright 2010-2013 the original author or authors.
+ *
+ * Licensed 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.springframework.showcases.lite;
+
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.stereotype.Controller;
+import org.springframework.ui.Model;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+/**
+ * Handles requests for the Home page.
+ * @author Roy Clarkson
+ */
+@Controller
+public class HomeController {
+
+ /**
+ * Show the home page to the user.
+ * Declares a {@link SitePreference} parameter to show how you can resolve the user's site preference.
+ * This controller renders a different version of the home view if the user has a mobile site preference.
+ */
+ @RequestMapping("/")
+ public String home(SitePreference sitePreference, Model model) {
+ return "home";
+ }
+
+}
View
41 lite-device-delegating-view-resolver-xml/src/main/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="org.springframework.showcases.lite">
+ <level value="info" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="info" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
3 lite-device-delegating-view-resolver-xml/src/main/webapp/META-INF/MANIFEST.MF
@@ -0,0 +1,3 @@
+Manifest-Version: 1.0
+Class-Path:
+
View
12 ...ce-delegating-view-resolver-xml/src/main/webapp/WEB-INF/spring/appServlet/controllers.xml
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:mvc="http://www.springframework.org/schema/mvc"
+ xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
+ http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd">
+
+ <!-- Scans within the base package of the application for @Components to configure as beans -->
+ <context:component-scan base-package="org.springframework.showcases.lite" />
+</beans>
View
45 ...elegating-view-resolver-xml/src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans:beans xmlns="http://www.springframework.org/schema/mvc" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:beans="http://www.springframework.org/schema/beans"
+ xsi:schemaLocation="
+ http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.2.xsd
+ http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd">
+
+ <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
+
+ <!-- Enables the Spring MVC @Controller programming model -->
+ <annotation-driven>
+ <argument-resolvers>
+ <beans:bean class="org.springframework.mobile.device.DeviceWebArgumentResolver" />
+ <beans:bean class="org.springframework.mobile.device.site.SitePreferenceWebArgumentResolver" />
+ </argument-resolvers>
+ </annotation-driven>
+
+ <interceptors>
+ <!-- On pre-handle, resolve the device that originated the web request -->
+ <beans:bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor" />
+ <!-- On pre-handle, manage the user's site preference (declare after DeviceResolverHandlerInterceptor) -->
+ <beans:bean class="org.springframework.mobile.device.site.SitePreferenceHandlerInterceptor" />
+ </interceptors>
+
+ <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources
+ directory -->
+ <resources mapping="/resources/**" location="/resources/" />
+
+ <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
+ <beans:bean class="org.springframework.mobile.device.view.LiteDeviceDelegatingViewResolver">
+ <beans:constructor-arg>
+ <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
+ <beans:property name="prefix" value="/WEB-INF/views/" />
+ <beans:property name="suffix" value=".jsp" />
+ </beans:bean>
+ </beans:constructor-arg>
+ <beans:property name="enableFallback" value="true" />
+ <beans:property name="mobilePrefix" value="mobile/" />
+ <beans:property name="tabletPrefix" value="tablet/" />
+ </beans:bean>
+
+ <!-- Imports user-defined @Controller beans that process client requests -->
+ <beans:import resource="controllers.xml" />
+
+</beans:beans>
View
8 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/spring/root-context.xml
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
+
+ <!-- Root Context: defines shared resources visible to all other web components -->
+
+</beans>
View
23 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/about.jsp
@@ -0,0 +1,23 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
+ </head>
+ <body>
+ <header>
+ <h1>About (Normal Site)</h1>
+ </header>
+ <p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-preference">
+ <p>Site:
+ <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
+ <c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
+ <c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
+ </aside>
+ </body>
+</html>
View
23 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/home.jsp
@@ -0,0 +1,23 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
+ </head>
+ <body>
+ <header>
+ <h1>Home (Normal Site)</h1>
+ </header>
+ <p>View the <a href="<c:url value="/about" />">About</a> page.</p>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-preference">
+ <p>Site:
+ <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
+ <c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
+ <c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
+ </aside>
+ </body>
+</html>
View
24 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/mobile/about.jsp
@@ -0,0 +1,24 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ </head>
+ <body>
+ <header>
+ <h1>About (Mobile Site)</h1>
+ </header>
+ <p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-preference">
+ <p>Site:
+ <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
+ <c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
+ <c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
+ </aside>
+ </body>
+</html>
View
24 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/mobile/home.jsp
@@ -0,0 +1,24 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ </head>
+ <body>
+ <header>
+ <h1>Home (Mobile Site)</h1>
+ </header>
+ <p>View the <a href="<c:url value="/about" />">About</a> page.</p>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-preference">
+ <p>Site:
+ <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
+ <c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
+ <c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
+ </aside>
+ </body>
+</html>
View
24 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/tablet/about.jsp
@@ -0,0 +1,24 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ </head>
+ <body>
+ <header>
+ <h1>About (Tablet Site)</h1>
+ </header>
+ <p>Return to the <a href="<c:url value="/" />">Home</a> page.</p>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-preference">
+ <p>Site:
+ <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
+ <c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
+ <c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
+ </aside>
+ </body>
+</html>
View
24 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/views/tablet/home.jsp
@@ -0,0 +1,24 @@
+<%@ page session="false" %>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<!DOCTYPE html>
+<html>
+ <head>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
+ </head>
+ <body>
+ <header>
+ <h1>Home (Tablet Site)</h1>
+ </header>
+ <p>View the <a href="<c:url value="/about" />">About</a> page.</p>
+ <footer>
+ An Apache-licensed technology showcase by SpringSource.
+ </footer>
+ <aside id="site-preference">
+ <p>Site:
+ <c:if test="${currentSitePreference.mobile}"><a href="?site_preference=normal">Normal</a> | Mobile | <a href="?site_preference=tablet">Tablet</a></c:if>
+ <c:if test="${currentSitePreference.tablet}"><a href="?site_preference=normal">Normal</a> | <a href="?site_preference=mobile">Mobile</a> | Tablet</c:if>
+ <c:if test="${currentSitePreference.normal}">Normal | <a href="?site_preference=mobile">Mobile</a> | <a href="?site_preference=tablet">Tablet</a></c:if>
+ </aside>
+ </body>
+</html>
View
32 lite-device-delegating-view-resolver-xml/src/main/webapp/WEB-INF/web.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+ <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
+ <context-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/root-context.xml</param-value>
+ </context-param>
+
+ <!-- Creates the Spring Container shared by all Servlets and Filters -->
+ <listener>
+ <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
+ </listener>
+
+ <!-- Processes application requests -->
+ <servlet>
+ <servlet-name>appServlet</servlet-name>
+ <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
+ <init-param>
+ <param-name>contextConfigLocation</param-name>
+ <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>appServlet</servlet-name>
+ <url-pattern>/</url-pattern>
+ </servlet-mapping>
+
+</web-app>
View
48 ...ew-resolver-xml/src/test/java/org/springframework/showcases/lite/AboutControllerTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2010-2013 the original author or authors.
+ *
+ * Licensed 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.springframework.showcases.lite;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+public class AboutControllerTest {
+
+ private AboutController controller = new AboutController();
+
+ @Test
+ public void homePageMobileSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("about", controller.home(SitePreference.MOBILE, model));
+ }
+
+ @Test
+ public void homePageTabletSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("about", controller.home(SitePreference.TABLET, model));
+ }
+
+ @Test
+ public void homePageNormalSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("about", controller.home(SitePreference.NORMAL, model));
+ }
+
+}
View
48 ...iew-resolver-xml/src/test/java/org/springframework/showcases/lite/HomeControllerTest.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2010-2013 the original author or authors.
+ *
+ * Licensed 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.springframework.showcases.lite;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.springframework.mobile.device.site.SitePreference;
+import org.springframework.ui.ExtendedModelMap;
+import org.springframework.ui.Model;
+
+public class HomeControllerTest {
+
+ private HomeController controller = new HomeController();
+
+ @Test
+ public void homePageMobileSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("home", controller.home(SitePreference.MOBILE, model));
+ }
+
+ @Test
+ public void homePageTabletSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("home", controller.home(SitePreference.TABLET, model));
+ }
+
+ @Test
+ public void homePageNormalSitePreference() {
+ Model model = new ExtendedModelMap();
+ assertEquals("home", controller.home(SitePreference.NORMAL, model));
+ }
+
+}
View
41 lite-device-delegating-view-resolver-xml/src/test/resources/log4j.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
+<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
+
+ <!-- Appenders -->
+ <appender name="console" class="org.apache.log4j.ConsoleAppender">
+ <param name="Target" value="System.out" />
+ <layout class="org.apache.log4j.PatternLayout">
+ <param name="ConversionPattern" value="%-5p: %c - %m%n" />
+ </layout>
+ </appender>
+
+ <!-- Application Loggers -->
+ <logger name="org.springframework.showcases.lite">
+ <level value="debug" />
+ </logger>
+
+ <!-- 3rdparty Loggers -->
+ <logger name="org.springframework.core">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.beans">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.context">
+ <level value="info" />
+ </logger>
+
+ <logger name="org.springframework.web">
+ <level value="info" />
+ </logger>
+
+ <!-- Root Logger -->
+ <root>
+ <priority value="warn" />
+ <appender-ref ref="console" />
+ </root>
+
+</log4j:configuration>
View
2 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/about.jsp
@@ -3,7 +3,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Spring Mobile | Lite Device Aware View Resolver</title>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
</head>
<body>
<header>
View
2 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/home.jsp
@@ -3,7 +3,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Spring Mobile | Lite Device Aware View Resolver</title>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
</head>
<body>
<header>
View
2 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/about.jsp
@@ -3,7 +3,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Spring Mobile | Lite Device Aware View Resolver</title>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
View
2 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/mobile/home.jsp
@@ -3,7 +3,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Spring Mobile | Lite Device Aware View Resolver</title>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
View
2 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/about.jsp
@@ -3,7 +3,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Spring Mobile | Lite Device Aware View Resolver</title>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
View
2 lite-device-delegating-view-resolver/src/main/webapp/WEB-INF/views/tablet/home.jsp
@@ -3,7 +3,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Spring Mobile | Lite Device Aware View Resolver</title>
+ <title>Spring Mobile | Lite Device Delegating View Resolver</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
</head>
<body>
View
1 pom.xml
@@ -21,6 +21,7 @@
<module>/lite-site-preference-handler</module>
<module>/lite-site-switcher-handler</module>
<module>/lite-device-delegating-view-resolver</module>
+ <module>/lite-device-delegating-view-resolver-xml</module>
<module>/lite-showcase</module>
</modules>

0 comments on commit 6376c9a

Please sign in to comment.
Something went wrong with that request. Please try again.