KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > exoplatform > faces > core > component > model > ComponentCell


1 /***************************************************************************
2  * Copyright 2001-2003 The eXo Platform SARL All rights reserved. *
3  * Please look at license.txt in info directory for more license detail. *
4  **************************************************************************/

5 package org.exoplatform.faces.core.component.model;
6
7 import java.io.IOException JavaDoc ;
8 import java.util.ResourceBundle JavaDoc;
9 import javax.faces.context.ResponseWriter ;
10 import javax.faces.context.FacesContext;
11 import javax.faces.component.UIComponent;
12 import org.exoplatform.faces.core.component.UIGrid;
13
14 /**
15  * Wed, Dec 22, 2003 @ 23:14
16  * @author: Tuan Nguyen
17  * @email: tuan08@users.sourceforge.net
18  * @version: $Id: ComponentCell.java,v 1.3 2004/06/30 19:52:01 tuan08 Exp $
19  */

20 public class ComponentCell extends Cell {
21   private UIComponent component_ ;
22
23   public ComponentCell(UIComponent parent, UIComponent comp) {
24     component_ = comp ;
25     parent.getChildren().add(comp) ;
26   }
27
28   public void setComponent(UIComponent parent, UIComponent comp) {
29     component_ = comp ;
30     parent.getChildren().add(comp) ;
31   }
32
33   public void render(ResponseWriter w, ResourceBundle JavaDoc res, UIGrid uiGrid, String JavaDoc cellTag) throws IOException JavaDoc {
34     w.write('<');w.write(cellTag) ;
35     if(attributes_ != null) {
36       int size = attributes_.size() ;
37       for(int i = 0; i < size ; i++) {
38         Cell.Attribute attr = (Cell.Attribute) attributes_.get(i) ;
39         w.write(' ');w.write(attr.name_);w.write("='");w.write(attr.value_);w.write('\'') ;
40       }
41     }
42     FacesContext context = FacesContext.getCurrentInstance() ;
43     w.write('>') ;
44     component_.encodeBegin(context) ;
45     component_.encodeChildren(context) ;
46     component_.encodeEnd(context) ;
47     w.write("</");w.write(cellTag);w.write(">") ;
48   }
49 }
50
Popular Tags