Main Page | Packages | Class Hierarchy | Class List | Directories | File List | Class Members | Related Pages

HTMLWriter.java

Go to the documentation of this file.
00001 package cedar.jetweb.html;
00002 
00003 import java.io.PrintWriter;
00004 import java.io.BufferedWriter;
00005 import java.io.File;
00006 import java.io.FileWriter;
00007 import java.io.IOException;
00008 import java.text.SimpleDateFormat;
00009 import java.text.NumberFormat;
00010 
00011 import java.util.Date;
00012 import java.util.Enumeration;
00013 import java.util.Vector;
00014 import java.util.Iterator;
00015 import java.util.List;
00016 import java.util.Collection;
00017 import java.util.Collections;
00018 import java.util.TreeSet;
00019 
00020 import cedar.jetweb.*;
00021 import cedar.jetweb.model.*;
00022 import cedar.jetweb.model.paper.*;
00023 import cedar.jetweb.model.plots.*;
00024 import cedar.jetweb.model.fit.*;
00025 import cedar.jetweb.job.*;
00026 import cedar.jetweb.batch.SubmitScriptHandler;
00027 
00028 import cedar.jetweb.generator.Generator;
00029 
00038 public class HTMLWriter {
00039 
00040     protected static final int LISTLENGTH = 10;
00041 
00043     protected String servletPath;
00044 
00046     protected BufferedWriter ofile;
00047 
00049     protected static NumberFormat dform; 
00050 
00052     protected SimpleDateFormat dateFormat;
00053 
00055     protected boolean modifiable = false;
00056 
00058     protected boolean hidden = false;
00059 
00061     protected boolean verbose = false;
00062 
00068     protected Integer forms_=0;
00069 
00075     private String formAction_ = "";
00076 
00086     public HTMLWriter(BufferedWriter out, String newServletPath ){
00087 
00088     ofile=out;
00089     initialize(newServletPath);
00090 
00091     }
00092 
00096     public static HTMLWriter makeWriter(PrintWriter out, 
00097                     String newServletPath, Object o) 
00098     throws JetWebException {
00099 
00100     if (o instanceof DataPlot) {
00101         return new HTMLPlotWriter(out,newServletPath);
00102     } else if (o instanceof MCProcessType || o instanceof Collision) {
00103         return new HTMLProcessWriter(out,newServletPath);
00104     } else if (o instanceof Paper) {
00105         return new HTMLPaperWriter(out,newServletPath);
00106     } else if (o instanceof Fit) {
00107         return new HTMLFitWriter(out,newServletPath);
00108     } else if (o instanceof Model) {
00109         return new HTMLModelWriter(out,newServletPath);
00110     } else {
00111         return new HTMLWriter(out,newServletPath);
00112     }
00113 
00114     }
00115 
00116 
00117     private void initialize(String newServletPath){
00118 
00119     servletPath = newServletPath;
00120 
00121     dateFormat = new SimpleDateFormat("dd/MM/yyyy");
00122 
00123     dform = JetWebConfig.getFormat();
00124     
00125     }
00126 
00127 
00137     public HTMLWriter(PrintWriter out, String newServletPath ){
00138 
00139     try{
00140         ofile = new BufferedWriter(out);
00141     } catch (Exception e) {
00142         System.out.println("error");
00143     }
00144     initialize(newServletPath);
00145     
00146     }
00147 
00148 
00159     public HTMLWriter(String filename, String newServletPath ){
00160 
00161     File htmlfile = new File(filename);
00162     if (htmlfile.exists()) {
00163         htmlfile.delete();
00164     }
00165     try {       
00166         htmlfile.getParentFile().mkdirs();
00167         htmlfile.createNewFile(); 
00168         ofile = new BufferedWriter(new FileWriter(htmlfile));       
00169     }    
00170     catch (Exception e) {
00171         System.out.println("Could not open file "+filename);
00172     }
00173     initialize(newServletPath);
00174     }
00178     public void setNumberFormat(NumberFormat form){
00179     dform = form;
00180     }
00184     public void setDateFormat(SimpleDateFormat form){
00185     dateFormat = form;
00186     }
00190     public BufferedWriter getWriter(){
00191     return ofile;
00192     }
00196     public void close(){
00197 
00198     try {
00199         ofile.close();
00200     }    
00201     catch (IOException e) {
00202         System.out.println("Could not open file "+e);
00203     }
00204     System.out.println("Done");
00205     }
00206 
00210     public void setHidden(boolean hide){
00211     hidden = hide;
00212     if (hide) {modifiable = false;}
00213     }
00217     public void setModifiable(boolean mod){
00218     modifiable = mod;
00219     if (mod) {hidden=false;}
00220     }
00224     public void setVerbose(boolean verb){
00225     verbose = verb;
00226     }
00227 
00231     public void startControlForm(){
00232     this.startControlForm(" ");
00233     }
00234 
00240     public void startControlForm(String message){
00241     
00242     try {
00243         writeTopMessage(message);
00244 
00245     } catch ( JetWebException e ) {
00246         System.out.println("problem writing form");
00247         return;
00248     }
00249     }
00250 
00256     public void startForm(){
00257     
00258     try {
00259         openForm("POST", servletPath);
00260 
00261     } catch ( IOException e ) {
00262         System.out.println("problem writing form");
00263         return;
00264     }
00265     }
00266 
00270     public void endForm(){
00271     try {
00272         closeForm();
00273         //ofile.write("</form>");
00274     } catch ( IOException e ) {
00275         System.out.println("problem writing form");
00276         return;
00277     }
00278     }
00279 
00284     public void searchByXML(){
00285     
00286     try{
00287         //  openForm
00288         //("POST", "..//mouse/JWUpload", "enctype='multipart/form-data");
00289         openForm("POST", 
00290              JetWebConfig.uploadServletPath, 
00291              "enctype='multipart/form-data'");
00292 
00293     ofile.write("<div class='jetweb-buttons'>");
00294     ofile.write("<input type='hidden' name='DIRECTORY' value='"+ 
00295             JetWebConfig.jobOutDirName
00296             +"'/>");
00297     ofile.write("<input type='hidden' name='MODELXML'/>");
00298     ofile.write(HTMLUtils.writeInputTag
00299             ("file", 
00300              "XMLFile", 
00301              "Search for models matching a Hepml file", ""));
00302     ofile.write("Search for models matching HepML file ");
00303     ofile.write("<input type='SUBMIT' name='SUBMITXML' value='Go'/>");
00304     ofile.write("</div>");
00305     }catch ( IOException e ) {
00306         System.out.println("problem writing form");
00307         return;
00308     }
00309     }
00310 
00311 
00315     public void makeActionButtons(){
00316     try {
00317         
00318         ofile.write("<div class='actionbuttons'>");
00319         ofile.newLine();
00320         ofile.write(HTMLUtils.writeSubmitButton("GETMODELS",
00321                             "Search for models matching the criteria specified",
00322                             "Get Models"));
00323         ofile.newLine();
00324         ofile.write(HTMLUtils.writeSubmitButton("GETFITS",
00325                             "Search for fits matching the specified criteria",
00326                             "Get Fits"));
00327         ofile.newLine();
00328         ofile.write(HTMLUtils.writeSubmitButton
00329             ("CLEARALL",
00330              "Clear all selections",
00331              "Reset"));
00332         ofile.newLine();
00333         ofile.write(HTMLUtils.writeSubmitButton
00334             ("DEFAULT",
00335              "Set all parameters to their default values",
00336              "Default"));
00337         ofile.newLine();
00338         ofile.write("<br>");
00339         ofile.write("</div>");
00340 
00341     } catch ( IOException e ) {
00342         System.out.println("problem writing form");
00343         return;
00344     }
00345     }
00346 
00347 
00351     public void makeSubmitButtons(){
00352     try {
00353         
00354         ofile.write("<div class='actionbuttons'>");
00355         ofile.newLine();
00356 
00357         ofile.write("Minimum PT (GeV) for generated events ");
00358         ofile.write
00359         ("<input type='text' size='3'" + 
00360          " name='GENPTMIN' title='Enter the minimum PT to generate'>");
00361         
00362         ofile.write(HTMLUtils.writeSubmitButton("SUBMIT1",
00363                             "Submit the simulation job request",
00364                             "Submit the request"));
00365 
00366         ofile.newLine();
00367         ofile.write(HTMLUtils.writeSubmitButton("CLEARALL",
00368                             "Clear all selections",
00369                             "Reset"));
00370 
00371         ofile.newLine();
00372         ofile.write
00373         ("<input type='hidden' name='SUBMITTINGJOB' value='TRUE'>");
00374     
00375         ofile.write("</div>");
00376 
00377     } catch ( IOException e ) {
00378         System.out.println("problem writing form");
00379         return;
00380     }
00381     }
00382 
00390     public void makeRequestForm(ResultSearchPattern pattern) throws JetWebException {
00391 
00392     try {   
00393         boolean oldModifiable = modifiable;
00394         modifiable = true;
00395         makeCommonForm(pattern);
00396         modifiable = oldModifiable;
00397         
00398         Generator gen = pattern.getGenerator();
00399         if (gen!=null) {
00400         ofile.write("<p>Model Description: ");
00401         ofile.write
00402             (HTMLUtils.writeInputBox
00403              ("DESCRIPTION", 
00404               "Write a description of the model", 
00405               pattern.getDescription()));
00406         ofile.write("</p>");
00407         
00408         ofile.write("<h4>Change the generator parameters</h4>");
00409         HTMLGeneratorWriter genOp 
00410             = new HTMLGeneratorWriter(ofile,servletPath);
00411         genOp.setModifiable(true);
00412         genOp.setVerbose(true);
00413         genOp.display(gen);
00414         ofile.newLine();
00415 
00416         } else {
00417         
00418         for (String gname: Generator.allNames()){
00419             ofile.write(HTMLUtils.writeSubmitButton("SETPARS",
00420                                 "Opens a form allowing "
00421                                 +gname+" parameters to be changed",
00422                                 gname));
00423         }
00424         }
00425     } catch ( IOException e ) {
00426         System.out.println("problem writing form");
00427         return;
00428     }       
00429     }
00430 
00431 
00435     public void makeControlForm(){
00436     
00437     try {
00438 
00439         ofile.write("<div class='jetweb-buttons'>");
00440 
00441         ofile.newLine();    
00442         openForm("POST", servletPath);
00443         //ofile.write("<form method='post' action='"+servletPath+"'>");
00444 
00445         ofile.write("<table><tbody>");
00446         ofile.newLine();        
00447         /*
00448         ofile.write("<tr>");
00449         ofile.write("<td valign='top'><p>Rewrite webpages</p></td>");
00450         ofile.write("<td align='middle' valign='middle'>");     
00451         ofile.write("<input type='submit' name='REDO' value='GO'></td></tr>");
00452         ofile.newLine();
00453         */
00454         ofile.write("<tr>");
00455         ofile.write("<td><p>Process any new data in the input directory</p></td>");
00456         ofile.write("<td align='right'>");
00457         ofile.write("<INPUT TYPE=SUBMIT NAME='PROCESSNEW' VALUE=\"GO\"></TD></TR>");
00458         ofile.newLine();
00459 
00460         ofile.write("<tr>");
00461         ofile.write("<td><p>Manage MCProcessTypes</p></td>");
00462         ofile.write("<td align='right'>");
00463         ofile.write("<input type='submit' name='PROCESSTYPE' value='GO'></td></tr>");
00464         ofile.newLine();
00465 
00466         /*
00467         ofile.write("<tr>");
00468         ofile.write("<td><p>Search or submit new job</P></TD>");
00469         ofile.write("<td align='right'>");
00470         ofile.write("<input type='submit' name='SEARCH' value='GO'></td></tr>");
00471         ofile.newLine();
00472         */
00473         ofile.write("<tr>");
00474         ofile.write("<td><p>List submitted jobs which have not yet returned.</p></td>");
00475         ofile.write("<td align='right'>");
00476         ofile.write("<input type='submit' name='PENDING' VALUE='GO'></td></tr>");
00477 
00478 
00479         ofile.write("<tr>");
00480         ofile.write("<td><p>Edit fit with ID</P></TD><TD align='left'>");
00481         ofile.write("<input type='text' name='FITID' width='5'></p></td>");
00482             ofile.write("<td align='right'>");
00483         ofile.write("<input type='submit' name='FITFIX' value='GO'></td></tr>");
00484 
00485             ofile.write("<tr>");
00486         ofile.write("<td><p>Modify a paper (give the ID)</p></td><td align='left'>");
00487         ofile.write("<input type='text' name='PAPERID' width='5'></p></td>");
00488             ofile.write("<td align='right'>");
00489         ofile.write("<input type='submit' name='PAPERMOD' value='GO'></td></tr>");
00490 
00491         ofile.write("<tr>");
00492         ofile.write("<td><p>Add a new paper</p></td>");
00493         ofile.write("<td align='right'>");
00494         ofile.write("<input type='submit' name='PAPERADD' value='GO'></td></tr>");
00495         ofile.write("<tr>");
00496 
00497         /*
00498         ofile.write("<td><p>Recalculate generated integrated luminosity</p></td>");
00499         ofile.write("<td align='right'>");
00500         ofile.write("<input type='submit' name='FIXLUMI' value='GO'></td></tr>");
00501         */
00502 
00503         ofile.write("</tbody></table>");
00504         closeForm();
00505         //ofile.write("</form>");
00506         openForm("POST", JetWebConfig.uploadServletPath, 
00507              "enctype='multipart/form-data'");
00508         //ofile.write
00509         //("<form enctype='multipart/form-data' method='post' action='"
00510         // + JetWebConfig.uploadServletPath + "'>");
00511 
00512         ofile.write("<table><tbody>");
00513         ofile.write("<tr>");
00514         ofile.write
00515         ("<td><p>Add a new generator default from an XML file</p></td>");
00516         ofile.write("<td align='right'>");
00517         ofile.write("<input type='hidden' name='DEFAULTSUPLOAD'>");
00518         ofile.write("<input type='hidden' name='DIRECTORY' value=" + 
00519             JetWebConfig.jobOutDirName+ "/>");
00520         ofile.write
00521         ("<input type='file' name='XMLDEFAULTS'></p></td>");
00522 
00523         ofile.write("<td align='right'>");
00524         ofile.write("<input type='submit' name='DEFAULTSMOD' value='GO'></TD></TR>");
00525         ofile.write("</tbody></table>");
00526 
00527         closeForm();
00528         //ofile.write("</form>");
00529         ofile.write("</div>");
00530 
00531         ofile.write("<div>");
00532         openForm("POST", servletPath);
00533         //ofile.write("<form method='post' action='"+servletPath+"'>");
00534         ofile.newLine();
00535         ofile.write("<table border='3'>");
00536 
00537         ofile.write("<tr><td colspan='6'>");
00538         ofile.write("<h3>New Configuration</h3>");
00539 
00540         ofile.newLine();
00541         ofile.write("<tr><td align='right'><p>Plot generation on:<td align=\"left\">");
00542         ofile.write("<input type='checkbox' name='PLOTS'");
00543         if (JetWebConfig.writePlots) { ofile.write(" checked ");}
00544         ofile.write(">");
00545         ofile.write("<tr>");
00546         ofile.write("<tr><td align='right'><p>Name of run subdirectory for jobs:<td align='left'>");
00547         String dname = JetWebConfig.jobOutDirName;
00548         ofile.write("<input type='text' name='RUNSUBDIR' width='24' value='"
00549             +dname+"'>");
00550 
00551         ofile.newLine();
00552         ofile.write("<tr><td><p>Batch facility:</p>");
00553 
00554         ofile.newLine();
00555         ofile.write("<td><table>"); // List of batch facilities. This is a bit clumsy!
00556         ofile.newLine();
00557         Iterator<Integer> iBatchNum = SubmitScriptHandler.batchNumbers.iterator();
00558         Iterator<String> iBatchName = SubmitScriptHandler.batchNames.iterator();
00559         while (iBatchNum.hasNext()&&iBatchName.hasNext()) {  // Should have same number of entries
00560         Integer batchNum = iBatchNum.next();
00561         String batchName = iBatchName.next();
00562         ofile.write("<TR><TD>"+batchName+"<TD><INPUT TYPE=RADIO NAME=BATCHFAC VALUE=\""
00563                 +batchNum+"\"");
00564         if (SubmitScriptHandler.BATCHFACILITY==batchNum.intValue()){
00565             ofile.write(" checked ");}
00566         ofile.write(">");
00567         ofile.newLine();
00568         }
00569         ofile.write("</table>");
00570 
00571         ofile.newLine();
00572         ofile.write("<tr>");
00573 
00574         ofile.write("<td align='right' colspan='6'>");
00575         ofile.write("<input type='submit' name='CONFIG' value='Update config'>");
00576 
00577         ofile.write("</table>");
00578         closeForm();
00579         //ofile.write("</form>");
00580         ofile.write("</div>");
00581 
00582         ofile.newLine();
00583     } catch ( IOException e ) {
00584         System.out.println("problem writing form");
00585         return;
00586     }
00587     }
00588 
00592     public void writeOkCancel(){
00593     try {
00594         ofile.newLine();
00595         ofile.write("<TR><TD COLSPAN=3><INPUT TYPE=SUBMIT NAME=ADDTOTHESE VALUE=\"OK\">");
00596         ofile.newLine();
00597         ofile.write("<INPUT TYPE=SUBMIT NAME=CANCEL VALUE=\"CANCEL\">");
00598     } catch ( IOException e ) {
00599         System.out.println("problem writing form");
00600         return;
00601     }
00602     }
00603 
00604 
00610     public void writeDirChoiceForm(String suggestion){
00611 
00612     try {
00613         File dir = new File(suggestion);
00614         ofile.write("<tr><td colspan=4><hr noshade size=3>");
00615         if (dir.exists()){
00616         File[] list = dir.listFiles();
00617 
00618         ofile.write("<tr><td><P>Choosing one of these overrides the input box</P>");
00619         for (int i=0; i<list.length ; i++){
00620             if (list[i].isDirectory()){
00621             ofile.write("<TR><TD>");
00622             ofile.write(list[i]+" <INPUT TYPE=RADIO NAME=RUNDIR1 VALUE=\""+list[i].getPath()+"\">");
00623             ofile.newLine();
00624             }
00625         }
00626         }
00627         ofile.write("<INPUT TYPE=TEXT SIZE=40 NAME=RUNDIR VALUE="+suggestion+">");
00628 
00629     } catch ( IOException e ) {
00630         System.out.println("problem writing form");
00631         return;
00632     }
00633 
00634     }
00635 
00639     public void listPendingJobs(){
00640     
00641     try {
00642         Enumeration pending = JobUtils.selectPendingJobs();
00643 
00644         closeForm();
00645 
00646         //ofile.write("</FORM>");
00647 
00648         int count = 0;
00649         while (pending.hasMoreElements()){
00650         
00651         PendingJob pj = (PendingJob)pending.nextElement();
00652 
00653         count++;
00654         ofile.write("<TR><TD COLSPAN=2>");
00655         ofile.newLine();
00656         ofile.write("<P><B>"+count+": "+pj.getName()+"</B> :");
00657         ofile.write(" Requested at "+pj.getDate()+". Run script is "
00658                 +pj.getScriptName()+"</P>");
00659         ofile.newLine();
00660         }
00661     } catch (JetWebException e){
00662         HTMLErrorWriter.write(ofile,e);
00663     } catch (Exception e) {
00664         System.out.println("error:"+e.getMessage());
00665     }
00666     }
00667 
00674     public void listHiddenPars(ResultSearchPattern pattern){
00675 
00676     try {
00677         ofile.write("<input type='HIDDEN' name='GENERATOR' value='"+pattern.getGenerator().getName()+"-"+pattern.getGenerator().getVersion()+"'>");
00678         ofile.newLine();
00679         ofile.write("<input type='HIDDEN' name='PHOTONPDF' value='"+pattern.getPhotonPDF()+"'>");
00680         ofile.newLine();
00681         ofile.write("<input type='HIDDEN' name='PROTONPDF' value='"+pattern.getProtonPDF()+"'>");
00682 
00683     } catch ( IOException e ) {
00684         System.out.println("problem writing form");
00685         e.printStackTrace();
00686         return;
00687     } catch (JetWebException jwe){
00688         System.out.println("problem writing form");
00689         jwe.printStackTrace();
00690         return;
00691     }
00692     }
00693 
00694 
00698     public void forwardTo(String htmlPath){
00699 
00700     try {
00701         ofile.write("<head><meta http-equiv=\"refresh\" content=\"0;URL="+
00702             htmlPath+"\"></head>");
00703         ofile.newLine();
00704         close();
00705     } catch ( IOException e ) {
00706         System.out.println("problem writing form");
00707         return;
00708     }
00709     }
00710 
00711 
00719     public void writeInputId(String text, String name, String hover, Integer id) 
00720     throws JetWebException {
00721 
00722     try {
00723 
00724         ofile.write("<div class='idselector'>");
00725         openForm("POST", servletPath);
00726         //ofile.write("<form method='post' action='"+servletPath+"'>");
00727         ofile.write(HTMLUtils.writeSubmitButton(name+"GET",hover,text));
00728         ofile.write(HTMLUtils.writeInputBox(name,"Enter the ID",id));
00729         closeForm();
00730         //ofile.write("</form>");
00731         ofile.write("</div>");
00732 
00733         
00734     } catch (IOException ioe) {
00735         ioe.printStackTrace(System.out);
00736         throw new JetWebException(ioe);
00737     }
00738 
00739 
00740     }
00741 
00742 
00743     public void makeCommonForm(ResultSearchPattern pattern) throws JetWebException {
00744 
00745     try { 
00746 
00747         ofile.write("<table cellpadding=\"4\" rules=\"cols\">");
00748         ofile.write("<tr><td colspan=\"8\"> <p><b>Common parameters</b></p>");
00749         ofile.write("<tr align=\"top\">");
00750         ofile.newLine();
00751         ofile.write("<td align=\"top\"><table align=\"top\"><tr align=\"top\"><td colspan=\"2\"><P>Generator</P>");
00752         ofile.newLine();
00753         boolean none = true;
00754         Generator gen = pattern.getGenerator();
00755         
00756         for (String name : Generator.allNames() ) {
00757         ofile.write("<tr><td align='right'>");
00758         ofile.write("<b>"+name+" </b>");
00759 
00760         TreeSet<String> allVersions = 
00761             new TreeSet(Generator.allVersions(name));
00762 
00763         for (String version : allVersions ) {
00764             ofile.write("<td>" + version + 
00765                 "<input type='checkbox' ");
00766             ofile.write("name='GENERATOR' value='"+name+"-"+version+"'");
00767             if (gen!=null && 
00768             gen.getName().equals(name) && 
00769             gen.getVersion().equals(version)){
00770             ofile.write(" checked ");
00771             }
00772             ofile.write("/></td>");
00773             ofile.newLine();
00774         }
00775         }
00776         ofile.write("</table>");
00777         
00778         ofile.newLine();
00779         ofile.write("<td align='top'><table><tr><td colspan='2'><P>Photon PDF</P>");
00780         ofile.newLine();
00781         none = true;
00782 
00783         Vector<PDF> knownPDFs = PDF.getKnownPDFs();
00784 
00785         Vector<PDF> knownProtonPDFs = new Vector<PDF>();
00786         Vector<PDF> knownPhotonPDFs = new Vector<PDF>();
00787 
00788         for(PDF pdf: knownPDFs){
00789         if(pdf.isPhoton()) knownPhotonPDFs.add(pdf);
00790         if(pdf.isProton()) knownProtonPDFs.add(pdf);
00791         }
00792 
00793         for(PDF pdf: knownPhotonPDFs){
00794         ofile.write("<tr><td align='right'>");
00795         ofile.write(pdf.getName()+"</td>");
00796                 ofile.write("<td><input type='checkbox' ");
00797         if(pattern.getPhotonPDFList().contains(pdf)&&none){
00798             ofile.write(" checked ");
00799             none = false;
00800         }
00801         ofile.write("name='PHOTONPDF' value='"+pdf.getName()+"'>");
00802         ofile.write("</td></tr>");
00803         ofile.newLine();        
00804         }
00805         ofile.write("</tr>");
00806         ofile.write("</table>");
00807         ofile.write
00808         ("<td align='top'> <table><tr><td colspan='2'><p>Proton PDF</p>");
00809         ofile.newLine();
00810         none = true;
00811 
00812         for(PDF pdf: knownProtonPDFs){
00813         ofile.write("<tr><td align='RIGHT'>");
00814         ofile.write(pdf.getName() + "</td>");
00815                 ofile.write("<td><input type='checkbox' ");
00816         if(pattern.getProtonPDFList().contains(pdf)&&none){
00817             ofile.write(" checked ");
00818             none = false;
00819         }
00820         ofile.write("name='PROTONPDF' value='"+pdf.getName()+"'>");
00821         ofile.write("</td></tr>");
00822         ofile.newLine();
00823         }
00824 
00825         ofile.write("</table>");
00826         
00827         ofile.write("<tr><td colspan='8'><hr noshade size='3'>");
00828         
00829         ofile.write("</table>");
00830     
00831     } catch (IOException ioe) {
00832         ioe.printStackTrace(System.out);
00833         throw new JetWebException(ioe);
00834     }
00835     }
00836 
00837 
00843     public synchronized void displayList(List<?> list) 
00844     throws JetWebException {
00845 
00846     //needs to delete them too
00847     Iterator<? extends Object> iterator = list.iterator();
00848     int count=0;
00849     Vector<Object> deleteList = new Vector<Object>();
00850     while (iterator.hasNext() && count<LISTLENGTH){
00851         Object next = iterator.next(); 
00852         display(next);
00853         deleteList.add(next);
00854         count++;
00855 
00856     }
00857 
00858     //now remove the fits that have been listed
00859     Enumeration<? extends Object> del = deleteList.elements();
00860     while (del.hasMoreElements()){
00861         list.remove(del.nextElement());
00862     }
00863 
00864     }
00865 
00869     public void write(String str) throws JetWebException {
00870         
00871     try {
00872         ofile.write(str);
00873         
00874     } catch (IOException ioe) {
00875         ioe.printStackTrace(System.out);
00876         throw new JetWebException(ioe);
00877     }
00878 
00879 
00880     }
00881 
00882 
00887     public void endListPage(String resultKey){
00888         try {
00889         openForm();
00890         //ofile.write("<form>");
00891         ofile.write("<input type='SUBMIT' name='MORERESULTS' value='Next Results'>");
00892         ofile.write("<input type='HIDDEN' name='RESULTKEY' value='"+resultKey+"'>");
00893         ofile.write("<input type='HIDDEN' name='VERBOSE' value='"+verbose+"'>");
00894         ofile.write("<input type='HIDDEN' name='MODIFIABLE' value='"+modifiable+"'>");
00895         closeForm();
00896         //ofile.write("</form>");
00897     } catch ( IOException e ) {
00898         System.out.println("problem end of list page");
00899         return;
00900     }
00901     }
00902 
00903     public void display(Object object) throws JetWebException {
00904     try {
00905         ofile.write(this+" display not implemented for "+object+"\n");
00906         ofile.newLine();
00907     } catch ( IOException e ) {
00908         System.out.println("problem end of list page");
00909         return;
00910     }
00911     }
00912 
00913 
00917     public void writeTopMessage(String message) throws JetWebException {
00918     try {
00919         ofile.write("<div class=\"news\">"+message+"</div>");
00920     } catch (IOException ioe){
00921         throw new JetWebException(ioe);
00922     }
00923 
00924     }
00925 
00929     public void writeTitle(String title) throws JetWebException {
00930     try {
00931         ofile.write("<h2>"+title+"</h2>");
00932     } catch (IOException ioe){
00933         throw new JetWebException(ioe);
00934     }
00935     }
00936 
00947     protected void openForm(String method, String action)
00948     throws IOException  {
00949 
00950     if(!action.equals(formAction_) &&
00951        !forms_.equals(0)){
00952         forms_ = 1;
00953         ofile.write("</form>");
00954     }else{
00955         ++forms_;
00956     }
00957 
00958     if(forms_==1){
00959         ofile.write("<form method='" + 
00960             method + 
00961             "' action='" + 
00962             action + "' >");
00963         formAction_ = action;
00964     }
00965 
00966     return;
00967     }
00968 
00979     protected void openForm(String method, String action, String extra)
00980     throws IOException  {
00981 
00982     if(!action.equals(formAction_) &&
00983        !forms_.equals(0)){
00984 
00985         forms_ = 1;
00986         ofile.write("</form>");
00987     }else{
00988         ++forms_;
00989     }
00990 
00991     if(forms_==1){
00992         ofile.write("<form method='" + 
00993             method + 
00994             "' action='" + 
00995             action + "' " + extra + ">");
00996         formAction_ = action;
00997     }
00998 
00999     return;
01000     }
01001 
01006     protected void openForm()
01007     throws IOException {
01008     if(!formAction_.equals("") && 
01009        !forms_.equals(0)){
01010         forms_=1;
01011         ofile.write("</form>");
01012     }else{
01013         ++forms_;
01014     }
01015 
01016     if(forms_==1){
01017         ofile.write("<form>");
01018         formAction_ = "";
01019     }
01020     
01021     return;
01022     }
01023 
01029     protected void closeForm()
01030     throws IOException {
01031     if(forms_<=0) return;
01032     --forms_;
01033     if(forms_==0){
01034         ofile.write("</form>");
01035         formAction_ = "";
01036     }
01037 
01038     return;
01039     }
01040 }
01041 
01042 
01043 
01044 

Generated Wed Jan 17 09:14:27 GMT 2007