📄 dropmenutag.java
字号:
package com.esimple.framework.web.taglib.menu;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.BodyTagSupport;
import javax.servlet.jsp.tagext.TagSupport;
import org.apache.struts.util.RequestUtils;
import org.apache.struts.util.ResponseUtils;
/**
* @author steven
*
*/
public class DropMenuTag extends BodyTagSupport {
private String menuId = "mainMenu";
private String style = "hbr";
private String theme = "ThemeOffice";
private String model = "mainMenu";
protected String scope = null;
public String getScope() {
return (this.scope);
}
public void setScope(String scope) {
this.scope = scope;
}
public void setMenuId(String menuId){
this.menuId = menuId;
}
public String getMenuId(){
return this.menuId;
}
public void setStyle(String style){
this.style = style;
}
public String getStyle(){
return this.style;
}
public void setTheme(String theme){
this.theme = theme;
}
public String getTheme(){
return this.theme;
}
public void setModel(String model){
this.model = model;
}
public String getModel(){
return this.model;
}
public int doStartTag() {
MenuModel menu=null;
try {
if( model != null ){
menu = (MenuModel)RequestUtils.lookup(pageContext, model,scope);
}
} catch (JspException e) {
e.printStackTrace();
}
//System.out.println("menu:" + menu );
if( menu == null ) return SKIP_BODY;
try {
writeHtml( menu );
} catch (Exception e) {
e.printStackTrace();
}
return TagSupport.SKIP_BODY;
}
private void writeHtml(MenuModel menu) throws Exception {
StringBuffer results = new StringBuffer();
results.append("<DIV id="+menuId+"></DIV>");
results.append("<SCRIPT language=JavaScript src='/widget/menu/JSCookMenu.js' type=text/javascript></SCRIPT>");
results.append("<SCRIPT language=JavaScript type=text/javascript>");
results.append( DropMenuMaker.makeMenu(menu) );
results.append("cmDraw ('"+ menuId + "', myMenu, '"+ style + "', cmThemeOffice, '"+ theme +"');");
results.append("</SCRIPT></div>");
ResponseUtils.write(pageContext, results.toString());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -