⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 beantag.java

📁 webwork source
💻 JAVA
字号:
/* * WebWork, Web Application Framework * * Distributable under Apache license. * See terms of license at opensource.org */package webwork.view.taglib;import webwork.util.BeanUtil;import javax.servlet.jsp.JspException;import javax.servlet.jsp.PageContext;import java.beans.Beans;/** *	Instantiate a JavaBean. * * The bean may be an action, in which it is executed before used. * It is lazily executed, which means that you can set parameters * by using the "param" tag. * *	@author Rickard 謆erg (rickard@dreambean.com) *	@version $Revision: 1.7 $ */public class BeanTag   extends WebWorkTagSupport   implements ParamTag.Parametric{   // Attributes ----------------------------------------------------   protected String nameAttr;   protected Object bean;   // Public --------------------------------------------------------	/**	 * Set name of JavaBean class.	 *	 * @param aName class name	 */   public void setName(String aName)   {      nameAttr = aName;   }   /**    * Set property in bean    */   public void addParameter(String name, Object value)   {      BeanUtil.setProperty(name, value, bean);   }   // BodyTag implementation ----------------------------------------   public int doStartTag() throws JspException   {      // Instantiate bean      ClassLoader cl = Thread.currentThread().getContextClassLoader();      try      {         String name = (String)findValue(nameAttr);         if (name == null)            throw new JspException("No bean named "+nameAttr+" found. Try putting quotes around name");         bean = Beans.instantiate(cl, name);      } catch (Exception e)      {         try         {            pageContext.handlePageException(e);         } catch (Exception ex)         {            // Ignore         }      }      getStack().pushValue(bean);      // Store as attribute?      if(getId() != null)      {         pageContext.setAttribute(getId(), bean);         pageContext.setAttribute(getId(), bean, PageContext.REQUEST_SCOPE);      }      return EVAL_BODY_INCLUDE;   }   public int doEndTag() throws JspException   {      getStack().popValue();      return EVAL_PAGE;   }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -