Example usage for javax.servlet.jsp JspException JspException

List of usage examples for javax.servlet.jsp JspException JspException

Introduction

In this page you can find the example usage for javax.servlet.jsp JspException JspException.

Prototype

public JspException(Throwable cause) 

Source Link

Document

Constructs a new JspException with the specified cause.

Usage

From source file:it.eng.spagobi.commons.presentation.tags.ListTag.java

public int doStartTag() throws JspException {
    logger.info(" method invoked");
    _providerUrlMap = new HashMap();
    _paramsMap = new HashMap();

    // Angelo (19/06/2009) BUG FiX: navigator of Events doesn't work
    if (ChannelUtilities.isWebRunning()) {
        _providerUrlMap.put(SpagoBIConstants.WEBMODE, "TRUE");
    }/*  www .  jav a2  s  .c  o  m*/

    httpRequest = (HttpServletRequest) pageContext.getRequest();
    _requestContainer = ChannelUtilities.getRequestContainer(httpRequest);
    _responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    _serviceRequest = _requestContainer.getServiceRequest();
    _serviceResponse = _responseContainer.getServiceResponse();
    _errorHandler = _responseContainer.getErrorHandler();
    response = (HttpServletResponse) pageContext.getResponse();
    urlBuilder = UrlBuilderFactory.getUrlBuilder(_requestContainer.getChannelType());
    msgBuilder = MessageBuilderFactory.getMessageBuilder();

    currTheme = ThemesManager.getCurrentTheme(_requestContainer);
    if (currTheme == null)
        currTheme = ThemesManager.getDefaultTheme();

    if (_bundle == null)
        _bundle = "messages";

    profile = (IEngUserProfile) _requestContainer.getSessionContainer().getPermanentContainer()
            .getAttribute(IEngUserProfile.ENG_USER_PROFILE);

    // identity string for object of the page
    UUIDGenerator uuidGen = UUIDGenerator.getInstance();
    UUID uuid = uuidGen.generateTimeBasedUUID();
    requestIdentity = uuid.toString();
    requestIdentity = requestIdentity.replaceAll("-", "");

    ConfigSingleton configure = ConfigSingleton.getInstance();
    if (_actionName != null) {
        _serviceName = _actionName;
        _content = _serviceResponse;
        SourceBean actionBean = (SourceBean) configure.getFilteredSourceBeanAttribute("ACTIONS.ACTION", "NAME",
                _actionName);
        _layout = (SourceBean) actionBean.getAttribute("CONFIG");
        if (_layout == null) {
            // if the layout is dinamically created it is an attribute of the response
            _layout = (SourceBean) _serviceResponse.getAttribute("CONFIG");
        }
        _providerURL = "ACTION_NAME=" + _actionName + "&";
        _providerUrlMap.put("ACTION_NAME", _actionName);
        HashMap params = (HashMap) _serviceResponse.getAttribute("PARAMETERS_MAP");
        if (params != null) {
            _paramsMap = params;
            _providerUrlMap.putAll(_paramsMap);
        }

    } // if (_actionName != null)
    else if (_moduleName != null) {
        _serviceName = _moduleName;
        logger.debug(" Module Name: " + _moduleName);
        _content = (SourceBean) _serviceResponse.getAttribute(_moduleName);
        SourceBean moduleBean = (SourceBean) configure.getFilteredSourceBeanAttribute("MODULES.MODULE", "NAME",
                _moduleName);
        if (moduleBean != null)
            logger.debug(" configuration loaded");
        _layout = (SourceBean) moduleBean.getAttribute("CONFIG");
        if (_layout == null) {
            // if the layout is dinamically created it is an attribute of the response
            _layout = (SourceBean) _serviceResponse.getAttribute(_moduleName + ".CONFIG");
        }
        String pageName = (String) _serviceRequest.getAttribute("PAGE");
        logger.debug(" PAGE: " + pageName);
        _providerURL = "PAGE=" + pageName + "&MODULE=" + _moduleName + "&";
        _providerUrlMap.put("PAGE", pageName);
        _providerUrlMap.put("MODULE", _moduleName);

        //checks for exception module (ie. for job and trigger must added the parameter MESSAGEDET into url
        for (int i = 0; i < EXCEPTION_MODULES.length; i++) {
            if (pageName.equalsIgnoreCase(EXCEPTION_MODULES[i])) {
                _providerUrlMap = updateUrlForExceptions(_providerUrlMap, _serviceRequest);
                break;
            }
        }
        HashMap params = (HashMap) _serviceResponse.getAttribute(_moduleName + ".PARAMETERS_MAP");
        if (params != null) {
            _paramsMap = params;
            _providerUrlMap.putAll(_paramsMap);
        }

    } // if (_moduleName != null)
    else {
        logger.error("service name not specified");
        throw new JspException("Business name not specified !");
    } // if (_content == null)
    if (_content == null) {
        logger.warn("list content null");
        return SKIP_BODY;
    } // if (_content == null)
    if (_layout == null) {
        logger.warn("list module configuration null");
        return SKIP_BODY;
    } // if (_layout == null)
      // if the LightNavigator is disabled entering the list, it is kept disabled untill exiting the list
    Object lightNavigatorDisabledObj = _serviceRequest
            .getAttribute(LightNavigationManager.LIGHT_NAVIGATOR_DISABLED);
    if (lightNavigatorDisabledObj != null) {
        String lightNavigatorDisabled = (String) lightNavigatorDisabledObj;
        _providerUrlMap.put(LightNavigationManager.LIGHT_NAVIGATOR_DISABLED, lightNavigatorDisabled);
    } else {
        // if the LightNavigator is abled, its LIGHT_NAVIGATOR_REPLACE_LAST function will be used while navigating the list
        _providerUrlMap.put(LightNavigationManager.LIGHT_NAVIGATOR_REPLACE_LAST, "true");
    }
    _htmlStream = new StringBuffer();
    makeForm();
    try {
        pageContext.getOut().print(_htmlStream);
    } // try
    catch (Exception ex) {
        logger.error("Impossible to send the stream");
        throw new JspException("Impossible to send the stream");
    } // catch (Exception ex)
    return SKIP_BODY;
}

From source file:de.laures.cewolf.taglib.tags.ChartMapTag.java

private boolean hasToolTips() throws JspException {
    if (toolTipGenerator != null && useJFreeChartTooltipGenerator) {
        throw new JspException(
                "Can't have both tooltipGenerator and useJFreeChartTooltipGenerator parameters specified!");
    }//from  ww  w. j a  va2 s .c  o m
    return toolTipGenerator != null || useJFreeChartTooltipGenerator;
}

From source file:com.glaf.core.tag.TagUtils.java

/**
 * Locate and return the specified property of the specified bean, from an
 * optionally specified scope, in the specified page context. If an
 * exception is thrown, it will have already been saved via a call to
 * <code>saveException()</code>.
 * //from   ww  w .ja  v  a2  s  . c om
 * @param pageContext
 *            Page context to be searched
 * @param name
 *            Name of the bean to be retrieved
 * @param property
 *            Name of the property to be retrieved, or <code>null</code> to
 *            retrieve the bean itself
 * @param scope
 *            Scope to be searched (page, request, session, application) or
 *            <code>null</code> to use <code>findAttribute()</code> instead
 * @return property of specified JavaBean
 * @throws JspException
 *             if an invalid scope name is requested
 * @throws JspException
 *             if the specified bean is not found
 * @throws JspException
 *             if accessing this property causes an IllegalAccessException,
 *             IllegalArgumentException, InvocationTargetException, or
 *             NoSuchMethodException
 */
public Object lookup(PageContext pageContext, String name, String property, String scope) throws JspException {
    // Look up the requested bean, and return if requested
    Object bean = lookup(pageContext, name, scope);

    if (bean == null) {
        JspException e = null;

        if (scope == null) {
            e = new JspException(messages.getMessage("lookup.bean.any", name));
        } else {
            e = new JspException(messages.getMessage("lookup.bean", name, scope));
        }

        saveException(pageContext, e);
        throw e;
    }

    if (property == null) {
        return bean;
    }

    // Locate and return the specified property
    try {
        return PropertyUtils.getProperty(bean, property);
    } catch (IllegalAccessException e) {
        saveException(pageContext, e);
        throw new JspException(messages.getMessage("lookup.access", property, name));
    } catch (IllegalArgumentException e) {
        saveException(pageContext, e);
        throw new JspException(messages.getMessage("lookup.argument", property, name));
    } catch (InvocationTargetException e) {
        Throwable t = e.getTargetException();

        if (t == null) {
            t = e;
        }

        saveException(pageContext, t);
        throw new JspException(messages.getMessage("lookup.target", property, name));
    } catch (NoSuchMethodException e) {
        saveException(pageContext, e);

        String beanName = name;

        // Name defaults to Contants.BEAN_KEY if no name is specified by
        // an input tag. Thus lookup the bean under the key and use
        // its class name for the exception message.
        if (Globals.BEAN_KEY.equals(name)) {
            Object obj = pageContext.findAttribute(Globals.BEAN_KEY);

            if (obj != null) {
                beanName = obj.getClass().getName();
            }
        }

        throw new JspException(messages.getMessage("lookup.method", property, beanName));
    }
}

From source file:com.xhsoft.framework.common.page.MiniPageTag.java

/**
 * <p>Description:?</p>/*from   ww  w .  j a va 2 s. c  o  m*/
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
private void printOutEnd() throws JspException {
    try {
        JspWriter out = pageContext.getOut();
        String outString = " ";
        out.print(outString);
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:it.eng.spagobi.commons.presentation.tags.QueryWizardTag.java

public int doStartTag() throws JspException {
    logger.debug("QueryWizardTag::doStartTag:: invoked");
    httpRequest = (HttpServletRequest) pageContext.getRequest();
    requestContainer = ChannelUtilities.getRequestContainer(httpRequest);
    responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    urlBuilder = UrlBuilderFactory.getUrlBuilder();
    msgBuilder = MessageBuilderFactory.getMessageBuilder();
    String dsLabelField = msgBuilder.getMessage("SBIDev.queryWiz.dsLabelField", "messages", httpRequest);
    String queryDefField = msgBuilder.getMessage("SBIDev.queryWiz.queryDefField", "messages", httpRequest);

    currTheme = ThemesManager.getCurrentTheme(requestContainer);
    if (currTheme == null)
        currTheme = ThemesManager.getDefaultTheme();

    RequestContainer aRequestContainer = RequestContainer.getRequestContainer();
    SessionContainer aSessionContainer = aRequestContainer.getSessionContainer();
    SessionContainer permanentSession = aSessionContainer.getPermanentContainer();
    IEngUserProfile userProfile = (IEngUserProfile) permanentSession
            .getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    boolean isable = false;
    try {//w  w  w  .j a  v a 2s  . c  om
        isable = userProfile.isAbleToExecuteAction(SpagoBIConstants.LOVS_MANAGEMENT);
    } catch (EMFInternalError e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (isable) {
        isreadonly = false;
        readonly = "";
        disabled = "";
    }

    List lstDs = new ArrayList();
    try {
        lstDs = DAOFactory.getDataSourceDAO().loadAllDataSources();
    } catch (EMFUserError emf) {
        emf.printStackTrace();
    }
    Iterator itDs = lstDs.iterator();

    StringBuffer output = new StringBuffer();

    output.append("<table width='100%' cellspacing='0' border='0'>\n");
    output.append("   <tr>\n");
    output.append("      <td class='titlebar_level_2_text_section' style='vertical-align:middle;'>\n");
    output.append("         &nbsp;&nbsp;&nbsp;"
            + msgBuilder.getMessage("SBIDev.queryWiz.wizardTitle", "messages", httpRequest) + "\n");
    output.append("      </td>\n");
    output.append("      <td class='titlebar_level_2_empty_section'>&nbsp;</td>\n");
    output.append("      <td class='titlebar_level_2_button_section'>\n");
    output.append("         <a style='text-decoration:none;' href='javascript:opencloseQueryWizardInfo()'> \n");
    output.append("            <img width='22px' height='22px'\n");
    output.append("                 src='"
            + urlBuilder.getResourceLinkByTheme(httpRequest, "/img/info22.jpg", currTheme) + "'\n");
    output.append("                name='info'\n");
    output.append("                alt='"
            + msgBuilder.getMessage("SBIDev.queryWiz.showSintax", "messages", httpRequest) + "'\n");
    output.append("                title='"
            + msgBuilder.getMessage("SBIDev.queryWiz.showSintax", "messages", httpRequest) + "'/>\n");
    output.append("         </a>\n");
    output.append("      </td>\n");
    String urlImgProfAttr = urlBuilder.getResourceLinkByTheme(httpRequest, "/img/profileAttributes22.jpg",
            currTheme);
    output.append(generateProfAttrTitleSection(urlImgProfAttr));
    output.append("   </tr>\n");
    output.append("</table>\n");

    output.append("<br/>\n");

    output.append("<div class='div_detail_area_forms_lov'>\n");
    output.append("      <div class='div_detail_label_lov'>\n");
    output.append("         <span class='portlet-form-field-label'>\n");
    output.append(dsLabelField);
    output.append("         </span>\n");
    output.append("      </div>\n");
    output.append("      <div class='div_detail_form'>\n");
    output.append(
            "         <select onchange='setLovProviderModified(true);' style='width:180px;' class='portlet-form-input-field' name='datasource' id='datasource' >\n");
    while (itDs.hasNext()) {
        IDataSource ds = (IDataSource) itDs.next();
        String dataSource = String.valueOf(ds.getLabel());
        String dataSourceDescription = ds.getDescr();
        dataSource = StringEscapeUtils.escapeHtml(dataSource);
        dataSourceDescription = StringEscapeUtils.escapeHtml(dataSourceDescription);

        String dsLabeleSelected = "";
        if (dataSourceLabel.equals(dataSource))
            dsLabeleSelected = "selected=\"selected\"";
        output.append("         <option " + disabled + " value='" + dataSource + "' " + dsLabeleSelected + ">"
                + dataSourceDescription + "</option>\n");
    }
    output.append("         </select>\n");
    output.append("      </div>\n");
    output.append("      <div class='div_detail_label_lov'>\n");
    output.append("         <span class='portlet-form-field-label'>\n");
    output.append(queryDefField);
    output.append("         </span>\n");
    output.append("      </div>\n");
    output.append("      <div style='height:110px;' class='div_detail_form'>\n");
    output.append("         <textarea style='height:100px;' " + disabled
            + " class='portlet-text-area-field' name='queryDef' onchange='setLovProviderModified(true);'  cols='50'>"
            + queryDef + "</textarea>\n");
    output.append("      </div>\n");
    output.append("      <div class='div_detail_label_lov'>\n");
    output.append("         &nbsp;\n");
    output.append("      </div>\n");
    output.append("</div>\n");

    output.append("<script>\n");
    output.append("      var infowizardqueryopen = false;\n");
    output.append("      var winQWT = null;\n");
    output.append("      function opencloseQueryWizardInfo() {\n");
    output.append("         if(!infowizardqueryopen){\n");
    output.append("            infowizardqueryopen = true;");
    output.append("            openQueryWizardInfo();\n");
    output.append("         }\n");
    output.append("      }\n");
    output.append("      function openQueryWizardInfo(){\n");
    output.append("         if(winQWT==null) {\n");
    output.append("            winQWT = new Window('winQWTInfo', {className: \"alphacube\", title:\""
            + msgBuilder.getMessage("SBIDev.queryWiz.showSintax", "messages", httpRequest)
            + "\", width:680, height:150, destroyOnClose: false});\n");
    output.append("            winQWT.setContent('querywizardinfodiv', false, false);\n");
    output.append("            winQWT.showCenter(false);\n");
    output.append("          } else {\n");
    output.append("            winQWT.showCenter(false);\n");
    output.append("          }\n");
    output.append("      }\n");
    output.append("      observerQWT = { onClose: function(eventName, win) {\n");
    output.append("         if (win == winQWT) {\n");
    output.append("            infowizardqueryopen = false;");
    output.append("         }\n");
    output.append("        }\n");
    output.append("      }\n");
    output.append("      Windows.addObserver(observerQWT);\n");
    output.append("</script>\n");

    output.append("<div id='querywizardinfodiv' style='display:none;'>\n");
    output.append(msgBuilder.getMessageTextFromResource(
            "it/eng/spagobi/commons/presentation/tags/info/querywizardinfo", httpRequest));
    output.append("</div>\n");

    try {
        pageContext.getOut().print(output.toString());
    } catch (Exception ex) {
        logger.error(ex);
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:it.eng.spagobi.commons.presentation.tags.DatasetLovWizardTag.java

public int doStartTag() throws JspException {
    logger.debug("DatasetLovWizardTag::doStartTag:: invoked");
    httpRequest = (HttpServletRequest) pageContext.getRequest();
    requestContainer = ChannelUtilities.getRequestContainer(httpRequest);
    responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    urlBuilder = UrlBuilderFactory.getUrlBuilder();
    msgBuilder = MessageBuilderFactory.getMessageBuilder();
    String datasetLabelField = msgBuilder.getMessage("SBIDev.datasetLovWiz.datasetLabelField", "messages",
            httpRequest);/*from w ww.j av a 2 s. c o  m*/

    currTheme = ThemesManager.getCurrentTheme(requestContainer);
    if (currTheme == null)
        currTheme = ThemesManager.getDefaultTheme();

    RequestContainer aRequestContainer = RequestContainer.getRequestContainer();
    SessionContainer aSessionContainer = aRequestContainer.getSessionContainer();
    SessionContainer permanentSession = aSessionContainer.getPermanentContainer();
    IEngUserProfile userProfile = (IEngUserProfile) permanentSession
            .getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    boolean isable = false;
    try {
        isable = userProfile.isAbleToExecuteAction(SpagoBIConstants.LOVS_MANAGEMENT);
    } catch (EMFInternalError e) {
        e.printStackTrace();
    }
    if (isable) {
        isreadonly = false;
        readonly = "";
        disabled = "";
    }

    StringBuffer output = new StringBuffer();

    output.append("<table width='100%' cellspacing='0' border='0'>\n");
    output.append("   <tr>\n");
    output.append("      <td class='titlebar_level_2_text_section' style='vertical-align:middle;'>\n");
    output.append("         &nbsp;&nbsp;&nbsp;"
            + msgBuilder.getMessage("SBIDev.datasetLovWiz.wizardTitle", "messages", httpRequest) + "\n");
    output.append("      </td>\n");
    output.append("      <td class='titlebar_level_2_empty_section'>&nbsp;</td>\n");
    output.append("      <td class='titlebar_level_2_button_section'>\n");
    output.append(
            "         <a style='text-decoration:none;' href='javascript:opencloseDatasetWizardInfo()'> \n");
    output.append("            <img width='22px' height='22px'\n");
    output.append("                 src='"
            + urlBuilder.getResourceLinkByTheme(httpRequest, "/img/info22.jpg", currTheme) + "'\n");
    output.append("                name='info'\n");
    output.append("                alt='"
            + msgBuilder.getMessage("SBIDev.datasetLovWiz.info", "messages", httpRequest) + "'\n");
    output.append("                title='"
            + msgBuilder.getMessage("SBIDev.datasetLovWiz.info", "messages", httpRequest) + "'/>\n");
    output.append("         </a>\n");
    output.append("      </td>\n");
    String urlImgProfAttr = urlBuilder.getResourceLinkByTheme(httpRequest, "/img/profileAttributes22.jpg",
            currTheme);
    output.append(generateProfAttrTitleSection(urlImgProfAttr));
    output.append("   </tr>\n");
    output.append("</table>\n");

    output.append("<br/>\n");

    output.append("<div class='div_detail_area_forms_lov'>\n");
    output.append("      <div class='div_detail_label_lov'>\n");
    output.append("               <span class='portlet-form-field-label'>\n");
    output.append(msgBuilder.getMessage("SBIDev.datasetLovWiz.datasetLabelField", "messages", httpRequest));
    output.append("               </span>\n");
    output.append("         <span class='portlet-form-field-label'>\n");
    output.append("         </span>\n");
    output.append("      </div>\n");

    output.append("<div class='div_detail_label' id='datasetLabel' >\n");

    output.append("            </div>\n");
    output.append("            \n");
    String url = GeneralUtilities.getSpagoBiHost() + GeneralUtilities.getSpagoBiContext()
            + GeneralUtilities.getSpagoAdapterHttpUrl() + "?" + "PAGE=SelectDatasetLookupPage&NEW_SESSION=TRUE&"
            + LightNavigationManager.LIGHT_NAVIGATOR_DISABLED + "=TRUE";

    String currDataSetLabel = "";
    Integer currDataSetId = null;
    String currDataSetIdValue = "";

    //aggiunto condizione (!getDatasetId().isEmpty())
    if ((getDatasetId() != null) && (!getDatasetId().isEmpty())) {
        currDataSetId = new Integer(getDatasetId());
        currDataSetIdValue = currDataSetId.toString();
        IDataSet dataSet = null;
        try {
            dataSet = DAOFactory.getDataSetDAO().loadActiveIDataSetByID(currDataSetId);
        } catch (EMFUserError e) {
            logger.error("Error Dataset Loading");
            e.printStackTrace();
        }
        if (dataSet != null) {
            currDataSetLabel = dataSet.getLabel();
        }
    }

    output.append("            <div class='div_detail_form' id='datasetForm' >\n");
    output.append("                 <input type='hidden' name='dataset' id='dataset' value='"
            + currDataSetIdValue + "' />   \n");
    output.append("                                    \n");
    output.append(
            "               <input class='portlet-form-input-field' style='width:230px;' type='text'  readonly='readonly'\n");
    output.append("                           name='datasetReadLabel' id='datasetReadLabel' value='"
            + StringEscapeUtils.escapeHtml(currDataSetLabel)
            + "' maxlength='400' onchange='setLovProviderModified(true);' /> \n");
    output.append("            \n");
    output.append("               <a href='javascript:void(0);' id='datasetLink'>\n");
    output.append("                  <img src="
            + urlBuilder.getResourceLinkByTheme(httpRequest, "/img/detail.gif", currTheme)
            + " title='Lookup' alt='Lookup' />\n");
    output.append("               </a>    \n");
    output.append("            </div>\n");
    output.append("         \n");
    output.append("         \n");
    output.append("      <script>\n");
    output.append("         var win_dataset;\n");
    output.append("         Ext.get('datasetLink').on('click', function(){\n");
    output.append("         if(!win_dataset){\n");
    output.append("            win_dataset = new Ext.Window({\n");
    output.append("            id:'popup_dataset',\n");
    output.append("            title:'dataset',\n");
    output.append("            bodyCfg:{\n");
    output.append("               tag:'div', \n");
    output.append("               cls:'x-panel-body', \n");
    output.append("               children:[{tag:'iframe', \n");
    output.append("                        name: 'iframe_par_dataset',   \n");
    output.append("                        id  : 'iframe_par_dataset',  \n");
    output.append("                        src: '" + url + "',  \n");
    output.append("                        frameBorder:0,\n");
    output.append("                        width:'100%',\n");
    output.append("                        height:'100%',\n");
    output.append("                        style: {overflow:'auto'}  \n");
    output.append("                        }]\n");
    output.append("                  },\n");
    output.append("               layout:'fit',\n");
    output.append("               width:800,\n");
    output.append("               height:320,\n");
    output.append("               closeAction:'hide',\n");
    output.append("               plain: true\n");
    output.append("               });\n");
    output.append("               };\n");
    output.append("            win_dataset.show();\n");
    output.append("            }\n");
    output.append("            );\n");
    output.append("            \n");
    output.append("      </script>\n");

    output.append("      </div>\n");

    try {
        pageContext.getOut().print(output.toString());
    } catch (Exception ex) {
        logger.error(ex);
        throw new JspException(ex.getMessage());
    }
    return SKIP_BODY;
}

From source file:de.laures.cewolf.taglib.tags.ChartMapTag.java

private boolean hasLinks() throws JspException {
    if (linkGenerator != null && useJFreeChartLinkGenerator) {
        throw new JspException(
                "Can't have both linkGenerator and useJFreeChartLinkGenerator parameters specified!");
    }/*from  ww  w .ja va 2s  . com*/
    return linkGenerator != null || useJFreeChartLinkGenerator;
}

From source file:net.sf.ginp.tags.TreeMenu.java

/**
 *  Description of the Method./*from www . ja  va2  s .com*/
 *
 *@param  path              Description of the Parameter
 *@exception  JspException  Description of the Exception
 */
final void doNodes(final String path) throws JspException {
    String[] nodes = ModelUtil.getFolderManager().getPicturesInDirectory(model.getCollection(), path);

    if (grid.size() > 0) {
        if (((GridElement) grid.get(grid.size() - 1)).getHtml().equals(gridtee)) {
            ((GridElement) grid.get(grid.size() - 1)).setHtml(gridcont);
        } else {
            ((GridElement) grid.get(grid.size() - 1)).setHtml(gridblank);
        }
    }

    grid.add(new GridElement(gridtee));

    try {
        for (int i = 0; i < nodes.length; i++) {
            if (i == (nodes.length - 1)) {
                if (grid.size() > 0) {
                    ((GridElement) grid.get(grid.size() - 1)).setHtml(gridend);
                }
            }

            pageContext.getOut().write(linestart);

            for (int j = 0; j < grid.size(); j++) {
                pageContext.getOut().write(((GridElement) grid.get(j)).getHtml());
            }

            String filename = nodes[i].substring(0, nodes[i].lastIndexOf("."));

            // if this is a featured picture remove the path.
            if (filename.indexOf("/") != -1) {
                filename = filename.substring(filename.lastIndexOf("/") + 1);
            }

            pageContext.getOut()
                    .write(nodeicon + "<a href=\"" + "ginpservlet?cmd=showpicture&colid="
                            + model.getCurrCollectionId() + "&path=" + path + "&name=" + nodes[i] + "\""
                            + anchorextra + ">" + filename + "</a>" + lineend);
        }
    } catch (IOException ioe) {
        log.error(ioe);
        throw new JspException(ioe.getMessage());
    }

    if (grid.size() > 0) {
        grid.removeElementAt(grid.size() - 1);
    }

    if (grid.size() > 0) {
        ((GridElement) grid.get(grid.size() - 1)).setHtml(gridtee);
    }

    gotMoreNodes = false;
}

From source file:net.sourceforge.fenixedu.presentationTier.TagLib.OptionsTag.java

/**
 * Return an iterator for the option labels or values, based on our
 * configured properties.//from w ww .j  av a  2s  .co  m
 * 
 * @param name
 *            Name of the bean attribute (if any)
 * @param property
 *            Name of the bean property (if any)
 * 
 * @exception JspException
 *                if an error occurs
 */
protected Iterator getIterator(String name, String property) throws JspException {

    // Identify the bean containing our collection
    String beanName = name;
    if (beanName == null) {
        beanName = Constants.BEAN_KEY;
    }
    Object bean = pageContext.findAttribute(beanName);
    if (bean == null) {
        throw new JspException(messages.getMessage("getter.bean", beanName));
    }

    // Identify the collection itself
    Object collection = bean;
    if (property != null) {
        try {
            collection = PropertyUtils.getProperty(bean, property);
            if (collection == null) {
                throw new JspException(messages.getMessage("getter.property", property));
            }
        } catch (IllegalAccessException e) {
            throw new JspException(messages.getMessage("getter.access", property, name));
        } catch (InvocationTargetException e) {
            Throwable t = e.getTargetException();
            throw new JspException(messages.getMessage("getter.result", property, t.toString()));
        } catch (NoSuchMethodException e) {
            throw new JspException(messages.getMessage("getter.method", property, name));
        }
    }

    // Construct and return an appropriate iterator
    if (collection.getClass().isArray()) {
        collection = Arrays.asList((Object[]) collection);
    }
    if (collection instanceof Collection) {
        return (((Collection) collection).iterator());
    } else if (collection instanceof Iterator) {
        return ((Iterator) collection);
    } else if (collection instanceof Map) {
        return (((Map) collection).entrySet().iterator());
    } else if (collection instanceof Enumeration) {
        return (IteratorUtils.asIterator((Enumeration) collection));
    } else {
        throw new JspException(messages.getMessage("optionsTag.iterator", collection.toString()));
    }

}

From source file:it.eng.spagobi.commons.presentation.tags.ScriptWizardTag.java

public int doStartTag() throws JspException {

    httpRequest = (HttpServletRequest) pageContext.getRequest();
    requestContainer = ChannelUtilities.getRequestContainer(httpRequest);
    responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    urlBuilder = UrlBuilderFactory.getUrlBuilder();
    msgBuilder = MessageBuilderFactory.getMessageBuilder();

    currTheme = ThemesManager.getCurrentTheme(requestContainer);
    if (currTheme == null)
        currTheme = ThemesManager.getDefaultTheme();

    TracerSingleton.log(SpagoBIConstants.NAME_MODULE, TracerSingleton.DEBUG,
            "ScriptWizardTag::doStartTag:: invocato");
    RequestContainer aRequestContainer = RequestContainer.getRequestContainer();
    SessionContainer aSessionContainer = aRequestContainer.getSessionContainer();
    SessionContainer permanentSession = aSessionContainer.getPermanentContainer();
    IEngUserProfile userProfile = (IEngUserProfile) permanentSession
            .getAttribute(IEngUserProfile.ENG_USER_PROFILE);
    boolean isable = false;
    try {//from  ww w  .  j  ava2  s.  com
        isable = userProfile.isAbleToExecuteAction(SpagoBIConstants.LOVS_MANAGEMENT);
    } catch (EMFInternalError e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    if (isable) {
        isreadonly = false;
        readonly = "";
        disabled = "";
    }
    StringBuffer output = new StringBuffer();

    String lanuageScriptLabel = msgBuilder.getMessage("SBISet.ListDataSet.languageScript", "messages",
            httpRequest);
    String scriptLabel = msgBuilder.getMessage("SBIDev.scriptWiz.scriptLbl", "messages", httpRequest);

    output.append("<table width='100%' cellspacing='0' border='0'>\n");
    output.append("   <tr>\n");
    output.append("      <td class='titlebar_level_2_text_section' style='vertical-align:middle;'>\n");
    output.append("         &nbsp;&nbsp;&nbsp;"
            + msgBuilder.getMessage("SBIDev.scriptWiz.wizardTitle", "messages", httpRequest) + "\n");
    output.append("      </td>\n");
    output.append("      <td class='titlebar_level_2_empty_section'>&nbsp;</td>\n");
    output.append("      <td class='titlebar_level_2_button_section'>\n");
    output.append(
            "         <a style='text-decoration:none;' href='javascript:opencloseScriptWizardInfo()'> \n");
    output.append("            <img width='22px' height='22px'\n");
    output.append("                 src='"
            + urlBuilder.getResourceLinkByTheme(httpRequest, "/img/info22.jpg", currTheme) + "'\n");
    output.append("                name='info'\n");
    output.append("                alt='"
            + msgBuilder.getMessage("SBIDev.scriptWiz.showSintax", "messages", httpRequest) + "'\n");
    output.append("                title='"
            + msgBuilder.getMessage("SBIDev.scriptWiz.showSintax", "messages", httpRequest) + "'/>\n");
    output.append("         </a>\n");
    output.append("      </td>\n");
    String urlImgProfAttr = urlBuilder.getResourceLinkByTheme(httpRequest, "/img/profileAttributes22.jpg",
            currTheme);
    output.append(generateProfAttrTitleSection(urlImgProfAttr));
    output.append("   </tr>\n");
    output.append("</table>\n");

    output.append("<br/>\n");

    output.append("<div class='div_detail_area_forms_lov'>\n");

    //LANGUAGE SCRIPT COMBO      

    output.append("      <div class='div_detail_label_lov'>\n");
    output.append("         <span class='portlet-form-field-label'>\n");
    output.append(lanuageScriptLabel);
    output.append("         </span>\n");
    output.append("      </div>\n");
    output.append("      <div class='div_detail_form'>\n");
    output.append(
            "         <select  style='width:180px;' class='portlet-form-input-field' name='LANGUAGESCRIPT' id='LANGUAGESCRIPT' >\n");

    String selected = "";
    try {

        List scriptLanguageList = DAOFactory.getDomainDAO().loadListDomainsByType(DataSetConstants.SCRIPT_TYPE);
        if (scriptLanguageList != null) {
            for (int i = 0; i < scriptLanguageList.size(); i++) {
                Domain domain = (Domain) scriptLanguageList.get(i);
                String name = domain.getValueName();
                name = StringEscapeUtils.escapeHtml(name);
                String value = domain.getValueCd();
                value = StringEscapeUtils.escapeHtml(value);
                if (languageScript.equalsIgnoreCase(value)) {
                    selected = "selected='selected'";
                }
                output.append("<option value='" + value + "' label='" + value + "' " + selected + ">");
                output.append(name);
                output.append("</option>");
            }
        }
    } catch (Throwable e) {
        e.printStackTrace();
    }

    /*
    Map engineNames=ScriptUtilities.getEngineFactoriesNames();
    for(Iterator it=engineNames.keySet().iterator();it.hasNext();){
       String engName=(String)it.next(); 
       String alias=(String)engineNames.get(engName);
       alias = StringEscapeUtils.escapeHtml(alias);
       selected="";
       if(languageScript.equalsIgnoreCase(alias)){
            
    selected="selected='selected'";
       }      
       String aliasName=ScriptUtilities.bindAliasEngine(alias);
            
       output.append("<option value='"+alias+"' label='"+alias+"' "+selected+">");
       output.append(aliasName);   
       output.append("</option>");
    }
    */

    output.append("</select>");
    output.append("</div>");

    // FINE LANGUAGE SCRIPT

    output.append("      <div class='div_detail_label_lov'>\n");
    output.append("         <span class='portlet-form-field-label'>\n");
    output.append(scriptLabel);
    output.append("         </span>\n");
    output.append("      </div>\n");
    output.append("      <div style='height:110px;' class='div_detail_form'>\n");
    output.append("         <textarea style='height:100px;'  " + disabled
            + " class='portlet-text-area-field' name='SCRIPT' onchange='setLovProviderModified(true);'  cols='50'>"
            + script + "</textarea>\n");
    output.append("      </div>\n");
    output.append("      <div class='div_detail_label_lov'>\n");
    output.append("         &nbsp;\n");
    output.append("      </div>\n");

    // fine DETAIL AREA FORMS
    output.append("</div>\n");

    output.append("<script>\n");
    output.append("      var infowizardscriptopen = false;\n");
    output.append("      var winSWT = null;\n");
    output.append("      function opencloseScriptWizardInfo() {\n");
    output.append("         if(!infowizardscriptopen){\n");
    output.append("            infowizardscriptopen = true;");
    output.append("            openScriptWizardInfo();\n");
    output.append("         }\n");
    output.append("      }\n");
    output.append("      function openScriptWizardInfo(){\n");
    output.append("         if(winSWT==null) {\n");
    output.append("            winSWT = new Window('winSWTInfo', {className: \"alphacube\", title:\""
            + msgBuilder.getMessage("SBIDev.scriptWiz.showSintax", "messages", httpRequest)
            + "\",width:680, height:150, destroyOnClose: false});\n");
    output.append("            winSWT.setContent('scriptwizardinfodiv', true, false);\n");
    output.append("            winSWT.showCenter(false);\n");
    output.append("            winSWT.setLocation(40,50);\n");
    output.append("          } else {\n");
    output.append("            winSWT.showCenter(false);\n");
    output.append("          }\n");
    output.append("      }\n");
    output.append("      observerSWT = { onClose: function(eventName, win) {\n");
    output.append("         if (win == winSWT) {\n");
    output.append("            infowizardscriptopen = false;");
    output.append("         }\n");
    output.append("        }\n");
    output.append("      }\n");
    output.append("      Windows.addObserver(observerSWT);\n");
    output.append("</script>\n");

    output.append("<div id='scriptwizardinfodiv' style='display:none;'>\n");
    output.append(msgBuilder.getMessageTextFromResource(
            "it/eng/spagobi/commons/presentation/tags/info/scriptwizardinfo", httpRequest));
    output.append("</div>\n");

    try {
        pageContext.getOut().print(output.toString());
    } catch (Exception ex) {
        TracerSingleton.log(Constants.NOME_MODULO, TracerSingleton.CRITICAL, "ScriptWizardTag::doStartTag::",
                ex);
        throw new JspException(ex.getMessage());
    }

    return SKIP_BODY;
}