Repository: wicket
Updated Branches:
  refs/heads/master 91f2f8a24 -> b680969db


Small improvments for the new StringResourceModel


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

Branch: refs/heads/master
Commit: b680969db6efb1e5ecb8ed0e32009b464ee6a039
Parents: 91f2f8a
Author: Andrea Del Bene <“[email protected]”>
Authored: Mon May 25 12:14:50 2015 +0200
Committer: Andrea Del Bene <“[email protected]”>
Committed: Mon May 25 12:14:50 2015 +0200

----------------------------------------------------------------------
 .../wicket/model/StringResourceModel.java       | 29 ++++++++++++++++++--
 1 file changed, 27 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/b680969d/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java
----------------------------------------------------------------------
diff --git 
a/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java 
b/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java
index 9faec98..59a89c5 100644
--- a/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java
+++ b/wicket-core/src/main/java/org/apache/wicket/model/StringResourceModel.java
@@ -284,7 +284,7 @@ public class StringResourceModel extends 
LoadableDetachableModel<String>
         * @param model
         *            The model to use for property substitutions
         */
-       public StringResourceModel(final String resourceKey, final Component 
component, IModel<?> model)
+       public StringResourceModel(final String resourceKey, final Component 
component, final IModel<?> model)
        {
                Args.notNull(resourceKey, "resource key");
 
@@ -310,7 +310,20 @@ public class StringResourceModel extends 
LoadableDetachableModel<String>
        {
                this(resourceKey, component, null);
        }
-
+       
+       /**
+        * Creates a new string resource model using the supplied parameter.
+        *
+        * @param resourceKey
+        *            The resource key for this string resource
+        * @param model
+        *            The model to use for property substitutions           
+        */
+       public StringResourceModel(final String resourceKey, final IModel<?> 
model)
+       {
+               this(resourceKey, null, model);
+       }
+       
        /**
         * Creates a new string resource model using the supplied parameter.
         *
@@ -334,6 +347,18 @@ public class StringResourceModel extends 
LoadableDetachableModel<String>
                this.defaultValue = defaultValue;
                return this;
        }
+       
+       /**
+        * Sets the default value if the resource key is not found.
+        *
+        * @param defaultValue
+        *            The default value as string if the resource key is not 
found.
+        * @return this for chaining
+        */
+       public StringResourceModel setDefaultValue(final String defaultValue)
+       {
+               return setDefaultValue(Model.of(defaultValue));
+       }
 
        /**
         * Sets the model used for property substitutions.

Reply via email to