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

SelectBox Class Reference

Inheritance diagram for SelectBox:

Widget DoctorSelect PatientSelect PolicySelect ServicesSelect List of all members.

Public Member Functions

 SelectBox (boolean multi, int rows, String prefix, Form form)
void loadValues ()
void display (boolean hidden)
void display (boolean hidden, String query)

Public Attributes

int rows
String text
boolean multi

Package Attributes

Integer id
Map ids = new HashMap()

Detailed Description

Definition at line 7 of file SelectBox.java.


Constructor & Destructor Documentation

SelectBox::SelectBox boolean  multi,
int  rows,
String  prefix,
Form  form
[inline]
 

Definition at line 16 of file SelectBox.java.

00017         {
00018           super(prefix, form);
00019           this.rows = rows;
00020           this.multi = multi;
00021         }


Member Function Documentation

void SelectBox::display boolean  hidden,
String  query
[inline]
 

Definition at line 48 of file SelectBox.java.

References Query::close(), Form::conn, Form::connectDb(), Widget::form, Widget::htmlencode(), ids, multi, Widget::n(), Widget::p(), Widget::prefix, Widget::printAttribute(), Form::pw, Query::r, and rows.

00049         {
00050           if (hidden)
00051           {
00052             if (multi)
00053             {
00054               Set s = ids.keySet();
00055               Iterator i = s.iterator();
00056               while(i.hasNext())
00057               {
00058                 Integer n = (Integer) i.next();
00059                 printAttribute(null, n.toString());
00060               }
00061             }
00062             else
00063             {
00064               if (id != null)
00065                 printAttribute(null, id.toString());
00066             }
00067             return;
00068           }
00069 
00070         p("<select name=" + prefix + " rows=" + rows + (multi ? " multiple" : "") + ">\n");
00071     if (query != null)
00072     {
00073       form.connectDb();
00074       Query q = new Query(form.conn, form.pw, query);
00075       try
00076       {
00077               if (q.r != null)
00078               while (q.r.next())
00079               {
00080                 int rid = q.r.getInt(1);
00081                 String rname = q.r.getString(2);
00082                 String s = (multi && ids.containsKey(new Integer(rid)))
00083                   || (!multi && id != null && id.intValue() == rid) ?
00084             " selected" : "";
00085                       p("  <option value=" + rid + s + ">" + htmlencode(rname) + "</option>\n");
00086               }
00087             }
00088             catch (SQLException e)
00089             {
00090               p(e);
00091             }
00092             finally
00093             {
00094               q.close();
00095             }
00096           }
00097           p("</select>\n");
00098         }

void SelectBox::display boolean  hidden  )  [inline]
 

Reimplemented from Widget.

Reimplemented in DoctorSelect, PatientSelect, PolicySelect, and ServicesSelect.

Definition at line 43 of file SelectBox.java.

References Widget::display().

00044         {
00045           display(hidden, null);
00046         }

void SelectBox::loadValues  )  [inline]
 

Reimplemented from Widget.

Definition at line 23 of file SelectBox.java.

References Widget::form, ids, Widget::loadAttribute(), multi, Widget::n(), Widget::prefix, Form::req, and Widget::toInt().

00024         {
00025     if (multi)
00026     {
00027       String[] v = form.req.getParameterValues(prefix);
00028       if (v == null) return;
00029       int vl = v.length;
00030       for(int i = 0; i < vl; ++i)
00031       {
00032         int n = toInt(v[i],0);
00033         if (n > 0) ids.put(new Integer(n), null);
00034       }
00035     }
00036     else
00037     {
00038       String s = loadAttribute();
00039       if (s != null) id = new Integer(toInt(s,0));
00040     }  
00041         }


Member Data Documentation

Integer SelectBox::id [package]
 

Definition at line 13 of file SelectBox.java.

Map SelectBox::ids = new HashMap() [package]
 

Definition at line 14 of file SelectBox.java.

boolean SelectBox::multi
 

Definition at line 11 of file SelectBox.java.

int SelectBox::rows
 

Definition at line 9 of file SelectBox.java.

String SelectBox::text
 

Definition at line 10 of file SelectBox.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