absolutecontainerlisttag.java

来自「java 写的一个新闻发布系统」· Java 代码 · 共 96 行

JAVA
96
字号
package org.jahia.taglibs.container;import org.jahia.data.JahiaData;import org.jahia.data.containers.JahiaContainerList;import org.jahia.exceptions.JahiaException;import org.jahia.utils.JahiaConsole;/** * Class AbsoluteContainerListTag : extends class ContainerListTag * * An absolute container list is declared on a page and can be used on any page * * @author  Jerome Tamiotti */public class AbsoluteContainerListTag extends ContainerListTag {    private int pageId = -1;    private int pageLevel = -1;    private int windowSize = -1;    private int windowOffset = -1;    public void setPageId(String pageId) {        try {            this.pageId = Integer.parseInt(pageId);        } catch (NumberFormatException nfe) {            JahiaConsole.println("AbsoluteContainerListTag: setPageId", "The given page id is not a number");        }    }    public void setPageLevel(String pageLevel) {        try {            this.pageLevel = Integer.parseInt(pageLevel);        } catch (NumberFormatException nfe) {            JahiaConsole.println("AbsoluteContainerListTag: setPageLevel", "The given page level is not a number");        }    }    public void setWindowSize(String windowSize) {        try {            this.windowSize = Integer.parseInt(windowSize);        } catch (NumberFormatException nfe) {            this.windowSize = -1;        }    }    /*    public int getWindowSize() {        return this.windowSize;    }    */    public void setWindowOffset(String windowOffset) {        try {            this.windowOffset = Integer.parseInt(windowOffset);        } catch (NumberFormatException nfe) {            this.windowOffset = -1;        }    }    /*    public int getWindowOffset() {        return this.windowOffset;    }    */    protected void checkAttributes(JahiaData jData) throws JahiaException {        if (this.pageId == -1) {            // check for page level            if (this.pageLevel != -1) {                this.pageId = jData.gui().getLevelID(this.pageLevel);                if (this.pageId == -1) {                    JahiaConsole.println("AbsoluteContainerListTag.checkAttributes",                                         "Couldn't find pageID for pageLevel=" + this.pageLevel);                }            }        }    }    protected void checkDeclaration(JahiaData jData) throws JahiaException {        if ( jData.page().getID()== this.pageId ) {            jData.containers().declareContainer(super.getName(), super.getTitle(), super.getFields(), this.windowSize, this.windowOffset);        }    }    // redefines only the method allowing to read the container list    // reads the container list from a container set    protected JahiaContainerList getContainerList( JahiaData jData, String listName ) throws JahiaException {        return jData.containers().getAbsoluteContainerList( listName, this.pageId );    }}

⌨️ 快捷键说明

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