returnurltag.java
来自「一个免费wap站」· Java 代码 · 共 76 行
JAVA
76 行
package com.eline.wap.catalog.taglib.wml;
import java.io.IOException;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.tagext.TagSupport;
import com.eline.wap.catalog.client.CatalogHelper;
import com.eline.wap.catalog.exceptions.CatalogException;
import com.eline.wap.catalog.model.Item;
import com.eline.wap.catalog.model.ListItem;
import com.eline.wap.catalog.model.SingleItem;
import com.eline.wap.catalog.util.WapFormatter;
import com.eline.wap.common.util.AppLogger;
import com.eline.wap.common.util.WapUrls;
public class ReturnURLTag extends TagSupport {
/**
*
*/
private static final long serialVersionUID = 3005167481026865850L;
private int catalogId = -1;
private String type = "list";
public int doStartTag() throws JspException {
CatalogHelper ch = new CatalogHelper();
String returnURL = null;
if (catalogId <= 0)
return SKIP_BODY;
try {
Item item = ch.getItem(catalogId);
int parentId = item.getParentId();
if (parentId > 0) {
if (type.equalsIgnoreCase("list")) {
Item parentItem = ch.getItem(parentId);
if (parentItem instanceof ListItem) {
returnURL = WapFormatter.getListURL(((ListItem)parentItem).getListAttribute()) + "?catalogId=" + parentItem.getIndexId();
}
} else {
if (item instanceof SingleItem) {
returnURL = WapFormatter.getSingleURL(((SingleItem)item).getSingleAttribute()) + "?catalogId=" + catalogId;
}
}
} else {
returnURL = WapUrls.getInstance().getProperty(WapUrls.CATALOG_LIST) + "?catalogId=0";
}
} catch (CatalogException e) {
AppLogger.error("ReturnURLTag.doStartTag() CatalogException : " + e.getMessage());
}
JspWriter out = pageContext.getOut();
try {
out.print(returnURL);
} catch (IOException e) {
}
return EVAL_PAGE;
}
public int doEndTag() throws JspException {
// TODO Auto-generated method stub
return super.doEndTag();
}
public void setCatalogId(int catalogId) {
this.catalogId = catalogId;
}
public void setType(String type) {
this.type = type;
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?