[richfaces-svn-commits] JBoss Rich Faces SVN: r18842 - in trunk: examples/output-demo/src/main/webapp/examples and 4 other directories.

richfaces-svn-commits at lists.jboss.org richfaces-svn-commits at lists.jboss.org
Fri Aug 20 06:54:22 EDT 2010


Author: Alex.Kolonitsky
Date: 2010-08-20 06:54:21 -0400 (Fri, 20 Aug 2010)
New Revision: 18842

Modified:
   trunk/examples/output-demo/src/main/java/org/richfaces/TogglePanelBean.java
   trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml
   trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlAccordion.java
   trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
   trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
   trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
   trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
   trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js
   trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
Log:
Accordion width and height attributes

Modified: trunk/examples/output-demo/src/main/java/org/richfaces/TogglePanelBean.java
===================================================================
--- trunk/examples/output-demo/src/main/java/org/richfaces/TogglePanelBean.java	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/examples/output-demo/src/main/java/org/richfaces/TogglePanelBean.java	2010-08-20 10:54:21 UTC (rev 18842)
@@ -29,7 +29,6 @@
     }
 
     public String getValue() {
-        System.out.println("value = " + value);
         return value;
     }
 

Modified: trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml
===================================================================
--- trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/examples/output-demo/src/main/webapp/examples/accordion.xhtml	2010-08-20 10:54:21 UTC (rev 18842)
@@ -15,7 +15,7 @@
         <p>Page</p>
 
         <h:form id="f" style="border:blue solid thin;">
-            <pn:accordion>
+            <pn:accordion width="500px" height="300px">
                 <pn:accordionItem header="label 1">Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here. Content will be here.</pn:accordionItem>
                 <pn:accordionItem header="label 2">content 2</pn:accordionItem>
                 <pn:accordionItem header="label 3">content 3</pn:accordionItem>

Modified: trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlAccordion.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlAccordion.java	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/component/html/HtmlAccordion.java	2010-08-20 10:54:21 UTC (rev 18842)
@@ -70,6 +70,8 @@
         onmousedown,
         onmousemove,
         onmouseout,
+        width,
+        height,
         onmouseover,
         onmouseup
     }
@@ -83,6 +85,22 @@
         return COMPONENT_FAMILY;
     }
 
+    public String getWidth() {
+        return (String) getStateHelper().eval(PropertyKeys.width);
+    }
+
+    public void setWidth(String width) {
+        getStateHelper().put(PropertyKeys.width, width);
+    }
+
+    public String getHeight() {
+        return (String) getStateHelper().eval(PropertyKeys.height);
+    }
+
+    public void setHeight(String height) {
+        getStateHelper().put(PropertyKeys.height, height);
+    }
+
     public String getItemHeaderClassActive() {
         return (String) getStateHelper().eval(PropertyKeys.itemHeaderClassActive);
     }

Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/AccordionRenderer.java	2010-08-20 10:54:21 UTC (rev 18842)
@@ -25,6 +25,7 @@
 import org.ajax4jsf.javascript.JSObject;
 import org.ajax4jsf.renderkit.RendererUtils;
 import org.richfaces.component.AbstractAccordion;
+import org.richfaces.component.util.HtmlUtil;
 
 import javax.faces.application.ResourceDependencies;
 import javax.faces.application.ResourceDependency;
@@ -34,6 +35,8 @@
 import java.io.IOException;
 import java.util.Map;
 
+import static org.richfaces.component.html.HtmlAccordion.PropertyKeys.*;
+
 /**
  * @author akolonitsky
  * @since 2010-08-05
@@ -56,6 +59,15 @@
     }
 
     @Override
+    protected String getStyle(UIComponent component) {
+        return HtmlUtil.concatStyles(
+            attributeAsStyle(component, height),
+            attributeAsStyle(component, width),
+
+            super.getStyle(component));
+    }
+
+    @Override
     protected String getStyleClass(UIComponent component) {
         return "rf-ac " + attributeAsString(component, "styleClass");
     }
@@ -79,6 +91,7 @@
     @Override
     protected Map<String, Object> getScriptObjectOptions(FacesContext context, UIComponent component) {
         Map<String, Object> options = super.getScriptObjectOptions(context, component);
+        options.put("isKeepHeight", !attributeAsString(component, height).isEmpty());
         options.remove("items");
 
         return options;

Modified: trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java
===================================================================
--- trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/ui/output/ui/src/main/java/org/richfaces/renderkit/html/DivPanelRenderer.java	2010-08-20 10:54:21 UTC (rev 18842)
@@ -43,7 +43,7 @@
  */
 public class DivPanelRenderer extends RendererBase {
 
-    private static final RenderKitUtils.Attributes PASS_THROUGH_ATTRIBUTES0 = attributes(
+    private static final RenderKitUtils.Attributes PASS_THROUGH_ATTRIBUTES = attributes(
         lang,
         onclick,
         ondblclick,
@@ -53,10 +53,21 @@
         onmouseover,
         onmouseup,
         title,
-        style,
         dir
     );
 
+    protected static String attributeAsStyle(UIComponent comp, Enum attr) {
+        String value = attributeAsString(comp, attr.toString());
+        if (value.isEmpty()) {
+            return "";
+        }
+
+        return new StringBuilder()
+            .append(attr).append(':').append(value).toString();
+    }
+    protected static String attributeAsString(UIComponent comp, Enum attr) {
+        return attributeAsString(comp, attr.toString());
+    }
     protected static String attributeAsString(UIComponent comp, String attr) {
         Object o = comp.getAttributes().get(attr);
         return o == null ? "" : o.toString();
@@ -80,9 +91,18 @@
         writer.startElement(HTML.DIV_ELEM, component);
         writer.writeAttribute("id", component.getClientId(context), "clientId");
         writer.writeAttribute("class", getStyleClass(component), null);
-        renderPassThroughAttributes(context, component, PASS_THROUGH_ATTRIBUTES0);
+        writer.writeAttribute(HTML.STYLE_ATTRIBUTE, getStyle(component), null);
+        renderPassThroughAttributes(context, component, getPassThroughAttributes());
     }
 
+    protected String getStyle(UIComponent component) {
+        return attributeAsString(component, "style");
+    }
+
+    protected RenderKitUtils.Attributes getPassThroughAttributes() {
+        return PASS_THROUGH_ATTRIBUTES;
+    }
+
     protected String getStyleClass(UIComponent component) {
         return attributeAsString(component, "styleClass");
     }

Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.faces-config.xml	2010-08-20 10:54:21 UTC (rev 18842)
@@ -25,6 +25,16 @@
         </property>
         <property>
             <description></description>
+            <property-name>height</property-name>
+            <property-class>java.lang.String</property-class>
+        </property>
+        <property>
+            <description></description>
+            <property-name>width</property-name>
+            <property-class>java.lang.String</property-class>
+        </property>
+        <property>
+            <description></description>
             <property-name>bypassUpdates</property-name>
             <property-class>boolean</property-class>
         </property>

Modified: trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/ui/output/ui/src/main/resources/META-INF/pn.taglib.xml	2010-08-20 10:54:21 UTC (rev 18842)
@@ -338,6 +338,16 @@
         </attribute>
         <attribute>
             <description></description>
+            <name>height</name>
+            <type>java.lang.String</type>
+        </attribute>
+        <attribute>
+            <description></description>
+            <name>width</name>
+            <type>java.lang.String</type>
+        </attribute>
+        <attribute>
+            <description></description>
             <name>bypassUpdates</name>
             <type>boolean</type>
         </attribute>

Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/AccordionItem.js	2010-08-20 10:54:21 UTC (rev 18842)
@@ -69,7 +69,10 @@
          * @return {jQuery Object}
          * */
         __content : function () {
-            return $(rf.getDomElement(this.id + ":content"));
+            if (!this.__content_) {
+                this.__content_ = $(rf.getDomElement(this.id + ":content"));
+            }
+            return this.__content_;
         },
 
         /**
@@ -80,14 +83,15 @@
         __enter : function () {
             var parentPanel = this.getTogglePanel();
             if (parentPanel.isKeepHeight) {
+                this.__content().hide();
                 var h = parentPanel.getInnerHeight();
 
                 var items = parentPanel.getItems();
                 for (var i = 0; i < items.length; i++) {
-                    h -= items[i].getHeight();
+                    h -= items[i].__header().outerHeight();
                 }
 
-                this.__content().height(h);
+                this.__content().height(h - 20); // 20 it is padding top and bottom
             }
 
             this.__content().show();

Modified: trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss
===================================================================
--- trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss	2010-08-20 10:41:27 UTC (rev 18841)
+++ trunk/ui/output/ui/src/main/resources/META-INF/resources/org.richfaces/accordion.ecss	2010-08-20 10:54:21 UTC (rev 18842)
@@ -1,5 +1,5 @@
 .rf-ac {
-    width: 300px; /*visible width*/
+    /*width: 300px;*/ /*visible width*/
     border-width: 1px;
     border-style: solid;
     border-color: '#{richSkin.panelBorderColor}';
@@ -28,7 +28,7 @@
     border-bottom-width: 1px;
     border-bottom-style: solid;
     border-bottom-color: '#{richSkin.panelBorderColor}';
-    height: 100px /*visible modal panel height minus header height*/;
+    /*height: 100px*/ /*visible modal panel height minus header height*/;
     position: relative;
     overflow: auto;
     overflow-x: hidden;



More information about the richfaces-svn-commits mailing list