com.mycompany.jsf.servlets
Class ShowViewStateServlet

java.lang.Object
  extended byjavax.servlet.GenericServlet
      extended byjavax.servlet.http.HttpServlet
          extended bycom.mycompany.jsf.servlets.ShowViewStateServlet
All Implemented Interfaces:
java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class ShowViewStateServlet
extends javax.servlet.http.HttpServlet

This class is a servlet that produces a response showing the state captured by the CaptureStatePhaseListener, as a tree with links for opening and closing nodes.

Version:
1.0
Author:
Hans Bergsten, Gefion Software
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.servlet.http.HttpServlet
 
Fields inherited from class javax.servlet.GenericServlet
 
Constructor Summary
ShowViewStateServlet()
           
 
Method Summary
 void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
          If invoked without a "viewId" parameter, renders a response with links back to itself for all views available in the session scope variable "com.mycompany.debug".
private  java.lang.String indent(int level)
          Returns a blank String of the appropriate length for the indention level.
private  void renderDocument(TreeNode root, java.io.PrintWriter out, java.lang.String viewId, java.lang.String uri)
          Renders the "html", "head" and "body" elements and calls the renderTreeNode() method to render the tree.
private  void renderLinks(java.util.Map debugMap, java.io.PrintWriter out, java.lang.String uri)
          Renders a response with links for all views in the Map.
private  void renderTreeNode(TreeNode node, java.io.PrintWriter out, java.lang.String viewId, java.lang.String uri, int level, java.lang.String parentNodeId, int childId)
          Renders the node, as "name=value" if it's a leaf node or as a link for expanding or collapsing the node otherwise.
private  void toggleExpanded(java.lang.String path, TreeNode root)
          Locates the node with the specified path in the tree and flips its "expanded" flag.
 
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
 
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ShowViewStateServlet

public ShowViewStateServlet()
Method Detail

doGet

public void doGet(javax.servlet.http.HttpServletRequest request,
                  javax.servlet.http.HttpServletResponse response)
           throws java.io.IOException
If invoked without a "viewId" parameter, renders a response with links back to itself for all views available in the session scope variable "com.mycompany.debug". Otherwise, toggles the "expanded" flag for the node identified by the "nodeId" parameter (if any) and renders the view state tree by calling renderDocument().

Throws:
java.io.IOException

renderLinks

private void renderLinks(java.util.Map debugMap,
                         java.io.PrintWriter out,
                         java.lang.String uri)
Renders a response with links for all views in the Map.


toggleExpanded

private void toggleExpanded(java.lang.String path,
                            TreeNode root)
Locates the node with the specified path in the tree and flips its "expanded" flag.


renderDocument

private void renderDocument(TreeNode root,
                            java.io.PrintWriter out,
                            java.lang.String viewId,
                            java.lang.String uri)
Renders the "html", "head" and "body" elements and calls the renderTreeNode() method to render the tree.


renderTreeNode

private void renderTreeNode(TreeNode node,
                            java.io.PrintWriter out,
                            java.lang.String viewId,
                            java.lang.String uri,
                            int level,
                            java.lang.String parentNodeId,
                            int childId)
Renders the node, as "name=value" if it's a leaf node or as a link for expanding or collapsing the node otherwise. If the node is expanded, calls itself recursively for all node children, rendering the children within a "blockquote" element.


indent

private java.lang.String indent(int level)
Returns a blank String of the appropriate length for the indention level.