KickJava   Java API By Example, From Geeks To Geeks.

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


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.ArrayList JavaDoc;
9 import java.util.List JavaDoc;
10 import java.util.ResourceBundle JavaDoc ;
11
12 import javax.faces.context.ResponseWriter;
13 import org.exoplatform.faces.core.component.UIGrid;
14
15 /**
16  * Wed, Dec 22, 2003 @ 23:14
17  * @author: Tuan Nguyen
18  * @email: tuan08@users.sourceforge.net
19  * @version: $Id: ActionCell.java,v 1.1 2004/07/02 02:35:21 tuan08 Exp $
20  */

21 public class ActionCell extends Cell {
22   private List JavaDoc buttons_ ;
23   
24   public ActionCell() {
25     buttons_ = new ArrayList JavaDoc(3) ;
26   }
27   
28   public ActionCell add(Button button) {
29     buttons_.add(button) ;
30     return this ;
31   }
32   
33   public ActionCell add(boolean activate, Button button) {
34     if(!activate) {
35       button.setActivate(false) ;
36     }
37     buttons_.add(button) ;
38     return this ;
39   }
40   
41   public void render(ResponseWriter w, ResourceBundle JavaDoc res, UIGrid uiGrid, String JavaDoc cellTag) throws IOException JavaDoc {
42     w.write("<td") ;
43     if(attributes_ != null) {
44         int size = attributes_.size() ;
45         for(int i = 0; i < size ; i++) {
46             Cell.Attribute attr = (Cell.Attribute) attributes_.get(i) ;
47             w.write(' '); w.write(attr.name_); w.write("='"); w.write(attr.value_);w.write('\'') ;
48         }
49     }
50     w.write('>') ;
51     for(int i = 0; i < buttons_.size(); i++) {
52         Button button = (Button)buttons_.get(i);
53         button.render(w, res, uiGrid) ;
54     }
55     w.write("</td>") ;
56   }
57 }
Popular Tags