Package healthwatcher.view.command

Source Code of healthwatcher.view.command.UpdateComplaintList

package healthwatcher.view.command;

import healthwatcher.Constants;
import healthwatcher.model.complaint.Complaint;
import healthwatcher.view.IFacade;

import java.io.PrintWriter;

import lib.exceptions.InvalidSessionException;
import lib.exceptions.ObjectNotFoundException;
import lib.util.HTMLCode;
import lib.util.IteratorDsk;

public class UpdateComplaintList extends Command {

  public UpdateComplaintList(IFacade f) {
      super(f);
    }

  public void execute() throws Exception {
    PrintWriter out = response.getWriter();
   
      try {
          if (! request.isAuthorized()) {
                  throw new InvalidSessionException();
              }
            // Facade calls must come before using out
            IteratorDsk repTP = facade.getComplaintList();
           
            out.println(HTMLCode.open("Queries - Complaint information"));
              out.println("<body><h1>Queries:<br>Querie about complaint</h1>");
              out.println("<p>Choose a complaint: </p>");
              out.println("<form method=\"POST\" action=\""+Constants.SYSTEM_ACTION+"?operation=UpdateComplaintSearch\">");
                

              if (repTP==null||!repTP.hasNext()) {               
                  out.println("<p><center><font color=\"red\"><b> There isn't any complaints.</b></font></center></p>");
              } else {
                out.println("<div align=\"center\"><center><p><select name=\"numQueixa\" size=\"1\">");             
                  Complaint tp;
                  do {
                      tp = (Complaint) repTP.next();
                      out.println("<option value=\""      +
                                  tp.getCodigo() + "\"> " +
                                  tp.getDescricao()      +
                                  " </OPTION>");                   
                  } while (repTP.hasNext());
                  repTP.close();
                 
                  out.println("</select></p></center></div>");
                  out.println("  <div align=\"center\"><center><p><input type=\"submit\" value=\"Search\" name=\"B1\"></p></center></div></form>");
              }
              out.println(HTMLCode.closeAdministrator());           
          } catch (ObjectNotFoundException e) {
              out.println(HTMLCode.errorPageQueries("There isn't any complaints"));
          }catch(InvalidSessionException e){
            out.println(HTMLCode.errorPageAdministrator("<p>Ivalid Session! <br>You must <a href=\""+Constants.SYSTEM_LOGIN+"\">login</a> again!"));
          }catch(Exception e){
            out.println(HTMLCode.errorPageQueries("There isn't any complaints"));
            e.printStackTrace(out);
          }finally {out.close();}
    }
}
TOP

Related Classes of healthwatcher.view.command.UpdateComplaintList

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.