empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1326632 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: app/ controls/ utils/
Date Mon, 16 Apr 2012 14:35:52 GMT
Author: doebele
Date: Mon Apr 16 14:35:51 2012
New Revision: 1326632

URL: http://svn.apache.org/viewvc?rev=1326632&view=rev
Log:
EMPIREDB-140
formatting

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/AppStartupListener.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
    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/SelectInputControl.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/app/AppStartupListener.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/AppStartupListener.java?rev=1326632&r1=1326631&r2=1326632&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/AppStartupListener.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/AppStartupListener.java
Mon Apr 16 14:35:51 2012
@@ -30,8 +30,6 @@ import javax.servlet.ServletContext;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-
-
 public class AppStartupListener implements SystemEventListener
 {
     final Log log = LogFactory.getLog(AppStartupListener.class);
@@ -51,7 +49,7 @@ public class AppStartupListener implemen
         {
             Application app = ((PostConstructApplicationEvent) event).getApplication();
             if (!(app instanceof FacesApplication))
-                throw new AbortProcessingException("Error: Application is not a JsfApplication
instance. Please create a ApplicationFactory!");
+                throw new AbortProcessingException("Error: Application is not a "+FacesApplication.class.getName()+"
instance. Please create a ApplicationFactory!");
             // Create an Init application
             ServletContext servletContext = (ServletContext) FacesContext.getCurrentInstance().getExternalContext().getContext();
             FacesApplication jsfApp = (FacesApplication)app;
@@ -59,7 +57,7 @@ public class AppStartupListener implemen
             // Set Servlet Attribute
             servletContext.setAttribute(jsfApp.getApplicationBeanName(), jsfApp);
             // done
-            log.info("Fin2Application initialization complete!");
+            log.info("Application initialization complete!");
         }
         else if (event instanceof PreDestroyApplicationEvent)
         {

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java?rev=1326632&r1=1326631&r2=1326632&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
Mon Apr 16 14:35:51 2012
@@ -160,6 +160,7 @@ public class FacesUtils
         String name = cls.getName();
         int i = name.lastIndexOf('.')+1;
         name  = name.substring(i, i+1).toLowerCase()+name.substring(i+1);
+        @SuppressWarnings("unchecked")
         T bean = (T)getManagedBean(fc, name);
         if (bean==null)
             log.warn("Managed Bean {} ist not available.", name);

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=1326632&r1=1326631&r2=1326632&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 Apr 16 14:35:51 2012
@@ -27,6 +27,7 @@ import javax.faces.component.UIInput;
 import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
+import org.apache.empire.commons.ObjectUtils;
 import org.apache.empire.commons.Options;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.data.Column;
@@ -153,6 +154,10 @@ public abstract class InputControl
     public static final String MINVALUE_ATTRIBUTE         = "minValue";
     public static final String MAXVALUE_ATTRIBUTE         = "maxValue";
     public static final String CURRENCY_CODE_ATTRIBUTE    = "currencyCode";   // "ISO 4217
code of the currency"  
+
+    // format attributes
+    public static final String FORMAT_NULL = "null:";
+    public static final String FORMAT_NULL_ATTRIBUTE = "format:null";
     
     public InputControl()
     {
@@ -168,11 +173,11 @@ public abstract class InputControl
         Column getColumn();
         Options getOptions();
         Object getValue();
-        Object getNullValue();
         String getFormat();    // Custom Formatting options specific to each InputControl-type
         Locale getLocale();
         String getText(String key);
         /*
+        Object getNullValue();
         String getOnclick();
         String getOndblclick();
         String getCssClass();
@@ -187,17 +192,15 @@ public abstract class InputControl
      */ 
     public interface InputInfo extends ValueInfo
     {
-        int getHSize();
-        int getVSize();
+        // perform action 
+        void setValue(Object value);
+        void validate(Object value);
         boolean isRequired();
         boolean isDisabled(); // readOnly
+        // input
         String getInputId();
         String getTabindex();
         String getStyleClass(String addlStyle);
-        // perform action 
-        void setValue(Object value);
-        void validate(Object value);
-        
         // String getAccesskey();
         /*
         String getName();
@@ -374,7 +377,7 @@ public abstract class InputControl
         }
         // value
         if (value==null)
-            value = vi.getNullValue();
+            value = getFormatOption(vi, FORMAT_NULL, FORMAT_NULL_ATTRIBUTE);
         // Convert to String
         String s = StringUtils.valueOf(value);
         if (hasFormatOption(vi, "noencode"))
@@ -417,7 +420,7 @@ public abstract class InputControl
         return (format!=null ? format.indexOf(option)>=0 : false);
     }
     
-    protected String getFormatOption(ValueInfo vi, String option)
+    private String getFormatOption(ValueInfo vi, String option)
     {
         // Is unit supplied with format
         String format = vi.getFormat();
@@ -435,5 +438,21 @@ public abstract class InputControl
         // The cbValue
         return format.substring(beg, end);
     }
+
+    protected Object getFormatOption(ValueInfo vi, String option, String columnAttributeName)
+    {
+        String format = getFormatOption(vi, option);
+        return (format!=null) ? format : vi.getColumn().getAttribute(columnAttributeName);

+    }
+
+    protected String getFormatString(ValueInfo vi, String option, String columnAttributeName)
+    {
+        return StringUtils.toString(getFormatOption(vi, option, columnAttributeName));
+    }
+
+    protected int getFormatInteger(ValueInfo vi, String option, String columnAttributeName)
+    {
+        return ObjectUtils.getInteger(getFormatOption(vi, option, columnAttributeName));
+    }
     
 }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java?rev=1326632&r1=1326631&r2=1326632&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/SelectInputControl.java
Mon Apr 16 14:35:51 2012
@@ -39,7 +39,7 @@ public class SelectInputControl extends 
     public static final String COLATTR_ABBR_OPTIONS   = "ABBR_OPTIONS";     // Option list
for abbreviations
     
     public static final String NAME = "select";
-    
+
     private Class<? extends javax.faces.component.html.HtmlSelectOneMenu> inputComponentClass;
 
     public SelectInputControl(Class<? extends HtmlSelectOneMenu> inputComponentClass)
@@ -85,10 +85,8 @@ public class SelectInputControl extends 
     
     private String getNullText(InputInfo ii)
     {
-        String nullText = getFormatOption(ii, "null:");
-        if (nullText==null)
-            nullText="";
-        return nullText;
+        String nullText = getFormatString(ii, FORMAT_NULL, FORMAT_NULL_ATTRIBUTE);
+        return (nullText!=null) ? ii.getText(nullText) : "";
     }
 
     private void addSelectItem(UIComponent input, InputInfo ii, OptionEntry e)

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=1326632&r1=1326631&r2=1326632&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 Apr 16 14:35:51 2012
@@ -32,6 +32,12 @@ public class TextAreaInputControl extend
     
     public static final String NAME = "textarea"; 
     
+    public static final String FORMAT_COLS = "cols:";
+    public static final String FORMAT_COLS_ATTRIBUTE = "format:cols";
+
+    public static final String FORMAT_ROWS = "rows:";
+    public static final String FORMAT_ROWS_ATTRIBUTE = "format:rows";
+    
     private Class<? extends javax.faces.component.html.HtmlInputTextarea> inputComponentClass;
 
     public TextAreaInputControl(Class<? extends HtmlInputTextarea> inputComponentClass)
@@ -58,11 +64,11 @@ public class TextAreaInputControl extend
 		}
         copyAttributes(parent, ii, input);
         
-        int cols = ii.getHSize();
+        int cols = getFormatInteger(ii, FORMAT_COLS, FORMAT_COLS_ATTRIBUTE);
         if (cols>0)
             input.setCols(cols);
 
-        int rows = ii.getVSize();
+        int rows = getFormatInteger(ii, FORMAT_ROWS, FORMAT_ROWS_ATTRIBUTE);
         if (rows>0)
             input.setRows(rows);
         
@@ -71,5 +77,12 @@ public class TextAreaInputControl extend
         
         compList.add(input);
     }
+
+    /*
+    private int getTextareaCols(InputInfo ii)
+    {
+        ii.getColumn().getAttribute("");
+    }
+    */
     
 }

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=1326632&r1=1326631&r2=1326632&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 Apr 16 14:35:51 2012
@@ -47,7 +47,8 @@ public class TextInputControl extends In
     public static final String NAME = "text"; 
 
     public static final String FORMAT_UNIT = "unit:";
-
+    public static final String FORMAT_UNIT_ATTRIBUTE = "format:unit";
+    
     private Class<? extends javax.faces.component.html.HtmlInputText> inputComponentClass;
     
     public TextInputControl(String name, Class<? extends HtmlInputText> inputComponentClass)
@@ -176,9 +177,10 @@ public class TextInputControl extends In
         }
         // Check Value
         if (value == null)
-        {   // Try to use default value 
-            if (value!=vi.getNullValue())
-                return formatValue(vi.getNullValue(), vi, false);
+        {   // Try to use default value
+            Object nullValue = getFormatOption(vi, FORMAT_NULL, FORMAT_NULL_ATTRIBUTE);
+            if (nullValue!=null)
+                return formatValue(nullValue, vi, false);
             // Empty String
             return "";
         }
@@ -391,7 +393,7 @@ public class TextInputControl extends In
     private String getUnitString(ValueInfo vi)
     {
         // Is unit supplied as a format option
-        String format = getFormatOption(vi, FORMAT_UNIT);
+        String format = getFormatString(vi, FORMAT_UNIT, FORMAT_UNIT_ATTRIBUTE);
         if (format!=null)
             return format;
         // Is it a currency column

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=1326632&r1=1326631&r2=1326632&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 Apr 16 14:35:51 2012
@@ -197,6 +197,7 @@ public class TagEncodingHelper implement
             return getValueOptions();
         }
 
+        /*
         @Override
         public Object getNullValue()
         {
@@ -210,6 +211,7 @@ public class TagEncodingHelper implement
             // not available
             return null;
         }
+        */
 
         @Override
         public String getFormat()
@@ -293,24 +295,6 @@ public class TagEncodingHelper implement
         }
 
         @Override
-        public int getHSize()
-        {
-            Object size = tag.getAttributes().get("hSize");
-            if (size == null)
-                return 0;
-            return ObjectUtils.getInteger(size);
-        }
-
-        @Override
-        public int getVSize()
-        {
-            Object size = tag.getAttributes().get("vSize");
-            if (size == null)
-                return 0;
-            return ObjectUtils.getInteger(size);
-        }
-
-        @Override
         public String getInputId()
         {
             Column c = getColumn();



Mime
View raw message