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

📄 referenceelementdefinetag.java

📁 OPIAM stands for Open Identity and Access Management. This Suite will provide modules for user & rig
💻 JAVA
字号:
/*
 * OPIAM Suite
 *
 * Distributable under LGPL license.
 * See terms of license at gnu.org.
 */

package opiam.admin.faare.struts.taglib;

import opiam.admin.faare.service.UserContext;
import opiam.admin.faare.service.services.references.ReferenceService;
import opiam.admin.faare.struts.service.StrutsService;

import org.apache.struts.taglib.TagUtils;

import java.util.Collections;
import java.util.List;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.PageContext;
import javax.servlet.jsp.tagext.BodyTagSupport;


/**
 * This tag allows to load either an operators list (Struts service)
 * or a search reference list (References service).
 *
 */
public class ReferenceElementDefineTag extends BodyTagSupport
{
    /** List identifier. */
    private String id;

    /** List type: reflist or operator. */
    private String type;

    /** List name. */
    private String name;

    /** Tag body. */
    private String body;

    /**
     * Saves the body content of this tag (if any), or throw a JspException
     * if the value was already defined.
     *
     * @return see BodyTagSupport
     *
     * @throws JspException if the value was already defined
     */
    public int doAfterBody() throws JspException
    {
        if (bodyContent != null)
        {
            body = bodyContent.getString();

            if (body != null)
            {
                body = body.trim();
            }

            if (body.length() < 1)
            {
                body = null;
            }
        }

        return (SKIP_BODY);
    }

    /**
     * Sets the list name.
     * @param aname The name to set
     */
    public void setName(String aname)
    {
        this.name = aname;
    }

    /**
     * Returns the list identifier.
     * @return identifier
     */
    public String getId()
    {
        return id;
    }

    /**
     * Sets the identifier.
     * @param aid The identifier to set
     */
    public void setId(String aid)
    {
        this.id = aid;
    }

    /**
     * Returns the type.
     * @return reflist or operator
     */
    public String getType()
    {
        return type;
    }

    /**
     * Sets the type.
     * @param atype The type to set: reflist or operator
     */
    public void setType(String atype)
    {
        this.type = atype;
    }

    /**
     * Retrieves the required property and exposes it as a scripting variable.
     *
     * @return see BodyTagSupport
     * @throws JspException if a JSP exception has occurred
     */
    public int doEndTag() throws JspException
    {
        List value = null;

        try
        {
            if (type.compareToIgnoreCase("operator") == 0)
            {
                value = StrutsService.getOperatorsList(name);
            }
            else
            {
                UserContext userContext = (UserContext) TagUtils.getInstance().lookup(pageContext,
                        "sessionContext", "userContext", "session");

                if (userContext == null)
                {
                    System.out.println(" *** userContext = NULL");
                }

                value = ReferenceService.getReferenceList(name, userContext)
                                        .getReferenceList();
            }
        }
        catch (Exception e)
        {
            value = Collections.EMPTY_LIST;
        }

        pageContext.setAttribute(id, value, PageContext.PAGE_SCOPE);

        // Continue processing this page
        return (EVAL_PAGE);
    }
}

⌨️ 快捷键说明

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