You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by jo...@apache.org on 2015/05/01 13:00:17 UTC
[1/4] struts git commit: WW-4492 Add support for Log4J2 as a struts
and xwork logging backend
Repository: struts
Updated Branches:
refs/heads/develop 45071a7ff -> f150c9f29
WW-4492 Add support for Log4J2 as a struts and xwork logging backend
- Move log4j2 version to properties
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/7afa4ae9
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/7afa4ae9
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/7afa4ae9
Branch: refs/heads/develop
Commit: 7afa4ae925dad9dd584eac4fb7bb12e02397518d
Parents: 45071a7
Author: Johannes Geppert <jo...@gmail.com>
Authored: Fri May 1 11:19:51 2015 +0200
Committer: Johannes Geppert <jo...@gmail.com>
Committed: Fri May 1 11:19:51 2015 +0200
----------------------------------------------------------------------
apps/blank/pom.xml | 4 ++--
apps/rest-showcase/pom.xml | 4 ++--
pom.xml | 3 ++-
3 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/7afa4ae9/apps/blank/pom.xml
----------------------------------------------------------------------
diff --git a/apps/blank/pom.xml b/apps/blank/pom.xml
index c105dd8..d7ab677 100644
--- a/apps/blank/pom.xml
+++ b/apps/blank/pom.xml
@@ -50,12 +50,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
- <version>2.2</version>
+ <version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
- <version>2.2</version>
+ <version>${log4j2.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/struts/blob/7afa4ae9/apps/rest-showcase/pom.xml
----------------------------------------------------------------------
diff --git a/apps/rest-showcase/pom.xml b/apps/rest-showcase/pom.xml
index d3679a1..681124c 100644
--- a/apps/rest-showcase/pom.xml
+++ b/apps/rest-showcase/pom.xml
@@ -52,12 +52,12 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
- <version>2.2</version>
+ <version>${log4j2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
- <version>2.2</version>
+ <version>${log4j2.version}</version>
</dependency>
<dependency>
http://git-wip-us.apache.org/repos/asf/struts/blob/7afa4ae9/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 7aaaefc..7e55d40 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,6 +90,7 @@
<asm.version>3.3</asm.version>
<asm5.version>5.0.2</asm5.version>
<tiles.version>2.0.6</tiles.version>
+ <log4j2.version>2.2</log4j2.version>
<!-- SCM Site Configuration -->
<site.mainDirectory>${project.build.directory}/site</site.mainDirectory>
@@ -868,7 +869,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-api</artifactId>
- <version>2.2</version>
+ <version>${log4j2.version}</version>
</dependency>
<dependency>
[2/4] struts git commit: WW-4492 Add support for Log4J2 as a struts
and xwork logging backend
Posted by jo...@apache.org.
WW-4492 Add support for Log4J2 as a struts and xwork logging backend
- Use log4j2 in the angularjs maven archetype
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e990fbb7
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e990fbb7
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e990fbb7
Branch: refs/heads/develop
Commit: e990fbb751af3ed83123ca71bd90b76eec24cf5c
Parents: 7afa4ae
Author: Johannes Geppert <jo...@gmail.com>
Authored: Fri May 1 12:46:59 2015 +0200
Committer: Johannes Geppert <jo...@gmail.com>
Committed: Fri May 1 12:46:59 2015 +0200
----------------------------------------------------------------------
.../META-INF/maven/archetype-metadata.xml | 2 +-
.../main/resources/archetype-resources/pom.xml | 38 +++++++++-----------
.../src/main/resources/log4j.properties | 29 ---------------
.../src/main/resources/log4j2.xml | 16 +++++++++
4 files changed, 34 insertions(+), 51 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/e990fbb7/archetypes/struts2-archetype-angularjs/src/main/resources/META-INF/maven/archetype-metadata.xml
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/META-INF/maven/archetype-metadata.xml b/archetypes/struts2-archetype-angularjs/src/main/resources/META-INF/maven/archetype-metadata.xml
index b826600..5253d83 100644
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/META-INF/maven/archetype-metadata.xml
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/META-INF/maven/archetype-metadata.xml
@@ -30,7 +30,7 @@
</includes>
</fileSet>
- <fileSet filtered="false" packaged="false">
+ <fileSet filtered="true" packaged="false">
<directory>src/main/resources</directory>
<includes>
<include>**/*.xml</include>
http://git-wip-us.apache.org/repos/asf/struts/blob/e990fbb7/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml
index 06422ce..3872a06 100644
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/pom.xml
@@ -10,6 +10,7 @@
<properties>
<struts2.version>${project.version}</struts2.version>
+ <log4j2.version>${log4j2.version}</log4j2.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
@@ -47,17 +48,17 @@
</dependency>
<dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- <version>1.1.3</version>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-api</artifactId>
+ <version>\${log4j2.version}</version>
</dependency>
-
<dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
+ <groupId>org.apache.logging.log4j</groupId>
+ <artifactId>log4j-core</artifactId>
+ <version>\${log4j2.version}</version>
</dependency>
+
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
@@ -84,7 +85,9 @@
<build>
<plugins>
<plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
+ <version>3.3</version>
<configuration>
<encoding>UTF-8</encoding>
<source>1.5</source>
@@ -94,29 +97,22 @@
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
- <version>8.1.12.v20130726</version>
+ <version>8.1.16.v20140903</version>
<configuration>
<stopKey>CTRL+C</stopKey>
<stopPort>8999</stopPort>
<systemProperties>
<systemProperty>
- <name>log4j.configuration</name>
- <value>file:\${basedir}/src/main/resources/log4j.properties</value>
- </systemProperty>
- <systemProperty>
- <name>slf4j</name>
- <value>false</value>
+ <name>xwork.loggerFactory</name>
+ <value>com.opensymphony.xwork2.util.logging.log4j2.Log4j2LoggerFactory</value>
</systemProperty>
</systemProperties>
<scanIntervalSeconds>10</scanIntervalSeconds>
+ <webAppSourceDirectory>${basedir}/src/main/webapp/</webAppSourceDirectory>
+ <webAppConfig>
+ <descriptor>${basedir}/src/main/webapp/WEB-INF/web.xml</descriptor>
+ </webAppConfig>
</configuration>
- <dependencies>
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- </dependency>
- </dependencies>
</plugin>
</plugins>
</build>
http://git-wip-us.apache.org/repos/asf/struts/blob/e990fbb7/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j.properties b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j.properties
deleted file mode 100644
index a29a304..0000000
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j.properties
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Log4J Settings for log4j 1.2.x (via jakarta-commons-logging)
-#
-# The five logging levels used by Log are (in order):
-#
-# 1. DEBUG (the least serious)
-# 2. INFO
-# 3. WARN
-# 4. ERROR
-# 5. FATAL (the most serious)
-
-
-# Set root logger level to WARN and append to stdout
-log4j.rootLogger=WARN, stdout
-
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-
-# Pattern to output the caller's file name and line number.
-log4j.appender.stdout.layout.ConversionPattern=%d %5p (%c:%L) - %m%n
-
-# Print only messages of level ERROR or above in the package noModule.
-log4j.logger.noModule=ERROR
-
-# OpenSymphony Stuff
-log4j.logger.com.opensymphony=INFO
-
-# Struts2 Stuff
-log4j.logger.org.apache.struts2=INFO
http://git-wip-us.apache.org/repos/asf/struts/blob/e990fbb7/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j2.xml
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j2.xml b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j2.xml
new file mode 100644
index 0000000..6d27d12
--- /dev/null
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/log4j2.xml
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration>
+ <Appenders>
+ <Console name="STDOUT" target="SYSTEM_OUT">
+ <PatternLayout pattern="%d %-5p [%t] %C{2} (%F:%L) - %m%n"/>
+ </Console>
+ </Appenders>
+ <Loggers>
+ <Logger name="com.opensymphony.xwork2" level="info"/>
+ <Logger name="org.apache.struts2" level="info"/>
+ <Logger name="\${groupId}" level="debug"/>
+ <Root level="warn">
+ <AppenderRef ref="STDOUT"/>
+ </Root>
+ </Loggers>
+</Configuration>
\ No newline at end of file
[3/4] struts git commit: Refactor angularjs maven archetype to have a
separate namespace for data action and DataService with promises
Posted by jo...@apache.org.
Refactor angularjs maven archetype to have a separate namespace for data action and DataService with promises
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/e3682f94
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/e3682f94
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/e3682f94
Branch: refs/heads/develop
Commit: e3682f94726015a6e97873b4e21cad2cf20b6eb6
Parents: e990fbb
Author: Johannes Geppert <jo...@gmail.com>
Authored: Fri May 1 12:48:09 2015 +0200
Committer: Johannes Geppert <jo...@gmail.com>
Committed: Fri May 1 12:48:09 2015 +0200
----------------------------------------------------------------------
.../src/main/java/actions/ProjectsAction.java | 67 ------------------
.../main/java/actions/data/ProjectsAction.java | 74 ++++++++++++++++++++
.../src/main/resources/struts.xml | 1 +
.../src/main/webapp/WEB-INF/content/hello.jsp | 1 +
.../src/main/webapp/js/controllers.js | 14 ++--
.../src/main/webapp/js/services.js | 57 +++++++++++++++
6 files changed, 139 insertions(+), 75 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/e3682f94/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ProjectsAction.java
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ProjectsAction.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ProjectsAction.java
deleted file mode 100644
index 77c9497..0000000
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/ProjectsAction.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * $Id$
- *
- * 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 ${package}.actions;
-
-import com.opensymphony.xwork2.ActionSupport;
-import org.apache.struts2.convention.annotation.Result;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * <code>List Apache projects.</code>
- */
-@Result(type = "json")
-public class ProjectsAction extends ActionSupport {
-
- private static final long serialVersionUID = 9037336532369476225L;
-
- private List<String> projectNames = new ArrayList<String>();
-
- public String execute() throws Exception {
-
- projectNames.add("Apache Struts");
- projectNames.add("Apache Log4j");
- projectNames.add("Apache Tomcat");
- projectNames.add("Apache Maven");
- projectNames.add("Apache Ant");
- projectNames.add("Apache Log4Net");
- projectNames.add("Apache Log4Cxx");
- projectNames.add("Apache Chainsaw");
- projectNames.add("Apache Incubator");
- projectNames.add("Apache Hadoop");
- projectNames.add("Apache OpenOffice");
- projectNames.add("Apache Mahout");
- projectNames.add("Apache Tapestry");
- projectNames.add("Apache Jena");
- projectNames.add("Apache Solr");
- projectNames.add("Apache Cayenne");
- projectNames.add("Apache OpenEJB");
- projectNames.add("Apache Deltaspike");
- projectNames.add("Apache Cordova");
-
- return SUCCESS;
- }
-
- public List<String> getProjectNames() {
- return projectNames;
- }
-}
http://git-wip-us.apache.org/repos/asf/struts/blob/e3682f94/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java
new file mode 100644
index 0000000..ddbe7da
--- /dev/null
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/java/actions/data/ProjectsAction.java
@@ -0,0 +1,74 @@
+/*
+ * $Id$
+ *
+ * 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 ${package}.actions.data;
+
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.struts2.convention.annotation.Result;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <code>List Apache projects.</code>
+ */
+@Result(type = "json")
+public class ProjectsAction extends ActionSupport {
+
+ private static final long serialVersionUID = 9037336532369476225L;
+ private static final Logger log = LogManager.getLogger(ProjectsAction.class);
+
+ private List<String> projectNames;
+
+ public String execute() throws Exception {
+
+ projectNames = new ArrayList<String>();
+ projectNames.add("Apache Struts");
+ projectNames.add("Apache Log4j");
+ projectNames.add("Apache Tomcat");
+ projectNames.add("Apache Maven");
+ projectNames.add("Apache Ant");
+ projectNames.add("Apache Log4Net");
+ projectNames.add("Apache Log4Cxx");
+ projectNames.add("Apache Chainsaw");
+ projectNames.add("Apache Incubator");
+ projectNames.add("Apache Hadoop");
+ projectNames.add("Apache OpenOffice");
+ projectNames.add("Apache Mahout");
+ projectNames.add("Apache Tapestry");
+ projectNames.add("Apache Jena");
+ projectNames.add("Apache Solr");
+ projectNames.add("Apache Cayenne");
+ projectNames.add("Apache OpenEJB");
+ projectNames.add("Apache Deltaspike");
+ projectNames.add("Apache Cordova");
+
+ log.debug("Return {} Apache projects", projectNames.size());
+
+ return SUCCESS;
+ }
+
+ public List<String> getProjectNames() {
+ return projectNames;
+ }
+}
http://git-wip-us.apache.org/repos/asf/struts/blob/e3682f94/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml
index 5da77c9..e725380 100644
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/resources/struts.xml
@@ -9,5 +9,6 @@
<constant name="struts.convention.default.parent.package" value="angularstruts"/>
<package name="angularstruts" extends="json-default"></package>
+ <package name="data" extends="angularstruts" namespace="/data"></package>
</struts>
http://git-wip-us.apache.org/repos/asf/struts/blob/e3682f94/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
index 70cdb14..703353e 100644
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
@@ -22,6 +22,7 @@
<script src="<s:url value="js/lib/angular/angular-route.min.js" />"></script>
<script src="<s:url value="js/bootstrap.js" />"></script>
<script src="<s:url value="js/directives.js" />"></script>
+<script src="<s:url value="js/services.js" />"></script>
<script src="<s:url value="js/controllers.js" />"></script>
</body>
</html>
http://git-wip-us.apache.org/repos/asf/struts/blob/e3682f94/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js
index 9a5b71f..ed57b00 100644
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/controllers.js
@@ -24,15 +24,13 @@ angularStrutsApp.controller('HomeController', function ($scope) {
$scope.name = "Sunshine";
});
-angularStrutsApp.controller('ApacheProjectsController', function ($scope, $http) {
+angularStrutsApp.controller('ApacheProjectsController', function ($scope, $http, DataService) {
this.init = function() {
- $http({method: 'GET', url: 'projects'}).
- success(function(data) {
- $scope.projects = data.projectNames;
- }).
- error(function(data, status, headers, config) {
- alert("Could not receive project names");
- });
+ DataService.getProjects().then(function(data) {
+ $scope.projects = data.data.projectNames;
+ }, function(data) {
+ console.log('Could not receive project names.')
+ });
};
this.init();
http://git-wip-us.apache.org/repos/asf/struts/blob/e3682f94/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js
new file mode 100644
index 0000000..e3be1de
--- /dev/null
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/services.js
@@ -0,0 +1,57 @@
+/*
+ * $Id$
+ *
+ * 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.
+ */
+angularStrutsApp.factory('DataService', ['$http', '$q', function($http, $q) {
+
+ var DataService = {
+ urls : {
+ projects : "data/projects"
+ }
+ };
+
+ DataService._request = function(url, method, model){
+ if(!method) {
+ method = 'GET';
+ }
+ var def = $q.defer();
+ if(method === 'GET') {
+ return $http.get(url).success(function(data) {
+ DataService.data = data;
+ def.resolve(data);
+ }).error(function() {
+ def.reject("Failed to get data");
+ });
+ } else if(method === 'POST'){
+ $http.post(url, model).success(function(data) {
+ DataService.data = data;
+ def.resolve(data);
+ }).error(function() {
+ def.reject("Failed to post data");
+ });
+ }
+ return def.promise;
+ };
+
+ DataService.getProjects = function () {
+ return this._request(this.urls.projects);
+ };
+
+ return DataService;
+}]);
\ No newline at end of file
[4/4] struts git commit: Refactor angularjs maven archetype to
support html5 uris
Posted by jo...@apache.org.
Refactor angularjs maven archetype to support html5 uris
Project: http://git-wip-us.apache.org/repos/asf/struts/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f150c9f2
Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f150c9f2
Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f150c9f2
Branch: refs/heads/develop
Commit: f150c9f295f41cbbddf122005c469dd7a935e233
Parents: e3682f9
Author: Johannes Geppert <jo...@gmail.com>
Authored: Fri May 1 12:59:46 2015 +0200
Committer: Johannes Geppert <jo...@gmail.com>
Committed: Fri May 1 12:59:46 2015 +0200
----------------------------------------------------------------------
.../src/main/webapp/WEB-INF/content/hello.jsp | 5 ++++-
.../archetype-resources/src/main/webapp/js/bootstrap.js | 7 +++++--
2 files changed, 9 insertions(+), 3 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/struts/blob/f150c9f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
index 703353e..d66b06a 100644
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/WEB-INF/content/hello.jsp
@@ -5,13 +5,16 @@
<head>
<meta charset="utf-8">
<title>My AngularJS Struts2 App</title>
+
+ <s:url var="ctxUrl" forceAddSchemeHostAndPort="true" includeContext="true" value="/" namespace="/" ></s:url>
+ <base href="<s:property value="ctxUrl"/>">
</head>
<body>
<h2><s:property value="message"/></h2>
<div>
- <a href="#/home">Home</a> - <a href="#/projects">Projects</a>
+ <a href="/home">Home</a> - <a href="/projects">Projects</a>
</div>
<div ng-controller="AppController">
http://git-wip-us.apache.org/repos/asf/struts/blob/f150c9f2/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/bootstrap.js
----------------------------------------------------------------------
diff --git a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/bootstrap.js b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/bootstrap.js
index 501427f..beefd53 100644
--- a/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/bootstrap.js
+++ b/archetypes/struts2-archetype-angularjs/src/main/resources/archetype-resources/src/main/webapp/js/bootstrap.js
@@ -21,8 +21,11 @@
var angularStrutsApp = angular.module('angularStrutsApp', ['ngRoute']);
-angularStrutsApp.config(['$routeProvider',
- function($routeProvider) {
+angularStrutsApp.config(['$routeProvider', '$locationProvider',
+ function($routeProvider, $locationProvider) {
+
+ $locationProvider.html5Mode(true).hashPrefix('!');
+
$routeProvider.when('/projects', {
templateUrl: 'partials/projects.html',
controller: 'ApacheProjectsController'