empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1485233 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2: components/MenuItemTag.java components/MenuListTag.java pageelements/ListPageElement.java utils/TagEncodingHelper.java
Date Wed, 22 May 2013 14:41:09 GMT
Author: doebele
Date: Wed May 22 14:41:08 2013
New Revision: 1485233

URL: http://svn.apache.org/r1485233
Log:
EMPIREDB-185
Add value expression evaluation for MyFaces

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuItemTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/ListPageElement.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/components/MenuItemTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuItemTag.java?rev=1485233&r1=1485232&r2=1485233&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuItemTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuItemTag.java
Wed May 22 14:41:08 2013
@@ -115,7 +115,10 @@ public class MenuItemTag extends LinkTag
         if(!isRendered())
             return;
         // call base
-        super.encodeEnd(context);
+        if (isExpanded())
+        {
+            super.encodeEnd(context);
+        }
         // end of list item
         ResponseWriter writer = context.getResponseWriter();
         writer.endElement("li");

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java?rev=1485233&r1=1485232&r2=1485233&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/components/MenuListTag.java
Wed May 22 14:41:08 2013
@@ -19,7 +19,6 @@
 package org.apache.empire.jsf2.components;
 
 import java.io.IOException;
-import java.util.Map;
 
 import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
@@ -29,12 +28,15 @@ import javax.faces.context.FacesContext;
 import javax.faces.context.ResponseWriter;
 
 import org.apache.empire.commons.StringUtils;
+import org.apache.empire.jsf2.utils.TagEncodingHelper;
 
 public class MenuListTag extends UIOutput implements NamingContainer
 {
     // Logger
     // private static final Logger log = LoggerFactory.getLogger(MenuTag.class);
     
+    private final TagEncodingHelper helper = new TagEncodingHelper(this, "eMenuList");
+    
     private String currentId = null; 
     private String currentClass = null; 
     // private String enabledClass = null; 
@@ -56,15 +58,14 @@ public class MenuListTag extends UIOutpu
         // call base
         super.encodeBegin(context);
         
-        Map<String, Object> map = getAttributes();
-        initMenuAttributes(map);
+        initMenuAttributes();
 
         // render components
         ResponseWriter writer = context.getResponseWriter();
         writer.startElement("ul", this);
         // writeAttribute(writer, map, "id");
-        writeAttribute(writer, map, "styleClass", "class");
-        writeAttribute(writer, map, "style");
+        helper.writeAttribute(writer, "class", helper.getTagAttributeString("styleClass"));
+        helper.writeAttribute(writer, "style", helper.getTagAttributeString("style"));
     }
 
     /*
@@ -75,25 +76,33 @@ public class MenuListTag extends UIOutpu
         return test;
     }
     */
+    
+    @Override
+    public void encodeChildren(FacesContext context)
+        throws IOException
+    {
+        super.encodeChildren(context);
+    }
 
     @Override
     public void encodeEnd(FacesContext context)
         throws IOException
     {
-        ResponseWriter writer = context.getResponseWriter();
-        writer.endElement("ul");
         // call base
         super.encodeEnd(context);
+        // close
+        ResponseWriter writer = context.getResponseWriter();
+        writer.endElement("ul");
     }
     
-    private void initMenuAttributes(Map<String, Object> map)
-    {
-        currentId = StringUtils.toString(map.get("currentId"));
-        currentClass = StringUtils.toString(map.get("currentClass")); 
-        // enabledClass = StringUtils.toString(map.get("enabledClass")); 
-        disabledClass = StringUtils.toString(map.get("disabledClass")); 
-        expandedClass = StringUtils.toString(map.get("expandedClass"));
-        defaultItemClass = StringUtils.toString(map.get("defaultItemClass"));
+    private void initMenuAttributes()
+    {        
+        currentId        = helper.getTagAttributeString("currentId"); 
+        currentClass     = helper.getTagAttributeString("currentClass"); 
+        // enabledClass  = StringUtils.toString(map.get("enabledClass")); 
+        disabledClass    = helper.getTagAttributeString("disabledClass"); 
+        expandedClass    = helper.getTagAttributeString("expandedClass");
+        defaultItemClass = helper.getTagAttributeString("defaultItemClass");
         
         MenuListTag parent = getParentMenu();
         if (parent==null)
@@ -171,7 +180,7 @@ public class MenuListTag extends UIOutpu
         return defaultItemClass;
     }
 
-    /** setters wozu? **/
+    /* setters */
     
     public void setCurrentId(String currentId)
     {
@@ -200,17 +209,4 @@ public class MenuListTag extends UIOutpu
         this.expandedClass = expandedClass;
     }
 
-    protected void writeAttribute(ResponseWriter writer, Map<String, Object> map, String
attribute, String targetName)
-        throws IOException
-    {
-        Object value = map.get(attribute);
-        if (value != null)
-            writer.writeAttribute(targetName, value, null);
-    }
-    protected void writeAttribute(ResponseWriter writer, Map<String, Object> map, String
attribute)
-        throws IOException
-    {
-        writeAttribute(writer, map, attribute, attribute);
-    }
-
 }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/ListPageElement.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/ListPageElement.java?rev=1485233&r1=1485232&r2=1485233&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/ListPageElement.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pageelements/ListPageElement.java
Wed May 22 14:41:08 2013
@@ -423,21 +423,46 @@ public abstract class ListPageElement<T>
         return this.items;
     }
 
+    /**
+     * returns whether the item list has been loaded 
+     * @return true if the item list has been loaded even it contains no items for false
otherwise
+     */
     public final boolean isValid()
     {
-        return (this.items != null); //  ? false : this.items.size() > 0
+        return (this.items != null);
     }
 
+    /**
+     * returns true if the either the item list is not valid or if it contains no items 
+     * @return true if the either the item list is not valid or if it contains no items
+     */
     public final boolean isEmpty()
     {
         return (this.items==null || this.items.size()==0);
     }
 
+    /**
+     * returns whether the item list is valid and contains at least one item 
+     * @return true if the item list contains one or more items or false otherwise
+     */
     public final boolean isNotEmpty()
     {
         return (this.items!=null && this.items.size()>0);
     }
 
+    /**
+     * added as "isEmpty" is not accessible from EL.
+     * @return true if the either the item list is not valid or if it contains no items
+     */
+    public final boolean isBlank()
+    {
+        return isEmpty();
+    }
+
+    /**
+     * returns the total item count of the entire list (not just the visible part)
+     * @return the total number of items in the list
+     */
     public int getItemCount()
     {
         return getTableInfo().getItemCount();

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=1485233&r1=1485232&r2=1485233&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
Wed May 22 14:41:08 2013
@@ -1120,11 +1120,6 @@ public class TagEncodingHelper implement
         FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_ERROR, msgText, msgText);
         context.addMessage(tag.getClientId(), msg);
     }
-    
-    public Object getTagAttributeValue(String name)
-    {
-        return tag.getAttributes().get(name);
-    }
 
     public Object getAttributeValueEx(String name)
     { 
@@ -1158,9 +1153,24 @@ public class TagEncodingHelper implement
         return value;
     }
     
+    public Object getTagAttributeValue(String name)
+    {
+        Object value = tag.getAttributes().get(name);
+        if (value==null)
+        {   // try value expression
+            ValueExpression ve = tag.getValueExpression(name);
+            if (ve!=null)
+            {   // It's a value expression
+                FacesContext ctx = FacesContext.getCurrentInstance();
+                value = ve.getValue(ctx.getELContext());
+            }
+        }
+        return value;
+    }
+    
     public String getTagAttributeString(String name, String defValue)
     {
-        Object  v = tag.getAttributes().get(name);
+        Object  v = getTagAttributeValue(name);
         return (v!=null) ? StringUtils.toString(v) : defValue;
     }
 



Mime
View raw message