Inheritance diagram for edu.virtualschool.jwaa.GenericPage:


Definition at line 25 of file GenericPage.java.
Public Member Functions | |
| void | init (MetaPage meta, GenericServlet servlet, HttpServletRequest req, HttpServletResponse rsp) throws IOException, ServletException |
| abstract void | run () throws Fault |
| void | send (Object html) throws IOFault |
| final AccountAbstraction | getAccount () |
| final void | setAccount (AccountAbstraction account) |
| RoleAbstraction | getRequiredRole () |
| void | redirect (MetaPage meta) throws Fault |
| void | forward (MetaPage meta) throws Fault |
| MetaPage | getParent () |
| Iterator | children () |
| String | getTitle () |
| String | toString () |
| final Validatable | getField (String parameterName, Validatable defaultValue) throws Fault |
| final Validatable[] | getFields (String parameterName, Validatable defaultValue) throws Fault |
| final HashMap | getParameterMap () |
| final String | getParameter (Object key, Object defaultValue) |
| final Object | getAttribute (String attributeName) throws IOFault |
| final String | getContextName () |
| final Validatable | getCookie (String cookieName, Validatable defaultValue) throws Fault |
| final HttpServletRequest | getHttpRequest () |
| final HttpServletResponse | getHttpResponse () |
| final GenericServlet | getServlet () |
| final String | getServletName () |
| final HttpSession | getSession () |
| final PrintWriter | getWriter () throws IOFault |
| final synchronized void | setAttribute (String key, Object value) |
| final void | setCookie (String cookieName, String cookieValue, int msec) |
| final String | getArguments () |
| String | emitLink (MetaPage meta) |
| String | emitLink (MetaPage meta, Object anchor) |
| String | emitLink (MetaPage meta, Object anchor, Object title) |
| String | emitLink (MetaPage meta, Object anchor, Object[] args) |
| String | link (MetaPage meta, Object anchor, Object title, Object[] args) |
| String | emitForm () |
| String | emitForm (MetaPage meta) |
| String | emitForm (MetaPage meta, Object[] args) |
Public Attributes | |
| MetaPage | meta |
| GenericServlet | servlet |
| The servlet that is handling this httpRequest. | |
| HttpServletRequest | httpRequest |
| The servlet request that this instance is responding to. | |
| HttpServletResponse | httpResponse |
| The servlet response that this instance is sending to. | |
Static Package Attributes | |
| final Logger | logger |
| final String | SESSION_ATTRIBUTE_NAME = "_PERSON_" |
|
|
Return the children of this node in the page hierarchy
Definition at line 182 of file GenericPage.java. References edu.virtualschool.jwaa.TreeNode.childrenIterator().
00183 {
00184 return meta.childrenIterator();
00185 }
|
|
||||||||||||
|
Composes a <form> command for accessing the specified pageClass instance with the specified parameter list. The closing </form> must be sent manually.
Definition at line 484 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.emitForm().
00485 {
00486 return meta.emitForm(this, args);
00487 }
|
|
|
Composes a <form> command for accessing the specified pageClass instance
Definition at line 471 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.emitForm().
00472 {
00473 return meta.emitForm(this, null);
00474 }
|
|
|
Composes a <form> command for accessing the receiver page.
Definition at line 459 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.emitForm().
00460 {
00461 return meta.emitForm(this, null);
00462 }
|
|
||||||||||||||||
|
Returns an <a href="..."> command as a string
Definition at line 447 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.emitLink().
00448 {
00449 return meta.emitLink(this, anchor, null, args);
00450 }
|
|
||||||||||||||||
|
Returns an <a href="..."> command as a string
Definition at line 435 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.emitLink().
00436 {
00437 return meta.emitLink(this, anchor, title, null);
00438 }
|
|
||||||||||||
|
Returns an <a href="..."> command as a string
Definition at line 423 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.emitLink().
00424 {
00425 return meta.emitLink(this, anchor, null, null);
00426 }
|
|
|
Returns an <a href="..."> command as a string
Definition at line 412 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.emitLink(). Referenced by edu.virtualschool.jwaa.GenericLookAndFeel.computeNavigationBar().
00413 {
00414 return meta.emitLink(this, null, null, null);
00415 }
|
|
|
Forward the httpRequest to the designated page and throw IgnorableFault so that control does not return to the caller.
Definition at line 165 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.forward().
00166 {
00167 logger.debug("forward: " + meta);
00168 meta.forward(this);
00169 }
|
|
|
Return the person of the currently logged in user or null if the servlet's default person if this user has not logged in.
Definition at line 100 of file GenericPage.java. References edu.virtualschool.jwaa.GenericServlet.getNullAccount(), edu.virtualschool.jwaa.GenericPage.getSession(), edu.virtualschool.jwaa.GenericPage.servlet, and edu.virtualschool.jwaa.GenericPage.SESSION_ATTRIBUTE_NAME. Referenced by edu.virtualschool.jwaa.GenericLookAndFeel.computeNavigationBar(), and edu.virtualschool.jwaa.xml.Controller.run().
00101 {
00102 HttpSession session = getSession();
00103 if (session == null)
00104 return servlet.getNullAccount();
00105 AccountAbstraction person = (AccountAbstraction) session.getAttribute(SESSION_ATTRIBUTE_NAME);
00106 if (person == null)
00107 return servlet.getNullAccount();
00108 else
00109 return person;
00110 }
|
|
|
Returns httpRequest arguments as a &-separate string
Definition at line 395 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest.
00396 {
00397 StringBuffer buf = new StringBuffer();
00398 for (Enumeration e = httpRequest.getParameterNames(); e.hasMoreElements();)
00399 {
00400 String key = (String) e.nextElement();
00401 String[] values = httpRequest.getParameterValues(key);
00402 String value = StringUtil.join('&', values);
00403 buf.append(key + "=" + value + (e.hasMoreElements() ? "&" : ""));
00404 }
00405 return buf.toString();
00406 }
|
|
|
Get a session attribute.value by calling getSession().getAttribute(attributeName)
Definition at line 270 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.getSession().
00271 {
00272 return getSession().getAttribute(attributeName);
00273 }
|
|
|
Return the httpRequest's getContextPath() string.
Definition at line 279 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest.
00280 {
00281 return httpRequest.getContextPath();
00282 }
|
|
||||||||||||
|
Get cookie value by calling httpRequest.getCookies().
Definition at line 291 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest.
00294 {
00295 Cookie[] cookies = httpRequest.getCookies();
00296 for (int i = 0; i < cookies.length; i++)
00297 {
00298 if (cookies[i].getName().equals(cookieName))
00299 return defaultValue.cloneWithValue(cookies[i].getValue());
00300 }
00301 return defaultValue;
00302 }
|
|
||||||||||||
|
Get a single field of defaultValue's class initialized to the parameter's value if present else defaultValue's value
Definition at line 202 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.getParameter().
00205 {
00206 String value = getParameter(parameterName, defaultValue.toString());
00207 return defaultValue.cloneWithValue(value);
00208 }
|
|
||||||||||||
|
Return an array of fields for the specified parameter name or an empty Validatable[0] if the field has no values.
Definition at line 217 of file GenericPage.java. References edu.virtualschool.jwaa.field.Validatable.cloneWithValue(), and edu.virtualschool.jwaa.GenericPage.httpRequest.
00220 {
00221 String[] values = httpRequest.getParameterValues(parameterName);
00222 if (values == null)
00223 values = new String[0]; // paranoia
00224 Validatable[] array =
00225 (Validatable[]) java.lang.reflect.Array.newInstance(
00226 defaultValue.getClass(),
00227 values.length);
00228 for (int i = 0; i < values.length; i++)
00229 array[i] = defaultValue.cloneWithValue(values[i]);
00230 return array;
00231 }
|
|
|
Get the httpRequest object
Definition at line 308 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest.
00309 {
00310 return httpRequest;
00311 }
|
|
|
Get the httpResponse object
Definition at line 317 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpResponse.
00318 {
00319 return httpResponse;
00320 }
|
|
||||||||||||
|
Get a httpRequest parameter. If null, return the defaultValue as a string.
Definition at line 255 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest. Referenced by edu.virtualschool.jwaa.GenericPage.getField().
00256 {
00257 String value = httpRequest.getParameter(key.toString());
00258 if (value == null)
00259 return defaultValue.toString();
00260 else
00261 return value;
00262 }
|
|
|
Composes a parameter map as a Hashtable whose keys are names and values are Object[]. Definition at line 236 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest.
00237 {
00238 HashMap map = new HashMap();
00239 for (Enumeration e = httpRequest.getParameterNames(); e.hasMoreElements();)
00240 {
00241 String key = (String) e.nextElement();
00242 String value = httpRequest.getParameter(key);
00243 map.put(key, value);
00244 }
00245 return map;
00246 }
|
|
|
Return the parent of this node in the page hierarchy
Definition at line 174 of file GenericPage.java. References edu.virtualschool.jwaa.TreeNode.getParentNode().
00175 {
00176 return (MetaPage) meta.getParentNode();
00177 }
|
|
|
Return the role that an person must hold to be allowed to access this page. Navigation bars will only present links to this page, and Servlet will only dispatch requests to this page, if the person has the required role.
Definition at line 132 of file GenericPage.java. References edu.virtualschool.jwaa.MetaPage.requiredRole.
00133 {
00134 return meta.requiredRole;
00135 }
|
|
|
Get the Servlet
Definition at line 325 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.servlet.
00326 {
00327 return servlet;
00328 }
|
|
|
Return the servlet name
Definition at line 334 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest.
00335 {
00336 return httpRequest.getServletPath();
00337 }
|
|
|
Get the session object by calling httpRequest.getSession(true)
Definition at line 343 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpRequest. Referenced by edu.virtualschool.jwaa.GenericPage.getAccount(), edu.virtualschool.jwaa.GenericPage.getAttribute(), edu.virtualschool.jwaa.GenericPage.setAccount(), and edu.virtualschool.jwaa.GenericPage.setAttribute().
00344 {
00345 return httpRequest.getSession(true);
00346 }
|
|
|
Get a PrintWriter suitable for communicating with the client browser by calling httpResponse.getWRiter().
Definition at line 354 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpResponse.
00355 {
00356 try
00357 {
00358 return httpResponse.getWriter();
00359 }
00360 catch (IOException e)
00361 {
00362 throw new IOFault(e);
00363 }
00364 }
|
|
||||||||||||||||||||
|
Override to initialize page instance variables
Definition at line 53 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.servlet. Referenced by edu.virtualschool.jwaa.GenericServlet.doRequest().
00059 {
00060 this.meta = meta;
00061 this.servlet = servlet;
00062 this.httpRequest = req;
00063 this.httpResponse = rsp;
00064 rsp.setContentType("text/html");
00065 }
|
|
|
Redirect the httpRequest to the designated page and throw a IgnorableFault to ensure that control will not return to the caller. Redirects work by sending a redirect httpRequest to the browser, unlike forward, which works entirely within the server. IgnorableFault is caught and discarded here.
Definition at line 145 of file GenericPage.java. References edu.virtualschool.jwaa.GenericURI.getText(), edu.virtualschool.jwaa.GenericPage.httpResponse, and edu.virtualschool.jwaa.MetaPage.link.
00146 {
00147 try
00148 {
00149 String path = meta.link.getText();
00150 httpResponse.sendRedirect(httpResponse.encodeRedirectURL(path));
00151 throw new IgnorableFault();
00152 }
00153 catch (IOException e)
00154 {
00155 throw new IOFault("Fault redirecting to page " + meta);
00156 }
00157 }
|
|
|
Servlet calls this to run the page. Every subclass overrides this to send html to the browser, to process form parameters, and so forth.
Implemented in edu.virtualschool.jwaa.xml.Controller. Referenced by edu.virtualschool.jwaa.GenericServlet.doRequest(). |
|
|
Send html text to the client as html text
Definition at line 81 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpResponse. Referenced by edu.virtualschool.jwaa.xml.Controller.run().
00082 {
00083 try
00084 {
00085 PrintWriter writer = httpResponse.getWriter();
00086 writer.println(html.toString());
00087 }
00088 catch (IOException e)
00089 {
00090 throw new IOFault(e);
00091 }
00092 }
|
|
|
Login the provided account by storing it as the session attribute SESSION_ATTRIBUTE_NAME. Definition at line 115 of file GenericPage.java. References edu.virtualschool.jwaa.GenericServlet.getNullAccount(), edu.virtualschool.jwaa.GenericPage.getSession(), edu.virtualschool.jwaa.GenericPage.servlet, and edu.virtualschool.jwaa.GenericPage.SESSION_ATTRIBUTE_NAME.
00116 {
00117 if (account == null)
00118 account = servlet.getNullAccount();
00119 HttpSession session = getSession();
00120 if (session == null)
00121 throw new RuntimeFault("session is null. Should not happen");
00122 session.setAttribute(SESSION_ATTRIBUTE_NAME, account);
00123 }
|
|
||||||||||||
|
Set a session attribute to key/value
Definition at line 371 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.getSession().
00372 {
00373 HttpSession session = getSession();
00374 // if (session == null) Log.fault(this + " ignoring null session", null);
00375 session.setAttribute(key, value);
00376 }
|
|
||||||||||||||||
|
Set a cookie to the designated name/value
Definition at line 384 of file GenericPage.java. References edu.virtualschool.jwaa.GenericPage.httpResponse.
00385 {
00386 Cookie cookie = new Cookie(cookieName, cookieValue);
00387 cookie.setMaxAge(cookieValue == null ? 0 : msec);
00388 httpResponse.addCookie(cookie);
00389 }
|
|
|
Initial value:
Logger.getLogger(GenericPage.class.getName())
Definition at line 35 of file GenericPage.java. |
|
|
The name of the session attribute. This is reserved to hold the person of the currently logged in user. It is managed internally and should need no external attention other than to avoid using this name for other purposes. Definition at line 42 of file GenericPage.java. Referenced by edu.virtualschool.jwaa.GenericPage.getAccount(), and edu.virtualschool.jwaa.GenericPage.setAccount(). |