/backpath/trunk/tld/ak-backpath.tld |
---|
1,4 → 1,4 |
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
<!DOCTYPE taglib PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN" "http://java.sun.com/j2ee/dtds/web-jsptaglibrary_1_1.dtd"> |
<taglib> |
<tlibversion>1.0</tlibversion> |
7,6 → 7,30 |
<uri>http://26th.net/backpath</uri> |
<tag> |
<name>init</name> |
<tagclass>ak.backpath.taglib.InitTag</tagclass> |
<attribute> |
<name>backPathKey</name> |
<required>false</required> |
<rtexprvalue>true</rtexprvalue> |
</attribute> |
<attribute> |
<name>backPathParam</name> |
<required>false</required> |
<rtexprvalue>true</rtexprvalue> |
</attribute> |
<attribute> |
<name>backPathIgnore</name> |
<required>false</required> |
<rtexprvalue>true</rtexprvalue> |
</attribute> |
<attribute> |
<name>zip</name> |
<required>false</required> |
<rtexprvalue>true</rtexprvalue> |
</attribute> |
</tag> |
<tag> |
<name>backlink</name> |
<tagclass>ak.backpath.taglib.BackwardLinkTag</tagclass> |
<attribute> |
/backpath/trunk/src/ak/backpath/BackPath.java |
---|
59,6 → 59,8 |
protected boolean forwardParamsFormed = false; |
protected String currentParams; |
protected boolean currentParamsFormed = false; |
protected String currentUrl; |
protected boolean currentUrlFormed = false; |
protected String backwardParams; |
protected boolean backwardParamsFormed = false; |
protected String backwardUrl; |
82,15 → 84,23 |
String backPathParam, String backPathIgnore, boolean zip) |
throws Exception |
{ |
String[] ignores = null; |
if(backPathIgnore != null) |
ignores = backPathIgnore.trim().split(IGNORES_DELIMITER); |
return findBackPath(request, backPathKey, backPathParam, ignores, zip); |
} |
public static BackPath findBackPath(HttpServletRequest request, String backPathKey, |
String backPathParam, String[] ignores, boolean zip) |
throws Exception |
{ |
Object backPathObj = request.getAttribute(backPathKey); |
if(backPathObj == null) { |
BackPath backPath; |
String[] ignores = null; |
if(backPathIgnore != null) |
ignores = backPathIgnore.trim().split(IGNORES_DELIMITER); |
backPath = new BackPath(request, backPathParam, ignores, zip); |
request.setAttribute(backPathKey, backPath); |
return backPath; |
256,6 → 266,37 |
} |
} |
public String getCurrentUrl() |
{ |
if(!currentParamsFormed) { |
currentUrl = formCurrentUrl(); |
currentUrlFormed = true; |
} |
return currentUrl; |
} |
protected String formCurrentUrl() |
{ |
if(stack.size() < 1) return null; |
try { |
StringBuffer url = new StringBuffer((String)stack.get(stack.size()-1)); |
if(stack.size() > 1) { |
String s = encode(stack, zip, 1); |
if(url.indexOf(URL_PARAM_START_STR) >= 0) url.append(URL_PARAM_SEPARATOR); |
else url.append(URL_PARAM_START); |
url.append(param).append(URL_PARAM_VALUE).append(s); |
} |
return url.toString(); |
} |
catch(IOException ex) { |
log.error("Cannot form current url", ex); |
return null; |
} |
} |
public void init(HttpServletRequest request) |
{ |
try { |
297,6 → 338,7 |
// form url |
if(query.length() > 0) url = query.insert(0, url).toString(); |
} |
stack.add(url); |
} |
catch(IOException ex) { |
386,6 → 428,8 |
forwardParamsFormed = false; |
currentParams = null; |
currentParamsFormed = false; |
currentUrl = null; |
currentUrlFormed = false; |
backwardParams = null; |
backwardParamsFormed = false; |
backwardUrl = null; |
/backpath/trunk/src/ak/backpath/taglib/ak-backpath.tld |
---|
File deleted |
/backpath/trunk/src/ak/backpath/taglib/EmptyTagBase.java |
---|
66,7 → 66,7 |
public int doStartTag() throws JspException |
{ |
if (condition()) |
if(condition()) |
return (EVAL_BODY_INCLUDE); |
else |
return (SKIP_BODY); |
/backpath/trunk/src/ak/backpath/taglib/InitTag.java |
---|
0,0 → 1,86 |
package ak.backpath.taglib; |
import javax.servlet.http.HttpServletRequest; |
import javax.servlet.jsp.JspException; |
import javax.servlet.jsp.tagext.TagSupport; |
import ak.backpath.BackPath; |
/** |
* This tag just does nothing but saves a backpath object into request with given params, |
* should be used at the top pf JSp to ensure that all tags use correct backpath params. |
*/ |
public class InitTag extends TagSupport |
{ |
protected String backPathKey = BackPath.DEFAULT_KEY; |
public String getBackPathKey() |
{ |
return this.backPathKey; |
} |
public void setBackPathKey(String backPathKey) |
{ |
this.backPathKey = backPathKey; |
} |
protected String backPathParam = BackPath.DEFAULT_PARAM; |
public String getBackPathParam() |
{ |
return this.backPathParam; |
} |
public void setBackPathParam(String backPathParam) |
{ |
this.backPathParam = backPathParam; |
} |
protected String backPathIgnore = null; |
public String getBackPathIgnore() |
{ |
return this.backPathIgnore; |
} |
public void setBackPathIgnore(String backPathIgnore) |
{ |
this.backPathIgnore = backPathIgnore; |
} |
protected boolean zip = BackPath.DEFAULT_ZIP; |
public boolean getZip() |
{ |
return this.zip; |
} |
public void setZip(boolean zip) |
{ |
this.zip = zip; |
} |
public void release() |
{ |
super.release(); |
backPathKey = BackPath.DEFAULT_KEY; |
backPathParam = BackPath.DEFAULT_PARAM; |
backPathIgnore = null; |
zip = BackPath.DEFAULT_ZIP; |
} |
public int doStartTag() throws JspException |
{ |
// remove old, if any |
((HttpServletRequest)pageContext.getRequest()).removeAttribute(backPathKey); |
// create a new one |
TaglibUtils.findBackPath(pageContext, backPathKey, backPathParam, backPathIgnore, zip); |
return (SKIP_BODY); |
} |
public int doEndTag() throws JspException |
{ |
return (EVAL_PAGE); |
} |
} |