如何在JSP页面之外运行taglib?

时间:2012-04-18 15:44:18

标签: jsp java-ee servlets jsp-tags taglib

鉴于我在JSP上有这样的东西:

<cic:table listBeanParm="presbeans" showSelct="false" messageType="cicProductTable">
    <cic:column>
        <cic:title>A column title</cic:title>
    </cic:column>    
</cic:table>
....
<% TableModel tableModel = (TableModel)request.getAttribute( "cic.table.model"); %>
//tableModel used here

我可以在与cic:table相关联的代码中看到它设置属性“cic.table.model”(障碍:我必须反编译才能看到它......没有来源)。

            public int doEndTag() throws JspException {
/*  47*/        request.setAttribute("cic.table.model", tableModel);
/*  48*/        init();
/*  49*/        return super.doEndTag();
            }

看起来像heirarchy这样的类型:

cicTable extends cicComponent
cicComponent extends BodyTagSupport
(cicComponent runs pageContext.getOut(), and we do not have a page!)

但即便如此,我尝试了几个这样的变体(doStartTag,doEndTag),但是我的调用总是失败,并且在编译的类中有一个空指针:

    System.out.println("type:" + request.getAttribute("presbeans").getClass().getName());
    cicTable aTable = new cicTable();
    aTable.setListBeanParam("presbeans");
    aTable.setShowSelect("false");
    aTable.setMessageType("cicProductTable");
    //int result = Integer.MAX_VALUE;
    //try {result = aTable.doStartTag();} catch (Exception e) {System.out.println("doStartTag bombed: " + e.getMessage());}
    //System.out.println("doStartTag returned " + result);
    int result2 = Integer.MAX_VALUE;
    result2 = Integer.MAX_VALUE;
    try {result2 = aTable.doEndTag();} catch (Exception e) {System.out.println("doEndTag bombed: " + e.getMessage());}
// Always a null pointer on the line above
    System.out.println("doEndTag returned " + result2);

    TableModel tableModel = (TableModel)request.getAttribute( "cic.table.model");

我想要做的是找到一种方法将JSP页面上taglibs中正在发生的事情转换为将在servlet中运行的代码。 是否有标准的,食谱,方法来获取在Servlet中运行的taglib内容?

0 个答案:

没有答案