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
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
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 attribute from current WebBox instance
 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
 String getPage()
          Get the page
 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(String page)
          Set a JSP page or URL
 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
 WebBox setText(String text)
          Set the text String
 void 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
 void 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


show

public void 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 void 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 attribute from current WebBox instance


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 String getPage()
Get the page


setPage

public WebBox setPage(String 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



Copyright © 2018. All rights reserved.