1 13 package com.tonbeller.wcf.toolbar; 14 15 import com.tonbeller.wcf.controller.RequestContext; 16 17 28 public abstract class ToolBarComponentSupport implements ToolBarComponent { 29 30 String role; 31 String visibleExpr; 32 boolean visible = true; 33 String id; 34 35 48 public boolean isVisible(RequestContext context) { 49 if (!visible) 50 return false; 51 52 if (!context.isUserInRole(role)) 54 return false; 55 56 if (visibleExpr != null) { 58 if ("true".equals(visibleExpr)) 59 return true; 60 if ("false".equals(visibleExpr)) 61 return false; 62 Object val = context.getModelReference(visibleExpr); 63 String s = String.valueOf(val); 64 boolean b = Boolean.valueOf(s).booleanValue(); 65 return b; 66 } 67 68 return true; 69 } 70 71 74 public String getVisibleExpr() { 75 return visibleExpr; 76 } 77 78 81 public void setVisibleExpr(String string) { 82 visibleExpr = string; 83 } 84 85 88 public String getRole() { 89 return role; 90 } 91 92 95 public void setRole(String role) { 96 this.role = role; 97 } 98 99 public boolean isVisible() { 100 return visible; 101 } 102 public void setVisible(boolean visible) { 103 this.visible = visible; 104 } 105 public String getId() { 106 return id; 107 } 108 public void setId(String id) { 109 this.id = id; 110 } 111 } 112 | Popular Tags |