|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javax.servlet.jsp.tagext.TagSupport javax.servlet.jsp.tagext.BodyTagSupport org.dbforms.taglib.AbstractScriptHandlerTag org.dbforms.taglib.AbstractDbBaseHandlerTag org.dbforms.taglib.DbFilterTag
public class DbFilterTag
custom tag that build up a set of sql filters. Create a set of sql filter conditions, letting user select which one will be applied. A filter tag contains one or more filterCondition tag. Each filterCondition represent a sql condition and is identified by its label. In the body of the filterCondition tag there is the piece of SQL code that we want to insert in the where clause, the character ? act like a placeholder, so a ? in the sql code will be substituted with the some user input. To tell the system what type of user input we want, the last tag is used, the filterValue tag. Each ? found in body will be subsituted by its corresponding filterValue tag. With the "type" attribute of this tag you can select the input more. Selecting "text", a filterValue will render an html input tag, with "select" you'll have an html select, and so on. An example is like this:
<db:filter> <db:filterCondition label="author name like"> NAME LIKE '%?%' <db:filterValue type="timestamp" useJsCalendar="true" /> </db:filterCondition> <db:filterCondition label="ID > V1 AND ID < V2"> AUTHOR_ID >= ? AND AUTHOR_ID <= ? <db:filterValue label="V1" type="numeric"/> <db:filterValue label="V2" type="numeric"/> </db:filterCondition> <db:filterCondition label="author = "> NAME = '?' <db:filterValue type="select"> <db:queryData name="q1" query="select distinct name as n1, name as n2 from author where AUTHOR_ID < 100 order by name"/> </db:filterValue> </db:filterCondition> <db:filterCondition label="now is after date"> CURRENT_DATE > ? <db:filterValue type="date" useJsCalendar="true" /> </db:filterCondition> <db:filterCondition label="filter without user input"> AUTHOR_ID > 10 </db:filterCondition> </db:filter>This structure will be rendered as a html select element to select the condition the you want to apply. On the onchange event there is a submit, so the page reload with the input elements of the condition that you have selected. After all input elements, there are two buttons, one to apply the condition, one to unset the current applied condition.
Internals:
Reading data from request, and update corrispondently the sqlFilter attribute of DbFormTag is done in the static method generateSqlFilter, which produce in output a valid filter string. This method is called in DbFormTag's method doStartTag, setting with it the sqlFilter attribute value. The only other changes needed in DbFormTag's doStartTag is the nullifing of the firstPosition and lastPosition variables that normally contain the current position in the case of applying of a filter (.i.e. when user press the set button, and so the filter_<tableId>_set parameter is found in request). This is needed because here we must force the goto event to move to the first avalilable row.
Field Summary | |
---|---|
protected static String |
FLT_COND
DOCUMENT ME! |
protected static String |
FLT_PREFIX
DOCUMENT ME! |
protected static String |
FLT_SEARCHALGO
DOCUMENT ME! |
protected static String |
FLT_SEL
DOCUMENT ME! |
protected static String |
FLT_SET
DOCUMENT ME! |
protected static String |
FLT_VALUE
DOCUMENT ME! |
protected static String |
FLT_VALUETYPE
DOCUMENT ME! |
Fields inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
---|
bodyContent |
Fields inherited from class javax.servlet.jsp.tagext.TagSupport |
---|
id, pageContext |
Fields inherited from interface javax.servlet.jsp.tagext.BodyTag |
---|
EVAL_BODY_BUFFERED, EVAL_BODY_TAG |
Fields inherited from interface javax.servlet.jsp.tagext.IterationTag |
---|
EVAL_BODY_AGAIN |
Fields inherited from interface javax.servlet.jsp.tagext.Tag |
---|
EVAL_BODY_INCLUDE, EVAL_PAGE, SKIP_BODY, SKIP_PAGE |
Constructor Summary | |
---|---|
DbFilterTag()
|
Method Summary | |
---|---|
protected int |
addCondition(DbFilterConditionTag condition)
add a condition object to the list. |
int |
doEndTag()
here we read information from nested tags and we render output to the page. |
void |
doFinally()
reset tag state |
int |
doStartTag()
initialize environment |
protected String |
getFilterName()
filter's parameters prefix in request |
protected static String |
getFilterName(int tableId)
filter prefix |
static String |
getSqlFilter(HttpServletRequest request,
int tableId)
return the currently setted filter condition, reading it from request. |
static FieldValue[] |
getSqlFilterParams(HttpServletRequest request,
int tableId)
return the parametes of the currently setted filter condition, reading it from request. |
protected int |
getTableId()
return tableId of the parent dbform tag |
void |
setDisabledCaption(String string)
DOCUMENT ME! |
void |
setSetCaption(String string)
DOCUMENT ME! |
void |
setSetStyleClass(String string)
DOCUMENT ME! |
void |
setSize(String string)
DOCUMENT ME! |
void |
setUnsetCaption(String string)
DOCUMENT ME! |
void |
setUnsetStyleClass(String string)
DOCUMENT ME! |
Methods inherited from class org.dbforms.taglib.AbstractScriptHandlerTag |
---|
doCatch, getAccessKey, getConfig, getOnBlur, getOnChange, getOnClick, getOnDblClick, getOnFocus, getOnKeyDown, getOnKeyPress, getOnKeyUp, getOnMouseDown, getOnMouseMove, getOnMouseOut, getOnMouseOver, getOnMouseUp, getOnSelect, getStyle, getTabIndex, getTitle, prepareEventHandlers, prepareStyles, setAccessKey, setOnBlur, setOnChange, setOnClick, setOnDblClick, setOnFocus, setOnKeyDown, setOnKeyPress, setOnKeyUp, setOnMouseDown, setOnMouseMove, setOnMouseOut, setOnMouseOver, setOnMouseUp, setOnSelect, setStyle, setStyleClass, setTabIndex, setTitle |
Methods inherited from class javax.servlet.jsp.tagext.BodyTagSupport |
---|
doAfterBody, doInitBody, getBodyContent, getPreviousOut, release, setBodyContent |
Methods inherited from class javax.servlet.jsp.tagext.TagSupport |
---|
findAncestorWithClass, getId, getParent, getValue, getValues, removeValue, setId, setPageContext, setValue |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.servlet.jsp.tagext.TryCatchFinally |
---|
doCatch |
Methods inherited from interface javax.servlet.jsp.tagext.Tag |
---|
getParent, setPageContext |
Field Detail |
---|
protected static final String FLT_COND
protected static final String FLT_PREFIX
protected static final String FLT_SEL
protected static final String FLT_SET
protected static final String FLT_VALUE
protected static final String FLT_VALUETYPE
protected static final String FLT_SEARCHALGO
Constructor Detail |
---|
public DbFilterTag()
Method Detail |
---|
public static String getSqlFilter(HttpServletRequest request, int tableId)
request
- tableId
-
public static FieldValue[] getSqlFilterParams(HttpServletRequest request, int tableId)
request
- tableId
-
public void setDisabledCaption(String string)
string
- public void setSetCaption(String string)
string
- public void setSize(String string)
string
- public void setUnsetCaption(String string)
string
- public int doEndTag() throws javax.servlet.jsp.JspException
doEndTag
in interface javax.servlet.jsp.tagext.Tag
doEndTag
in class javax.servlet.jsp.tagext.BodyTagSupport
javax.servlet.jsp.JspException
Tag.doEndTag()
public void doFinally()
doFinally
in interface javax.servlet.jsp.tagext.TryCatchFinally
doFinally
in class AbstractDbBaseHandlerTag
TryCatchFinally.doFinally()
public int doStartTag() throws javax.servlet.jsp.JspException
doStartTag
in interface javax.servlet.jsp.tagext.Tag
doStartTag
in class javax.servlet.jsp.tagext.BodyTagSupport
javax.servlet.jsp.JspException
Tag.doStartTag()
protected static String getFilterName(int tableId)
tableId
-
protected String getFilterName()
protected int getTableId()
protected int addCondition(DbFilterConditionTag condition)
condition
- to add
public void setSetStyleClass(String string)
string
- public void setUnsetStyleClass(String string)
string
-
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |