JSP Help Icon Tag


public class HelpIconTag extends TagSupport {
    
    private String key;
    public void setKey(String key) {
        this.key = key;
    }

    private String position = "";
    public void setPosition(String position) {
        this.position = position;
    }
    
    private int level = 1;
    public void setLevel(int level) {
        this.level = level;
    }
    
    @Override
    public int doStartTag() throws JspException {
        try {
            ServiceContainer services = (ServiceContainer) pageContext.getRequest().getAttribute(Key.SERVICES);
            TenantSettings settings = null;
            if(services.tenant != null ) {
                settings = services.tenant.getSettings();
            }
            if(settings == null || settings.getHelpId() == null || settings.getHelpId().intValue() <= level) {
                JspWriter out = pageContext.getOut();
                String helpString = services.cmsService.getHelp(key);
                if(helpString == null || helpString.isEmpty()) {
                    helpString = key + "Help";
                }
                out.print("");
            }
        } catch (Exception ioe) {
            ioe.printStackTrace();
        }
        return SKIP_BODY;
    }

    @Override
    public int doEndTag() throws JspException {
        return EVAL_PAGE;
    }
}
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s