KickJava   Java API By Example, From Geeks To Geeks.

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


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.util.ResourceBundle JavaDoc ;
8 import java.io.IOException JavaDoc;
9 import javax.faces.context.ResponseWriter;
10 import javax.faces.context.FacesContext;
11 import org.exoplatform.faces.core.component.UIGrid;
12 import org.exoplatform.faces.core.component.UISimpleForm;
13 import org.exoplatform.faces.core.renderer.html.SimpleFormRenderer;
14
15 /**
16  * Wed, Dec 22, 2003 @ 23:14
17  * @author: Tuan Nguyen
18  * @email: tuan08@users.sourceforge.net
19  * @version: $Id: FormButton.java,v 1.11 2004/08/05 04:10:10 tuan08 Exp $
20  */

21 public class FormButton implements HtmlFragment {
22   
23   protected String JavaDoc label_;
24   protected String JavaDoc action_;
25   protected String JavaDoc clazz_;
26   protected short supportMode_ ;
27   private boolean visible_ = true;
28
29   public FormButton(String JavaDoc name, String JavaDoc action) {
30     label_ = name;
31     action_ = action;
32     supportMode_ = UISimpleForm.ALL_MODE ;
33   }
34   
35   public FormButton(String JavaDoc name, String JavaDoc action, short mode) {
36     label_ = name;
37     action_ = action;
38     supportMode_ = mode ;
39   }
40
41   public short getSupportMode() { return supportMode_ ; }
42   public void setSupportMode(short mode) { supportMode_ = mode ; }
43   
44   public String JavaDoc getLabel() { return label_ ; }
45   public void setLabel(String JavaDoc label) {
46     label_ = label;
47   }
48
49   public String JavaDoc getAction() { return action_ ;}
50   public void setAction(String JavaDoc action) {
51     action_ = action;
52   }
53   
54   public void setVisible(boolean visible) { visible_ = visible;}
55   public boolean isVisible(){return visible_ = true;}
56   
57   public String JavaDoc getClazz() { return clazz_ ; }
58   public void setClass(String JavaDoc s) {
59     clazz_ = s;
60   }
61   
62   public void render(ResponseWriter w, ResourceBundle JavaDoc res, UIGrid uiParent) throws IOException JavaDoc {
63     if(!visible_) return;
64     UISimpleForm uiForm = (UISimpleForm) uiParent ;
65     if(supportMode_ == UISimpleForm.ALL_MODE || supportMode_ == uiForm.getMode()) {
66       SimpleFormRenderer renderer =
67         (SimpleFormRenderer)uiParent.getComponentRenderer(FacesContext.getCurrentInstance()) ;
68       renderer.renderFormButton(this, res, w, uiParent) ;
69     }
70   }
71   
72 }
Popular Tags