empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1386551 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: controls/InputControl.java controls/TextAreaInputControl.java controls/TextInputControl.java utils/TagEncodingHelper.java
Date Mon, 17 Sep 2012 10:59:39 GMT
Author: doebele
Date: Mon Sep 17 10:59:38 2012
New Revision: 1386551

URL: http://svn.apache.org/viewvc?rev=1386551&view=rev
Log:
EMPIREDB-157 
JSF2 add or remove class style for input controls that have an error (eInvalid)

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java?rev=1386551&r1=1386550&r2=1386551&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java
Mon Sep 17 10:59:38 2012
@@ -206,6 +206,7 @@ public abstract class InputControl
         // input
         String getInputId();
         String getStyleClass(String addlStyle);
+        boolean hasError();
         /*
         String getName();
         String getTabindex();
@@ -501,18 +502,28 @@ public abstract class InputControl
     
     public void addRemoveDisabledStyle(UIInput input, boolean disabled)
     {
+        addRemoveStyle(input, " eInpDis", disabled);
+    }
+    
+    public void addRemoveInvalidStyle(UIInput input, boolean invalid)
+    {
+        addRemoveStyle(input, " eInvalid", invalid);
+    }
+    
+    public void addRemoveStyle(UIInput input, String styleName, boolean setStyle)
+    {
         String styleClass = StringUtils.toString(input.getAttributes().get("styleClass"),
"");
-        boolean hasDisStyle = (styleClass.indexOf("eInpDis")>=0);
-        if (disabled==hasDisStyle)
+        boolean hasStyle = (styleClass.indexOf(styleName)>=0);
+        if (setStyle==hasStyle)
             return; // Nothing to do
         // Special IceFaces patch
         if (styleClass.endsWith("-dis"))
             styleClass = styleClass.substring(0, styleClass.length()-4);
         // add or remove disabled style
-        if (disabled)
-            styleClass += " eInpDis";
+        if (setStyle)
+            styleClass += styleName;
         else
-            styleClass = styleClass.replace(" eInpDis", "");
+            styleClass = styleClass.replace(styleName, "");
         // add Style
         input.getAttributes().put("styleClass", styleClass);
     }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java?rev=1386551&r1=1386550&r2=1386551&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextAreaInputControl.java
Mon Sep 17 10:59:38 2012
@@ -97,6 +97,7 @@ public class TextAreaInputControl extend
             input.setReadonly(ii.isFieldReadOnly());
         // style
         addRemoveDisabledStyle(input, (input.isDisabled() || input.isReadonly()));
+        addRemoveInvalidStyle(input, ii.hasError());
         
         // Set Value
         setInputValue(input, ii);

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java?rev=1386551&r1=1386550&r2=1386551&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/TextInputControl.java
Mon Sep 17 10:59:38 2012
@@ -127,6 +127,7 @@ public class TextInputControl extends In
             input.setReadonly(ii.isFieldReadOnly());
         // style
         addRemoveDisabledStyle(input, (input.isDisabled() || input.isReadonly()));
+        addRemoveInvalidStyle(input, ii.hasError());
         
         // set value
         setInputValue(input, ii);

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java?rev=1386551&r1=1386550&r2=1386551&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
Mon Sep 17 10:59:38 2012
@@ -327,12 +327,14 @@ public class TagEncodingHelper implement
         public String getStyleClass(String addlStyle)
         {
             String style = getTagStyleClass(addlStyle);
-            if (hasError)
-            {   // Invalid
-                style = "eInvalid "+style;
-            }
             return style; 
         }
+        
+        @Override
+        public boolean hasError()
+        {
+            return hasError;
+        }
 
         @Override
         public Object getAttribute(String name)



Mime
View raw message