Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members

Widget Class Reference

Inheritance diagram for Widget:

ActionButton AppointmentEditor AppointmentList DiagnosisEditor DiagnosisList PatientEditor PatientList ReferralEditor ReferralList SelectBox TableEditor TextBox List of all members.

Public Member Functions

 Widget (String prefix, Form form)
void addChild (Widget w)
void loadDefaults ()
void loadValues ()
void display ()
void display (boolean hidden)
void dumpscript ()
String loadAttribute ()
String loadAttribute (String name)
String n (String suffix)
void printAttribute (String name, String value)
void preserveAttribute (String name)
void p (String str)
void p (Exception e)
String serialize (Serializable o)
Object unserialize (String s)
int toInt (String str, int def)

Static Public Member Functions

static String htmlencode (String v)
static void ShowException (Throwable t, PrintWriter pw)

Public Attributes

String prefix
Form form
boolean modal = false
Vector children = new Vector()
Widget modalChild
String name
int method

Static Public Attributes

static final int GET = 1
static final int POST = 2
static final int BOTH = 3

Detailed Description

Definition at line 10 of file Widget.java.


Constructor & Destructor Documentation

Widget::Widget String  prefix,
Form  form
[inline]
 

Definition at line 27 of file Widget.java.

00028   {
00029     this.prefix = prefix;
00030     this.form = form;
00031   }


Member Function Documentation

void Widget::addChild Widget  w  )  [inline]
 

Definition at line 33 of file Widget.java.

References children.

00034   {
00035     children.add(w);
00036   }

void Widget::display boolean  hidden  )  [inline]
 

Reimplemented in ActionButton, AppointmentEditor, AppointmentList, DiagnosisEditor, DiagnosisList, DoctorSelect, PatientEditor, PatientList, PatientSelect, PolicySelect, ReferralEditor, ReferralList, SelectBox, ServicesSelect, TableEditor, and TextBox.

Definition at line 64 of file Widget.java.

References children, display(), modal, and modalChild.

00065   {
00066     if (hidden || modalChild != null)
00067     {
00068       int l = children.size();
00069       for(int i = 0; i < l; ++i)
00070       {
00071         Widget w = (Widget)children.get(i);
00072         w.display(!w.modal);
00073       }
00074     }
00075   }

void Widget::display  )  [inline]
 

Definition at line 59 of file Widget.java.

00060   {
00061     display(false);
00062   }

void Widget::dumpscript  )  [inline]
 

Definition at line 77 of file Widget.java.

00077 { }

static String Widget::htmlencode String  v  )  [inline, static]
 

Definition at line 115 of file Widget.java.

00116   {
00117     if (v == null) return "";
00118     StringBuffer b = new StringBuffer();
00119     int l = v.length();
00120 
00121     for(int i = 0; i < l; ++i)
00122     {
00123       char c = v.charAt(i);
00124 
00125       switch (c)
00126       {
00127         case '"':
00128           b.append("&quot;");
00129         break;
00130         case '<':
00131           b.append("&lt;");
00132         break;
00133         case '>':
00134           b.append("&gt;");
00135         break;
00136         case '&':
00137           b.append("&amp;");
00138         break;
00139         default:
00140           b.append(c);
00141         break;
00142       }
00143     }
00144     return b.toString();
00145   }

String Widget::loadAttribute String  name  )  [inline]
 

Definition at line 84 of file Widget.java.

References form, n(), and Form::req.

00085   {
00086     return form.req.getParameter(n(name));
00087   }

String Widget::loadAttribute  )  [inline]
 

Definition at line 79 of file Widget.java.

References form, prefix, and Form::req.

00080   {
00081     return form.req.getParameter(prefix);
00082   }

void Widget::loadDefaults  )  [inline]
 

Reimplemented in AppointmentEditor, DiagnosisEditor, PatientEditor, and ReferralEditor.

Definition at line 38 of file Widget.java.

References children, and loadDefaults().

00039   {
00040     int l = children.size();
00041     for(int i = 0; i < l; ++i)
00042     {
00043       Widget w = (Widget)children.get(i);
00044       w.loadDefaults();
00045     }    
00046   }

void Widget::loadValues  )  [inline]
 

Reimplemented in ActionButton, AppointmentEditor, AppointmentList, DiagnosisEditor, DiagnosisList, PatientEditor, PatientList, ReferralEditor, ReferralList, SelectBox, TableEditor, and TextBox.

Definition at line 48 of file Widget.java.

References children, loadValues(), modal, and modalChild.

00049   {
00050     int l = children.size();
00051     for(int i = 0; i < l; ++i)
00052     {
00053       Widget w = (Widget)children.get(i);
00054       w.loadValues();
00055       if (w.modal) modalChild = w;
00056     }
00057   }

String Widget::n String  suffix  )  [inline]
 

Definition at line 89 of file Widget.java.

References prefix.

00090   {
00091     return suffix != null ? prefix + "." + suffix : prefix;
00092   }

void Widget::p Exception  e  )  [inline]
 

Definition at line 110 of file Widget.java.

References form, Form::pw, and ShowException().

00111   {
00112     ShowException(e, form.pw);
00113   }

void Widget::p String  str  )  [inline]
 

Definition at line 105 of file Widget.java.

References form, and Form::pw.

00106   {
00107     form.pw.print(str);
00108   }

void Widget::preserveAttribute String  name  )  [inline]
 

Definition at line 99 of file Widget.java.

References loadAttribute(), and printAttribute().

00100   {
00101     String v = loadAttribute(name);
00102     if (v != null) printAttribute(name, v);
00103   }

void Widget::printAttribute String  name,
String  value
[inline]
 

Definition at line 94 of file Widget.java.

References htmlencode(), n(), and p().

00095   {
00096     p("<input type=hidden name=\"" + n(name) + "\" value=\"" + htmlencode(value) + "\">");
00097   }

String Widget::serialize Serializable  o  )  [inline]
 

Definition at line 147 of file Widget.java.

References p().

00148   {
00149     String r = null;
00150     try
00151     {
00152       ByteArrayOutputStream bos = new ByteArrayOutputStream();
00153       try
00154       {
00155         ObjectOutputStream oos = new ObjectOutputStream(bos);
00156         try
00157         {
00158           oos.writeObject(o);
00159           oos.flush();
00160           r = Base64.encodeBytes(bos.toByteArray());
00161         }
00162         finally
00163         {
00164           oos.close();
00165         }
00166       }
00167       finally
00168       {
00169         bos.close();
00170       }
00171     }
00172     catch (java.io.IOException e)
00173     {
00174       p("<h1>Serialize IO Exception: " + e.toString() + "</h1>");
00175     }
00176     return r;
00177   }

static void Widget::ShowException Throwable  t,
PrintWriter  pw
[inline, static]
 

Definition at line 226 of file Widget.java.

00227   {
00228     pw.println("</select>");
00229     pw.println("<h2>Exception Caught</h2>");
00230     pw.print("<pre style=\"background-color: #eeeeee\">");
00231     t.printStackTrace(pw);
00232     pw.println("</pre>");
00233   }

int Widget::toInt String  str,
int  def
[inline]
 

Definition at line 214 of file Widget.java.

00215   {
00216     try
00217     {
00218       return str == null ? def : Integer.parseInt(str);
00219     }
00220     catch (java.lang.NumberFormatException e)
00221     {
00222       return def;
00223     }
00224   }

Object Widget::unserialize String  s  )  [inline]
 

Definition at line 179 of file Widget.java.

References p().

00180   {
00181     Object o = null;
00182     try
00183     {
00184       InputStream is = new ByteArrayInputStream(Base64.decode(s));
00185       try
00186       {
00187         ObjectInputStream ois = new ObjectInputStream(is);
00188         try
00189         {
00190           o = ois.readObject();
00191         }
00192         finally
00193         {
00194           ois.close();
00195         }
00196         is.close();
00197       }
00198       finally
00199       {
00200         is.close();
00201       }
00202     }
00203     catch (java.io.IOException e)
00204     {
00205       p(e);
00206     }
00207     catch (java.lang.ClassNotFoundException e)
00208     {
00209       p(e);
00210     }
00211     return o;
00212   }


Member Data Documentation

final int Widget::BOTH = 3 [static]
 

Definition at line 22 of file Widget.java.

Vector Widget::children = new Vector()
 

Definition at line 17 of file Widget.java.

Form Widget::form
 

Definition at line 13 of file Widget.java.

final int Widget::GET = 1 [static]
 

Definition at line 20 of file Widget.java.

int Widget::method
 

Definition at line 25 of file Widget.java.

boolean Widget::modal = false
 

Definition at line 15 of file Widget.java.

Widget Widget::modalChild
 

Definition at line 18 of file Widget.java.

String Widget::name
 

Reimplemented in DiagnosisEditor, and PatientEditor.

Definition at line 24 of file Widget.java.

final int Widget::POST = 2 [static]
 

Definition at line 21 of file Widget.java.

String Widget::prefix
 

Definition at line 12 of file Widget.java.


The documentation for this class was generated from the following file:
Generated on Mon Mar 6 23:34:35 2006 by  doxygen 1.4.4