cmsjsptagcontentload.java

来自「找了很久才找到到源代码」· Java 代码 · 共 918 行 · 第 1/3 页

JAVA
918
字号

            result = collectorResult.subList(startIndex, endIndex);
        } else {

            result = collectorResult;
            if (collectorResult.size() > 0) {
                contentInfoBean.setPageCount(1);
            }
        }

        return result;
    }

    /**
     * @see javax.servlet.jsp.tagext.BodyTagSupport#doAfterBody()
     */
    public int doAfterBody() throws JspException {

        // close open direct edit first
        if (hasMoreContent()) {
            // another loop is required
            return EVAL_BODY_AGAIN;
        }
        // need to release manually, JSP container may not call release as required (happens with Tomcat)
        release();
        // no more files are available, so skip the body and finish the loop
        return SKIP_BODY;
    }

    /**
     * @see javax.servlet.jsp.tagext.Tag#doEndTag()
     */
    public int doEndTag() {

        // need to release manually, JSP container may not call release as required (happens with Tomcat)
        release();
        return EVAL_PAGE;
    }

    /**
     * @see javax.servlet.jsp.tagext.Tag#doStartTag()
     */
    public int doStartTag() throws JspException, CmsIllegalArgumentException {

        // get a reference to the parent "content container" class (if available)
        Tag ancestor = findAncestorWithClass(this, I_CmsXmlContentContainer.class);
        I_CmsXmlContentContainer container = null;
        if (ancestor != null) {
            // parent content container available, use preloaded values from this container
            container = (I_CmsXmlContentContainer)ancestor;
            // check if container really is a preloader
            if (!container.isPreloader()) {
                // don't use ancestor if not a preloader
                container = null;
            }
        }

        // initialize the content load tag
        init(container);

        hasMoreContent();

        return isScopeVarSet() ? SKIP_BODY : EVAL_BODY_INCLUDE;
    }

    /**
     * Returns the collector.<p>
     *
     * @return the collector
     */
    public String getCollector() {

        return m_collector;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#getCollectorName()
     */
    public String getCollectorName() {

        return m_collectorName;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#getCollectorParam()
     */
    public String getCollectorParam() {

        return m_collectorParam;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#getCollectorResult()
     */
    public List getCollectorResult() {

        return m_collectorResult;
    }

    /**
     * Returns the editable flag.<p>
     * 
     * @return the editable flag
     */
    public String getEditable() {

        return m_directEditMode != null ? m_directEditMode.toString() : "";
    }

    /**
     * Returns the locale.<p>
     *
     * @return the locale
     */
    public String getLocale() {

        return (m_locale != null) ? m_locale.toString() : "";
    }

    /**
     * Returns the index of the page to be displayed.<p>
     * 
     * @return the index of the page to be displayed
     */
    public String getPageIndex() {

        return m_pageIndex;
    }

    /**
     * Returns the number of page links in the Google-like page navigation.<p>
     * 
     * @return the number of page links in the Google-like page navigation
     */
    public String getPageNavLength() {

        return m_pageNavLength;
    }

    /**
     * Returns the size of a single page to be displayed.<p>
     * 
     * @return the size of a single page to be displayed
     */
    public String getPageSize() {

        return m_pageSize;
    }

    /**
     * Returns the collector parameter.<p>
     *
     * @return the collector parameter
     */
    public String getParam() {

        return m_param;
    }

    /**
     * Returns <code>"true"</code> if this content load tag should only preload the values from the collector.<p>
     * 
     * @return <code>"true"</code> if this content load tag should only preload the values from the collector
     */
    public String getPreload() {

        return String.valueOf(isPreloader());
    }

    /**
     * Returns the property.<p>
     *
     * @return the property
     */
    public String getProperty() {

        return m_property;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#getResourceName()
     */
    public String getResourceName() {

        return m_resourceName;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#getXmlDocument()
     */
    public I_CmsXmlDocument getXmlDocument() {

        return m_content;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#getXmlDocumentElement()
     */
    public String getXmlDocumentElement() {

        // value must be set in "loop" or "show" class
        return null;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#getXmlDocumentLocale()
     */
    public Locale getXmlDocumentLocale() {

        return m_contentLocale;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#hasMoreContent()
     */
    public boolean hasMoreContent() throws JspException {

        if (m_isFirstLoop) {
            m_isFirstLoop = false;
        } else {
            if (m_directEditOpen) {
                // last element was direct editable, close it
                CmsJspTagEditable.endDirectEdit(pageContext);
                m_directEditOpen = false;
            }
        }

        if (isPreloader()) {
            // if in preload mode, no result is required            
            return false;
        }

        // check if there are more files to iterate
        boolean hasMoreContent = m_collectorResult.size() > 0;
        if (hasMoreContent) {
            // there are more results available...
            try {
                doLoadNextFile();
            } catch (CmsException e) {
                m_controller.setThrowable(e, m_resourceName);
                throw new JspException(e);
            }

            // check "direct edit" support
            if (m_directEditMode.isEnabled() && (m_resourceName != null)) {

                // check options for first element
                CmsDirectEditButtonSelection directEditButtons;
                if (m_directEditFollowButtons == null) {
                    // this is the first call, calculate the options
                    if (m_directEditLinkForNew == null) {
                        // if create link is null, show only "edit" button for first element
                        directEditButtons = CmsDirectEditButtonSelection.EDIT;
                        // also show only the "edit" button for 2nd to last element
                        m_directEditFollowButtons = directEditButtons;
                    } else {
                        // if create link is not null, show "edit", "delete" and "new" button for first element
                        directEditButtons = CmsDirectEditButtonSelection.EDIT_DELETE_NEW;
                        // show "edit" and "delete" button for 2nd to last element
                        m_directEditFollowButtons = CmsDirectEditButtonSelection.EDIT_DELETE;
                    }
                } else {
                    // re-use pre calculated options
                    directEditButtons = m_directEditFollowButtons;
                }

                m_directEditOpen = CmsJspTagEditable.startDirectEdit(pageContext, new CmsDirectEditParams(
                    m_resourceName,
                    directEditButtons,
                    m_directEditMode,
                    m_directEditLinkForNew));
            }

        } else {
            // no more results in the collector, reset locale (just to make sure...)
            m_locale = null;
        }

        return hasMoreContent;
    }

    /**
     * @see org.opencms.jsp.I_CmsXmlContentContainer#isPreloader()
     */
    public boolean isPreloader() {

        return isScopeVarSet() ? true : m_preload;
    }

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

        m_cms = null;
        m_collector = null;
        m_collectorName = null;
        m_collectorParam = null;
        m_collectorResult = null;
        m_content = null;
        m_contentInfoBean = null;
        m_contentLocale = null;
        m_controller = null;
        m_directEditLinkForNew = null;
        m_directEditFollowButtons = null;
        m_directEditOpen = false;

⌨️ 快捷键说明

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