myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From caga...@apache.org
Subject svn commit: r697000 - in /myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle: AbstractToggleGroup.java ToggleGroupRenderer.java TogglePanelRenderer.java
Date Fri, 19 Sep 2008 09:02:43 GMT
Author: cagatay
Date: Fri Sep 19 02:02:42 2008
New Revision: 697000

URL: http://svn.apache.org/viewvc?rev=697000&view=rev
Log:
Added new toggled attribute : TOMAHAWK-1334

Modified:
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/AbstractToggleGroup.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java
    myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/AbstractToggleGroup.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/AbstractToggleGroup.java?rev=697000&r1=696999&r2=697000&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/AbstractToggleGroup.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/AbstractToggleGroup.java
Fri Sep 19 02:02:42 2008
@@ -137,4 +137,13 @@
      */
     public abstract String getOnmouseup();
     
-}
+    /**
+     * HTML: Flag to define the toggle status.
+     * 
+     * @JSFProperty
+     */
+     public abstract boolean isToggled();
+    
+     public abstract void setToggled(boolean toggleMode);
+    
+}
\ No newline at end of file

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java?rev=697000&r1=696999&r2=697000&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/ToggleGroupRenderer.java
Fri Sep 19 02:02:42 2008
@@ -40,10 +40,13 @@
 public class ToggleGroupRenderer extends HtmlGroupRendererBase {
 
     public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
+        ToggleGroup toggleGroup = (ToggleGroup) component;
         ResponseWriter writer = context.getResponseWriter();
 
         writer.startElement( org.apache.myfaces.shared_tomahawk.renderkit.html.HTML.SPAN_ELEM,
component );
         writer.writeAttribute(HTML.ID_ATTR, component.getClientId(context), null);
+        TogglePanelRenderer.setComponentVisibility(toggleGroup, !toggleGroup.isToggled());
+
         HtmlRendererUtils.renderHTMLAttributes( writer, component, HTML.COMMON_PASSTROUGH_ATTRIBUTES
);
 
         RendererUtils.renderChildren( context, component );

Modified: myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java
URL: http://svn.apache.org/viewvc/myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java?rev=697000&r1=696999&r2=697000&view=diff
==============================================================================
--- myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java
(original)
+++ myfaces/tomahawk/trunk/sandbox/core/src/main/java/org/apache/myfaces/custom/toggle/TogglePanelRenderer.java
Fri Sep 19 02:02:42 2008
@@ -45,6 +45,8 @@
  */
 public class TogglePanelRenderer extends HtmlGroupRendererBase {
 
+    private static Log log = LogFactory.getLog(TogglePanelRenderer.class);
+
     public void encodeEnd(FacesContext context, UIComponent component) throws IOException
{
         RendererUtils.checkParamValidity(context, component, TogglePanel.class);
         addScrollToJavascript(context);
@@ -81,7 +83,7 @@
     }
 
     // checks if this component has getStyle/setStyle methods
-    private boolean hasStyleAttribute(UIComponent component) {
+    public static boolean hasStyleAttribute(UIComponent component) {
         Method[] methods = component.getClass().getMethods();
 
         for (int i = 0; i < methods.length; i++) {
@@ -94,11 +96,11 @@
     }
 
     // hides component by appending 'display:none' to the 'style' attribute
-    private void setComponentVisibility(UIComponent component, boolean toggleMode) {
+    public static void setComponentVisibility(UIComponent component, boolean toggleMode)
{
         FacesContext context = FacesContext.getCurrentInstance();
 
         if (!hasStyleAttribute(component)) {
-            getLog().info("style attribute expected, not found for component " + component.getClientId(context));
+            log.info("style attribute expected, not found for component " + component.getClientId(context));
             return;
         }
 
@@ -134,15 +136,11 @@
 
             setStyle.invoke(component, new Object[] { style });
         } catch (Throwable e) {
-            getLog().error("unable to set style attribute on component " + component.getClientId(context));
+            log.error("unable to set style attribute on component " + component.getClientId(context));
         }
     }
 
-    private Log getLog() {
-        return LogFactory.getLog(TogglePanelRenderer.class);
-    }
-
-    private boolean isHiddenWhenToggled(UIComponent component){
+    public static boolean isHiddenWhenToggled(UIComponent component){
         return component instanceof ToggleLink || component instanceof ToggleGroup;
     }
 
@@ -180,7 +178,7 @@
             out.write( "var idsToHide = '" + idsToHide.toString() + "'.split(',');\n" );
             out.write( "for(var i=0;i<idsToHide.length;i++) document.getElementById(idsToHide[i]).style.display
= 'none';\n" );
         }else{ // no idsToHide set
-            getLog().warn( "TogglePanel "+ togglePanel.getClientId(context) +" has no visible
components when toggled." );
+            log.warn( "TogglePanel "+ togglePanel.getClientId(context) +" has no visible
components when toggled." );
         }
         out.write( "var idsToShow = idsToShowS.split(',');\n" );
         out.write( "scrollTo(idsToShow[0]);\n" );



Mime
View raw message