Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
$URL: https://source.sakaiproject.org/svn/jsf/tags/sakai-10.0/jsf-widgets/src/java/org/sakaiproject/jsf/renderer/ToolBarItemRenderer.java $ $Id: ToolBarItemRenderer.java 126577 2013-07-02 12:11:17Z azeckoski@unicon.net $ Copyright (c) 2003, 2004, 2005, 2006, 2007, 2008 The Sakai Foundation Licensed under the Educational Community License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.opensource.org/licenses/ECL-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. /
 
 
 package org.sakaiproject.jsf.renderer;
 
 
 
 
 
 {
   public boolean supportsComponentType(UIComponent component)
   {
     return (component instanceof org.sakaiproject.jsf.component.ToolBarItemComponent);
   }
 
   public void encodeBegin(FacesContext contextUIComponent componentthrows IOException
   {
       if (!component.isRendered()) return;
 
     if (!isDisabled(contextcomponent))
     {
         // use default link rendering, after closing open span tag
 	  ResponseWriter writer = context.getResponseWriter();
 	  	writer.write(""); // normaly just close the span
       super.encodeBegin(contextcomponent);
     }
     else
     {
         // setup to render the disabled link ourselves - close open span tag after adding inactive attributes
       ResponseWriter writer = context.getResponseWriter();
       writer.write(""); //normally, add aria and class attributes and close the span
     }
 
   }
 
   public void encodeChildren(FacesContext contextUIComponent componentthrows IOException
   {
       if (!component.isRendered()) return;
 
       if (!isDisabled(contextcomponent))
       {
           // use default rendering
           super.encodeChildren(contextcomponent);
       }
       else
       {
           // render the text of the disabled link ourselves
       String label = "";
       Object value = ((UICommandcomponent).getValue();
       if (value != null)
       {
       label = value.toString();
       }
 
       ResponseWriter writer = context.getResponseWriter();
       writer.write(label);
       }
   }
 
   public void encodeEnd(FacesContext contextUIComponent componentthrows IOException
   {
       if (!component.isRendered()) return;
 
     if (!isDisabled(contextcomponent))
     {
         // use default link rendering
       super.encodeEnd(contextcomponent);
     }
     else
     {
         // rendering of end of disabled link taken care of already
     }
   }

  
Check if the component is disabled.

Parameters:
component
Returns:
true if the component has a boolean "disabled" attribute set, false if not
  protected boolean isDisabled(FacesContext contextUIComponent component)
  {
    boolean disabled = false;
    Object value = RendererUtil.getAttribute(contextcomponent"disabled");
    if (value != null)
    {
      if (value instanceof Boolean)
      {
        disabled = ((Booleanvalue).booleanValue();
      }
      else
      {
        if (!(value instanceof String))
        {
          value = value.toString();
        }
        disabled = (new Boolean((Stringvalue)).booleanValue();
      }
    }
    return disabled;
  }
New to GrepCode? Check out our FAQ X