1 5 package org.exoplatform.faces.core.component.model; 6 7 import java.util.ResourceBundle ; 8 import java.io.IOException ; 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 21 public class FormButton implements HtmlFragment { 22 23 protected String label_; 24 protected String action_; 25 protected String clazz_; 26 protected short supportMode_ ; 27 private boolean visible_ = true; 28 29 public FormButton(String name, String action) { 30 label_ = name; 31 action_ = action; 32 supportMode_ = UISimpleForm.ALL_MODE ; 33 } 34 35 public FormButton(String name, String 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 getLabel() { return label_ ; } 45 public void setLabel(String label) { 46 label_ = label; 47 } 48 49 public String getAction() { return action_ ;} 50 public void setAction(String 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 getClazz() { return clazz_ ; } 58 public void setClass(String s) { 59 clazz_ = s; 60 } 61 62 public void render(ResponseWriter w, ResourceBundle res, UIGrid uiParent) throws IOException { 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 |