/* (non-Javadoc)
  * @see it.eng.spago.presentation.PublisherDispatcherIFace#getPublisherName(it.eng.spago.base.RequestContainer, it.eng.spago.base.ResponseContainer)
  */
 public String getPublisherName(
     RequestContainer requestContainer, ResponseContainer responseContainer) {
   // get the module response
   SourceBean moduleResponse =
       (SourceBean)
           responseContainer.getServiceResponse().getAttribute("SelectParameterPageModule");
   // return publisher
   return getPublisherName(requestContainer, responseContainer, moduleResponse);
 }
  /**
   * Starting tag.
   *
   * @return the int
   * @throws JspException the jsp exception
   */
  public int doStartTag() throws JspException {
    httpRequest = (HttpServletRequest) pageContext.getRequest();
    RequestContainer requestContainer = ChannelUtilities.getRequestContainer(httpRequest);
    ResponseContainer responseContainer = ChannelUtilities.getResponseContainer(httpRequest);
    SourceBean serviceRequest = requestContainer.getServiceRequest();
    SourceBean serviceResponse = responseContainer.getServiceResponse();
    SourceBean moduleResponse = (SourceBean) serviceResponse.getAttribute(moduleName);

    List functionalitiesList = null;
    if (attributeToRender == null || attributeToRender.trim().equals("")) {
      functionalitiesList =
          (List) moduleResponse.getAttribute(SpagoBIConstants.FUNCTIONALITIES_LIST);
    } else {
      functionalitiesList = (List) moduleResponse.getAttribute(attributeToRender);
    }
    String initialPath = (String) moduleResponse.getAttribute(TreeObjectsModule.PATH_SUBTREE);
    ITreeHtmlGenerator gen = null;
    try {
      gen = (ITreeHtmlGenerator) Class.forName(htmlGeneratorClass).newInstance();
    } catch (Exception e) {
      return -1;
    }

    StringBuffer htmlStream = null;
    if (treeName == null) {
      htmlStream = gen.makeTree(functionalitiesList, httpRequest, initialPath);
    } else {
      htmlStream = gen.makeTree(functionalitiesList, httpRequest, initialPath, treeName);
    }

    try {
      pageContext.getOut().print(htmlStream);
    } catch (IOException ioe) {
      SpagoBITracer.major(
          SpagoBIConstants.NAME_MODULE,
          this.getClass().getName(),
          "doStartTag",
          "cannot start object tree tag: IOexception occurred",
          ioe);
    }
    return SKIP_BODY;
  }
  /**
   * Do start tag.
   *
   * @return the int
   * @throws JspException the jsp exception
   * @see it.eng.spagobi.commons.presentation.tags.CheckListTag#doStartTag()
   */
  public int doStartTag() throws JspException {
    SpagoBITracer.info("Admintools", "ListTag", "doStartTag", " method invoked");
    httpRequest = (HttpServletRequest) pageContext.getRequest();
    renderResponse = (RenderResponse) httpRequest.getAttribute("javax.portlet.response");
    renderRequest = (RenderRequest) httpRequest.getAttribute("javax.portlet.request");

    _requestContainer = RequestContainerPortletAccess.getRequestContainer(httpRequest);
    portReq = PortletUtilities.getPortletRequest();
    _serviceRequest = _requestContainer.getServiceRequest();
    _responseContainer = ResponseContainerPortletAccess.getResponseContainer(httpRequest);

    msgBuilder = MessageBuilderFactory.getMessageBuilder();
    if (_bundle == null) _bundle = "messages";

    _session = _requestContainer.getSessionContainer();

    _serviceResponse = _responseContainer.getServiceResponse();
    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;
      SpagoBITracer.debug("Admintools", "ListTag", "doStartTag", " Module Name: " + _moduleName);
      _content = (SourceBean) _serviceResponse.getAttribute(_moduleName);
      SourceBean moduleBean =
          (SourceBean)
              configure.getFilteredSourceBeanAttribute("MODULES.MODULE", "NAME", _moduleName);

      if (moduleBean != null)
        SpagoBITracer.debug(
            "Admintools", "ListTag", "doStartTag", _moduleName + " 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");
      SpagoBITracer.debug("Admintools", "ListTag", "doStartTag", " PAGE: " + pageName);
      _providerURL = "PAGE=" + pageName + "&MODULE=" + _moduleName + "&";
      _providerUrlMap.put("PAGE", pageName);
      _providerUrlMap.put("MODULE", _moduleName);
      HashMap params = (HashMap) _serviceResponse.getAttribute(_moduleName + ".PARAMETERS_MAP");
      if (params != null) {
        _paramsMap = params;
        _providerUrlMap.putAll(_paramsMap);
      }
    } // if (_moduleName != null)
    else {
      SpagoBITracer.critical("Admintools", "ListTag", "doStartTag", "service name not specified");
      throw new JspException("Business name not specified !");
    } // if (_content == null)
    if (_content == null) {
      SpagoBITracer.warning("Admintools", "ListTag", "doStartTag", "list content null");
      return SKIP_BODY;
    } // if (_content == null)
    if (_layout == null) {
      SpagoBITracer.warning(
          "Admintools", "ListTag", "doStartTag", "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);
    }
    _htmlStream = new StringBuffer();

    PortletURL url = renderResponse.createActionURL();
    url.setParameter("PAGE", "DetailBIObjectPage");
    url.setParameter("MESSAGEDET", "RETURN_FROM_SUBREPORTS_LOOKUP");
    url.setParameter("LIGHT_NAVIGATOR_DISABLED", "true");

    _htmlStream.append(" <form method='POST' action='" + url.toString() + "'>\n");
    makeForm();
    _htmlStream.append(" </form>\n");
    try {
      pageContext.getOut().print(_htmlStream);
    } // try
    catch (Exception ex) {
      SpagoBITracer.critical(
          "Admintools", "ListTag", "doStartTag", "Impossible to send the stream");
      throw new JspException("Impossible to send the stream");
    } // catch (Exception ex)
    return SKIP_BODY;
  } // public int doStartTag() throws JspException