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

📄 menudefinetag.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.struts.service.StrutsService;
import opiam.admin.faare.struts.service.beans.JBMenu;

import org.apache.struts.taglib.TagUtils;

import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.TagSupport;


/**
 * This tag loads the menus of corresponding user profile at first call,
 * and stores them in the session.
 * Next, it retrieves the requested menu and sets it in the page context.
 *
 */
public class MenuDefineTag extends TagSupport
{
    /** Session attribute storing menus. */
    public static final String USER_MENUS_SESSION_ATTR = "_user_menu_session_attr";

    /** Menu identifier in page context. */
    private String id;

    /** Requested menu name. */
    private String name;

    /**
     * @see javax.servlet.jsp.tagext.Tag#doStartTag().
     */
    public int doStartTag() throws JspException
    {
        Map menus = (Map) pageContext.getSession().getAttribute(USER_MENUS_SESSION_ATTR);

        try
        {
            if (menus == null)
            {
                // r閏uperer les menus
                UserContext userContext = (UserContext) TagUtils.getInstance().lookup(pageContext,
                        "sessionContext", "userContext", "session");
                menus = StrutsService.getCurrentProfileMenus(userContext);
                pageContext.getSession().setAttribute(USER_MENUS_SESSION_ATTR,
                    menus);
            }

            String key = name.trim().toLowerCase();
            JBMenu currentMenu = (JBMenu) menus.get(key);

            if (currentMenu == null)
            {
                // put empty menu
                currentMenu = new JBMenu();
            }

            pageContext.setAttribute(id, currentMenu);
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }

        return (SKIP_BODY);
    }

    /**
     * @see javax.servlet.jsp.tagext.Tag#release().
     */
    public void release()
    {
        super.release();
    }

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

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

⌨️ 快捷键说明

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