00001 import java.util.Enumeration;
00002
00003 public class ActionButton extends Widget
00004 {
00005 int action = 0;
00006 int param = 0;
00007
00008 public ActionButton(String prefix, Form form)
00009 {
00010 super(prefix, form);
00011 }
00012
00013 public void loadValues()
00014 {
00015 String s = form.req.getParameter(prefix);
00016 if(s != null && s.length() > 0)
00017 setThisString(s);
00018 else
00019 {
00020 String c = prefix + ".";
00021 int cl = c.length();
00022
00023 for (Enumeration e = form.req.getParameterNames(); e.hasMoreElements() ;)
00024 {
00025 String n = (String) e.nextElement();
00026 if (n == null) break;
00027 if (n.length() < cl) continue;
00028 if (n.substring(0,cl).equals(c))
00029 {
00030 String p = n.substring(cl);
00031 setThisString(p);
00032 break;
00033 }
00034 }
00035 }
00036 }
00037
00038 protected String getString(int action, int param)
00039 {
00040 String s = Integer.toString(action) + "_" + Integer.toString(param);
00041 return s;
00042 }
00043
00044 protected void setThisString(String s)
00045 {
00046 int p = s.lastIndexOf('_');
00047 this.action = Integer.parseInt(s.substring(0,p));
00048 this.param = Integer.parseInt(s.substring(p+1));
00049 }
00050
00051 public void display(boolean hidden)
00052 {
00053
00054 }
00055
00056 public void display(String name, int action)
00057 {
00058 display(name, action, 0, "");
00059 }
00060
00061 public void display(String name, int action, int param)
00062 {
00063 display(name, action, param, "");
00064 }
00065
00066 public void display(String name, int action, int param, String attribs)
00067 {
00068 String n = this.n(getString(action, param));
00069 p("<input type=submit name=\"" + n + "\" value=\"" + name
00070 + "\"" + attribs + ">");
00071 }
00072
00073 public String gethref(int action, int param)
00074 {
00075 return "javascript:ActionButton_sgo(" + action + ", " + param + ", '"
00076 + form.name + "', '" + prefix + "');";
00077 }
00078
00079 public void dumpScript()
00080 {
00081 p(
00082 ""
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 );
00103 }
00104 };