com.github.drinkjava2.jwebbox
Class WebBox

java.lang.Object
  extended by com.github.drinkjava2.jwebbox.WebBox

public class WebBox
extends Object

JWebBox is a small layout tool used in java server pages(JSP) projects, playing the same role like Apache Tiles and SiteMesh, no XML file, no Tags, simple(only 1 java file), can be used to support whole site's layout or only few page components.

Version:
2.1.2
Author:
Yong Zhu(yong9981@gmail.com)

Nested Class Summary
static class WebBox.Show
          This is a custom TagLib for JSP and also can be used in FreeMaker
static class WebBox.WebBoxException
          A runtime exception caused by WebBox
 
Field Summary
static String JWEBBOX_ID
           
 
Constructor Summary
WebBox()
           
WebBox(String page)
          Create a WebBox
 
Method Summary
 void afterExecute()
          For subclasses override this method to do something
 void afterPrepared()
          For subclasses override this method to do something
 void afterShow()
          For subclasses override this method to do something
 void beforeExecute()
          For subclasses override this method to do something
 void beforeShow()
          For subclasses override this method to do something
 void execute()
          For subclasses override this method to do something
static
<T> T
getAttribute(javax.servlet.jsp.PageContext pageContext, String attributeName)
          Get an attribute from current page's WebBox instance
<T> T
getAttribute(String key)
          Get WebBox's attribute
 Map<String,Object> getAttributeMap()
          Get the attribute map of WebBox instance
static WebBox getBox(javax.servlet.jsp.PageContext pageContext)
          Get current pageContext's WebBox instance
 WebBox getFatherWebBox()
          Set the father page's WebBox instance
 String getName()
          get the name of the WebBox instance
<T> T
getObject(String key)
          Search and return an attribute object follow this order: pageContext->request->parameter->session
 Object getPage()
          Get the page
 javax.servlet.jsp.PageContext getPageContext()
          Get current pageContext if have
 Object getPrepareBean()
          Get the prepare bean instance
 String getPrepareBeanMethod()
          Get the prepare bean method name
 String getPrepareStaticMethod()
          Get the Prepare static method name
 String getPrepareURL()
          Get the prepare URL
 String getText()
          Get the Text
static boolean isEmptyStr(String str)
          Check if String null or empty
 void prepareOnly(javax.servlet.jsp.PageContext pageContext)
          Prepare data, only but do not output text and do not show page
 WebBox setAttribute(String key, Object value)
          Set attribute for current WebBox instance
 WebBox setAttributeMap(Map<String,Object> attributeMap)
          Set the attribute map for WebBox instance
 void setFatherWebBox(WebBox fatherWebBox)
          Get the father page's WebBox instance
 WebBox setName(String name)
          Set the name of the WebBox instance
 WebBox setPage(Object page)
          Set a JSP page or URL
 void setPageContext(javax.servlet.jsp.PageContext pageContext)
          Set pageContext to it
 void setPageContextAttribute(String key, Object value)
          Set a pageContext attribute
 WebBox setPrepareBean(Object prepareBean)
          Set a prepare bean which has a prepare method
 WebBox setPrepareBeanMethod(String prepareBeanMethod)
          Set the bean prepare method name
 WebBox setPrepareStaticMethod(String prepareStaticMethod)
          Set a prepare static method
 WebBox setPrepareURL(String prepareURL)
          Set prepare URL, this URL be called after prepare methods but before show page
 void setRequestAttribute(String key, Object value)
          Set a request attribute
 void setSessionAttribute(String key, Object value)
          Set a session attribute
 WebBox setText(String text)
          Set the text String
 WebBox show(javax.servlet.jsp.PageContext pageContext)
          Prepare data and out put text include page if have
static void showAttribute(javax.servlet.jsp.PageContext pageContext, String attributeName)
          Assume the value is String or WebBox instance, show it
 WebBox showPageOnly(javax.servlet.jsp.PageContext pageContext)
          Show page only, do not call prepareStaticMethod and URL
static void showTarget(javax.servlet.jsp.PageContext pageContext, Object target)
          Show an target object, target can be: WebBox instance or String or List of WebBox instance or String
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JWEBBOX_ID

public static final String JWEBBOX_ID
See Also:
Constant Field Values
Constructor Detail

WebBox

public WebBox()

WebBox

public WebBox(String page)
Create a WebBox

Parameters:
page - The JSP or FTL or any URL, for example: "/template/abc.jsp"
Method Detail

isEmptyStr

public static boolean isEmptyStr(String str)
Check if String null or empty


beforeShow

public void beforeShow()
For subclasses override this method to do something


beforeExecute

public void beforeExecute()
For subclasses override this method to do something


execute

public void execute()
For subclasses override this method to do something


afterExecute

public void afterExecute()
For subclasses override this method to do something


afterPrepared

public void afterPrepared()
For subclasses override this method to do something


afterShow

public void afterShow()
For subclasses override this method to do something


show

public WebBox show(javax.servlet.jsp.PageContext pageContext)
Prepare data and out put text include page if have


prepareOnly

public void prepareOnly(javax.servlet.jsp.PageContext pageContext)
Prepare data, only but do not output text and do not show page


showPageOnly

public WebBox showPageOnly(javax.servlet.jsp.PageContext pageContext)
Show page only, do not call prepareStaticMethod and URL


getBox

public static WebBox getBox(javax.servlet.jsp.PageContext pageContext)
Get current pageContext's WebBox instance


getAttribute

public static <T> T getAttribute(javax.servlet.jsp.PageContext pageContext,
                                 String attributeName)
Get an attribute from current page's WebBox instance


showAttribute

public static void showAttribute(javax.servlet.jsp.PageContext pageContext,
                                 String attributeName)
Assume the value is String or WebBox instance, show it


showTarget

public static void showTarget(javax.servlet.jsp.PageContext pageContext,
                              Object target)
Show an target object, target can be: WebBox instance or String or List of WebBox instance or String


setAttribute

public WebBox setAttribute(String key,
                           Object value)
Set attribute for current WebBox instance


getAttribute

public <T> T getAttribute(String key)
Get WebBox's attribute


getObject

public <T> T getObject(String key)
Search and return an attribute object follow this order: pageContext->request->parameter->session


setPageContextAttribute

public void setPageContextAttribute(String key,
                                    Object value)
Set a pageContext attribute


setRequestAttribute

public void setRequestAttribute(String key,
                                Object value)
Set a request attribute


setSessionAttribute

public void setSessionAttribute(String key,
                                Object value)
Set a session attribute


getPrepareURL

public String getPrepareURL()
Get the prepare URL


setPrepareURL

public WebBox setPrepareURL(String prepareURL)
Set prepare URL, this URL be called after prepare methods but before show page


getPage

public Object getPage()
Get the page


setPage

public WebBox setPage(Object page)
Set a JSP page or URL


getText

public String getText()
Get the Text


setText

public WebBox setText(String text)
Set the text String


setPrepareStaticMethod

public WebBox setPrepareStaticMethod(String prepareStaticMethod)
Set a prepare static method


getPrepareStaticMethod

public String getPrepareStaticMethod()
Get the Prepare static method name


getPrepareBean

public Object getPrepareBean()
Get the prepare bean instance


setPrepareBean

public WebBox setPrepareBean(Object prepareBean)
Set a prepare bean which has a prepare method


getPrepareBeanMethod

public String getPrepareBeanMethod()
Get the prepare bean method name


setPrepareBeanMethod

public WebBox setPrepareBeanMethod(String prepareBeanMethod)
Set the bean prepare method name


getAttributeMap

public Map<String,Object> getAttributeMap()
Get the attribute map of WebBox instance


setAttributeMap

public WebBox setAttributeMap(Map<String,Object> attributeMap)
Set the attribute map for WebBox instance


getName

public String getName()
get the name of the WebBox instance


setName

public WebBox setName(String name)
Set the name of the WebBox instance


getFatherWebBox

public WebBox getFatherWebBox()
Set the father page's WebBox instance


setFatherWebBox

public void setFatherWebBox(WebBox fatherWebBox)
Get the father page's WebBox instance


getPageContext

public javax.servlet.jsp.PageContext getPageContext()
Get current pageContext if have


setPageContext

public void setPageContext(javax.servlet.jsp.PageContext pageContext)
Set pageContext to it



Copyright © 2018. All rights reserved.