Repository: struts-examples
Updated Branches:
  refs/heads/master 04d6d8388 -> d07e95420


Defines an action to show how number conversion works


Project: http://git-wip-us.apache.org/repos/asf/struts-examples/repo
Commit: http://git-wip-us.apache.org/repos/asf/struts-examples/commit/d07e9542
Tree: http://git-wip-us.apache.org/repos/asf/struts-examples/tree/d07e9542
Diff: http://git-wip-us.apache.org/repos/asf/struts-examples/diff/d07e9542

Branch: refs/heads/master
Commit: d07e954204fe39a89c40dc58aec86a29ad677c70
Parents: 9dcfa1b
Author: Lukasz Lenart <lukasz.len...@gmail.com>
Authored: Fri May 12 16:31:11 2017 +0200
Committer: Lukasz Lenart <lukasz.len...@gmail.com>
Committed: Fri May 12 16:47:29 2017 +0200

----------------------------------------------------------------------
 .../org/apache/struts/example/NumberAction.java | 49 ++++++++++++++++
 type-conversion/src/main/resources/example.xml  |  4 ++
 .../apache/struts/example/package.properties    |  1 +
 .../apache/struts/example/package_de.properties |  1 +
 .../apache/struts/example/package_pl.properties |  1 +
 type-conversion/src/main/resources/struts.xml   |  1 +
 .../src/main/webapp/WEB-INF/example/Number.jsp  | 62 ++++++++++++++++++++
 .../src/main/webapp/WEB-INF/example/Theme.jsp   |  7 ++-
 8 files changed, 124 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/java/org/apache/struts/example/NumberAction.java
----------------------------------------------------------------------
diff --git 
a/type-conversion/src/main/java/org/apache/struts/example/NumberAction.java 
b/type-conversion/src/main/java/org/apache/struts/example/NumberAction.java
new file mode 100644
index 0000000..5b2e0e0
--- /dev/null
+++ b/type-conversion/src/main/java/org/apache/struts/example/NumberAction.java
@@ -0,0 +1,49 @@
+package org.apache.struts.example;
+
+import com.opensymphony.xwork2.ActionSupport;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+
+import java.math.BigDecimal;
+
+public class NumberAction extends ActionSupport {
+
+    private static final Logger LOG = LogManager.getLogger(NumberAction.class);
+
+    private BigDecimal bigDecimal = BigDecimal.valueOf(1.01);
+    private Double bigDouble = 1.01;
+    private double primitiveDouble = 1.01;
+
+    @Override
+    public String execute() throws Exception {
+        LOG.info("BigDecimal value: {}", bigDecimal);
+        LOG.info("Double value: {}", bigDouble);
+        LOG.info("double value: {}", primitiveDouble);
+
+        return INPUT;
+    }
+
+    public BigDecimal getBigDecimal() {
+        return bigDecimal;
+    }
+
+    public void setBigDecimal(BigDecimal bigDecimal) {
+        this.bigDecimal = bigDecimal;
+    }
+
+    public Double getBigDouble() {
+        return bigDouble;
+    }
+
+    public void setBigDouble(Double bigDouble) {
+        this.bigDouble = bigDouble;
+    }
+
+    public double getPrimitiveDouble() {
+        return primitiveDouble;
+    }
+
+    public void setPrimitiveDouble(double primitiveDouble) {
+        this.primitiveDouble = primitiveDouble;
+    }
+}

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/resources/example.xml
----------------------------------------------------------------------
diff --git a/type-conversion/src/main/resources/example.xml 
b/type-conversion/src/main/resources/example.xml
index 924b431..b12b0a3 100644
--- a/type-conversion/src/main/resources/example.xml
+++ b/type-conversion/src/main/resources/example.xml
@@ -15,5 +15,9 @@
             <result>/WEB-INF/example/Theme.jsp</result>
         </action>
 
+        <action name="Number" class="org.apache.struts.example.NumberAction">
+            <result name="input">/WEB-INF/example/Number.jsp</result>
+        </action>
+
     </package>
 </struts>

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/resources/org/apache/struts/example/package.properties
----------------------------------------------------------------------
diff --git 
a/type-conversion/src/main/resources/org/apache/struts/example/package.properties
 
b/type-conversion/src/main/resources/org/apache/struts/example/package.properties
new file mode 100644
index 0000000..581936c
--- /dev/null
+++ 
b/type-conversion/src/main/resources/org/apache/struts/example/package.properties
@@ -0,0 +1 @@
+label=Locale (EN)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/resources/org/apache/struts/example/package_de.properties
----------------------------------------------------------------------
diff --git 
a/type-conversion/src/main/resources/org/apache/struts/example/package_de.properties
 
b/type-conversion/src/main/resources/org/apache/struts/example/package_de.properties
new file mode 100644
index 0000000..7e18611
--- /dev/null
+++ 
b/type-conversion/src/main/resources/org/apache/struts/example/package_de.properties
@@ -0,0 +1 @@
+label=Gebietsschema (DE)
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/resources/org/apache/struts/example/package_pl.properties
----------------------------------------------------------------------
diff --git 
a/type-conversion/src/main/resources/org/apache/struts/example/package_pl.properties
 
b/type-conversion/src/main/resources/org/apache/struts/example/package_pl.properties
new file mode 100644
index 0000000..bd5e8b5
--- /dev/null
+++ 
b/type-conversion/src/main/resources/org/apache/struts/example/package_pl.properties
@@ -0,0 +1 @@
+label=J\u0119zyk (PL)

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/resources/struts.xml
----------------------------------------------------------------------
diff --git a/type-conversion/src/main/resources/struts.xml 
b/type-conversion/src/main/resources/struts.xml
index 6f25e26..2cbb2e0 100644
--- a/type-conversion/src/main/resources/struts.xml
+++ b/type-conversion/src/main/resources/struts.xml
@@ -5,6 +5,7 @@
 <struts>
     <constant name="struts.enable.DynamicMethodInvocation" value="false"/>
     <constant name="struts.devMode" value="true"/>
+    <constant name="struts.i18n.reload" value="true"/>
 
     <include file="example.xml"/>
 

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/webapp/WEB-INF/example/Number.jsp
----------------------------------------------------------------------
diff --git a/type-conversion/src/main/webapp/WEB-INF/example/Number.jsp 
b/type-conversion/src/main/webapp/WEB-INF/example/Number.jsp
new file mode 100644
index 0000000..840140b
--- /dev/null
+++ b/type-conversion/src/main/webapp/WEB-INF/example/Number.jsp
@@ -0,0 +1,62 @@
+<%@ page contentType="text/html; charset=UTF-8" %>
+<%@ taglib prefix="s" uri="/struts-tags" %>
+<html>
+<head>
+  <title>Number conversion</title>
+</head>
+
+<body>
+
+<s:url var="themeAction" action="Theme"/>
+<s:a value="%{themeAction}">Theme conversion</s:a>
+
+<s:url var="switchToEN" action="Number">
+  <s:param name="request_locale">en</s:param>
+</s:url>
+<s:a value="%{switchToEN}">Switch to EN</s:a>
+
+<s:url var="switchToPL" action="Number">
+  <s:param name="request_locale">pl</s:param>
+</s:url>
+<s:a value="%{switchToPL}">Switch to PL</s:a>
+
+<s:url var="switchToDE" action="Number">
+  <s:param name="request_locale">de</s:param>
+</s:url>
+<s:a value="%{switchToDE}">Switch to DE</s:a>
+
+<s:form method="POST" action="Number">
+  <table>
+    <tr>
+      <td>BigDecimal</td>
+      <td><s:textfield name="bigDecimal"/></td>
+    </tr>
+    <tr>
+      <td>Double</td>
+      <td><s:textfield name="bigDouble"/></td>
+    </tr>
+    <tr>
+      <td>double</td>
+      <td><s:textfield name="primitiveDouble"/></td>
+    </tr>
+    <tr>
+      <td colspan="2"><s:submit/></td>
+    </tr>
+  </table>
+</s:form>
+
+<pre>
+  <s:text name="label"/>: <s:property value="locale"/>
+</pre>
+<pre>
+  BigDecimal: <s:property value="bigDecimal"/>
+</pre>
+<pre>
+  Double: <s:property value="bigDouble"/>
+</pre>
+<pre>
+  double: <s:property value="primitiveDouble"/>
+</pre>
+
+</body>
+</html>

http://git-wip-us.apache.org/repos/asf/struts-examples/blob/d07e9542/type-conversion/src/main/webapp/WEB-INF/example/Theme.jsp
----------------------------------------------------------------------
diff --git a/type-conversion/src/main/webapp/WEB-INF/example/Theme.jsp 
b/type-conversion/src/main/webapp/WEB-INF/example/Theme.jsp
index c684819..3fd6ba2 100644
--- a/type-conversion/src/main/webapp/WEB-INF/example/Theme.jsp
+++ b/type-conversion/src/main/webapp/WEB-INF/example/Theme.jsp
@@ -1,12 +1,15 @@
 <%@ page contentType="text/html; charset=UTF-8" %>
 <%@ taglib prefix="s" uri="/struts-tags" %>
-<html>
+<!DOCTYPE html>
+<html lang="en">
 <head>
   <title>Theme selector</title>
 </head>
 
 <body>
-<h2><s:property value="message"/></h2>
+
+<s:url var="numberAction" action="Number"/>
+<s:a value="%{numberAction}">Number conversion</s:a>
 
 <s:form method="POST" action="design" theme="simple">
   <table>

Reply via email to