Package org.xulfaces.renderer.tree

Source Code of org.xulfaces.renderer.tree.TreeRowRenderer

/*
*   xulfaces : bring XUL power to Java
*  
*  Copyright (C) 2005  Olivier SCHMITT
*  This library is free software; you can redistribute it and/or
*  modify it under the terms of the GNU Lesser General Public
*  License as published by the Free Software Foundation; either
*  version 2.1 of the License, or (at your option) any later version.
*
*  This library is distributed in the hope that it will be useful,
*  but WITHOUT ANY WARRANTY; without even the implied warranty of
*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
*  Lesser General Public License for more details.
*
*  You should have received a copy of the GNU Lesser General Public
*  License along with this library; if not, write to the Free Software
*  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
*/


package org.xulfaces.renderer.tree;

import java.io.IOException;
import java.util.List;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

import org.xulfaces.SmoothlyUpdateable;
import org.xulfaces.annotation.faces.RENDERER;
import org.xulfaces.bridge.Bridge;
import org.xulfaces.bridge.Zone;
import org.xulfaces.bridge.command.UpdateZoneCommand;
import org.xulfaces.component.tree.TreeCellComponent;
import org.xulfaces.component.tree.TreeItemComponent;
import org.xulfaces.component.tree.TreeRowComponent;
import org.xulfaces.renderer.XULRenderer;
import org.xulfaces.utils.XulUtils;

/**
*
* @author kito31
* @version $Id: TreeRowRenderer.java,v 1.12 2007/06/10 19:46:41 kito31 Exp $
*/
@RENDERER(kit="XUL_RENDERKIT",family="xul.component.family",type="xul.renderer.TreeRow")
public class TreeRowRenderer extends XULRenderer {

 
  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {
   
    ResponseWriter responseWriter = facesContext.getResponseWriter();   
    responseWriter.startElement("treerow",component);
    TreeRowComponent treeRowComponent = (TreeRowComponent) component;
    TreeItemComponent treeItemComponent = (TreeItemComponent) treeRowComponent.getParent();
    StringBuffer stringBuffer = new StringBuffer(treeItemComponent.getNodeId());
    stringBuffer.append(":tr");
    treeRowComponent.setNodeId(stringBuffer.toString());
    responseWriter.writeAttribute("id",treeRowComponent.getNodeId(), "id");
    if(!isParentSmoothlyUpdateable(component)){
      if (component instanceof SmoothlyUpdateable) {
        SmoothlyUpdateable smoothlyUpdateable = (SmoothlyUpdateable) component;
        if (smoothlyUpdateable.needsUpdate()) {
          Bridge bridge = XulUtils.getBridge();
          Zone zone = new Zone(treeRowComponent.getNodeId());
          bridge.addCommand(new UpdateZoneCommand(zone,buildTargetName(component)));
        }
      }
    }
   
    renderAttributes(facesContext, component, (List) component
        .getAttributes().get("annotatedAttributes"));
  }

  public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {
    List children  = component.getChildren();
    for (int j = 0, size = component.getChildCount(); j < size; j++) {
      TreeCellComponent treeCellComponent = (TreeCellComponent) children.get(j);
      if (treeCellComponent.isRendered()) {
        renderChild(facesContext,treeCellComponent);             
      }
    }
  }

  public void encodeEnd(FacesContext facesContext, UIComponent component) throws IOException {              
    ResponseWriter responseWriter = facesContext.getResponseWriter();   
        responseWriter.endElement("treerow");       
  }
 
  public boolean getRendersChildren() {
    return true;
  }
}
TOP

Related Classes of org.xulfaces.renderer.tree.TreeRowRenderer

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.