public abstract class Module
extends java.lang.Object
BasePage
to show some dynamic content must extend this class. The dynamic modules
are called when the tag name looks like a java class (package.class_name for example).Constructor and Description |
---|
Module() |
Modifier and Type | Method and Description |
---|---|
ExtendedServlet |
getCallingServlet()
This method will return the calling servlet, if it was set.
|
abstract Page |
getContent(java.util.Map<java.lang.String,java.lang.String> m)
This is the work that the module does.
|
Page |
getContent(java.lang.String s)
This is called by
BasePage to obtain the page to put in the place of the tag. |
protected static int |
geti(java.util.Map<java.lang.String,java.lang.String> m,
java.lang.String s,
int i)
Method to easily extract an integer parameter from the module arguments.
|
abstract java.lang.String |
getModuleName()
The module must also implement this method, to return a nice name to debug.
|
protected static java.lang.String |
gets(java.util.Map<java.lang.String,java.lang.String> m,
java.lang.String s,
java.lang.String sDefault)
Method to easily extract a string parameter from the module arguments.
|
TemplatePage |
getWrapper()
This default method returns a wrapper for the HTML that is generated by all the modules.
|
static java.util.Map<java.lang.String,java.lang.String> |
parse(java.lang.String s)
This method parses the argument string to obtain the key-value pairs for the arguments.
|
public Page getContent(java.lang.String s)
BasePage
to obtain the page to put in the place of the tag. The argument will be parsed to
extract key=value pairs and to put them into a Map of options to be given to the module implementation.s
- arguments, the rest of the tag after the class namepublic abstract Page getContent(java.util.Map<java.lang.String,java.lang.String> m)
m
- arguments to call the module withpublic abstract java.lang.String getModuleName()
public TemplatePage getWrapper()
protected static final int geti(java.util.Map<java.lang.String,java.lang.String> m, java.lang.String s, int i)
m
- map of the argumentss
- key namei
- default value to return in case of an errorprotected static final java.lang.String gets(java.util.Map<java.lang.String,java.lang.String> m, java.lang.String s, java.lang.String sDefault)
m
- map of the argumentss
- key namesDefault
- the default value to return in case the key is not found in the arguments of the module at call timepublic static final java.util.Map<java.lang.String,java.lang.String> parse(java.lang.String s)
<<:portal.weather day=today city=Bucharest:>>
. In this case, the class to be instantiated is portal.weather
and the argument string is day=today city=Bucharest
. This string will be parsed to obtain the map {day={today}, city={Bucharest}}
s
- original argument to the modulepublic final ExtendedServlet getCallingServlet()
BasePage.setCallingServlet(ExtendedServlet)
otherwise this pointer will be null.