⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 a_cmslistdialog.java

📁 一个cms内容管理平台
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
     * @throws IOException if writing to the JSP out fails, or in case of errros forwarding to the required result page
     * @throws ServletException in case of errros forwarding to the required result page
     */
    public void displayDialog(boolean writeLater) throws JspException, IOException, ServletException {

        actionDialog();
        if (writeLater) {
            return;
        }
        writeDialog();
    }

    /**
     * This method execute the default actions for searching, sorting and paging.<p>
     */
    public void executeDefaultActions() {

        switch (getAction()) {

            case ACTION_LIST_SEARCH:
                executeSearch();
                break;
            case ACTION_LIST_SORT:
                executeSort();
                break;
            case ACTION_LIST_SELECT_PAGE:
                executeSelectPage();
                break;
            default:
        //noop
        }
        listSave();
    }

    /**
     * This method should handle the default list independent actions,
     * by comparing <code>{@link #getParamListAction()}</code> with the id 
     * of the action to execute.<p> 
     * 
     * if you want to handle additional independent actions, override this method,
     * handling your actions and FINALLY calling <code>super.executeListIndepActions();</code>.<p> 
     */
    public void executeListIndepActions() {

        if (getList().getMetadata().getItemDetailDefinition(getParamListAction()) != null) {
            // toogle item details
            getList().getMetadata().toogleDetailState(getParamListAction());
            // lazzy initialization
            initializeDetail(getParamListAction());
        }
        listSave();
    }

    /**
     * This method should handle every defined list multi action,
     * by comparing <code>{@link #getParamListAction()}</code> with the id 
     * of the action to execute.<p> 
     *
     * @throws IOException in case of errors when including a required sub-element
     * @throws ServletException in case of errors when including a required sub-element
     * @throws CmsRuntimeException to signal that an action is not supported
     */
    public abstract void executeListMultiActions() throws IOException, ServletException, CmsRuntimeException;

    /**
     * This method should handle every defined list single action,
     * by comparing <code>{@link #getParamListAction()}</code> with the id 
     * of the action to execute.<p> 
     * 
     * @throws IOException in case of errors when including a required sub-element
     * @throws ServletException in case of errors when including a required sub-element
     * @throws CmsRuntimeException to signal that an action is not supported
     */
    public abstract void executeListSingleActions() throws IOException, ServletException, CmsRuntimeException;

    /**
     * Returns the list.<p>
     *
     * @return the list
     */
    public CmsHtmlList getList() {

        if (m_list != null && m_list.getMetadata() == null) {
            m_list.setMetadata(getMetadata(getClass().getName(), m_list.getId()));
        }
        return m_list;
    }

    /**
     * Returns the Id of the list.<p>
     *
     * @return the list Id
     */
    public final String getListId() {

        return m_listId;
    }

    /**
     * Returns the form name.<p>
     *
     * @return the form name
     */
    public String getParamFormName() {

        return m_paramFormName;
    }

    /**
     * Returns the List Action.<p>
     *
     * @return the List Action
     */
    public String getParamListAction() {

        return m_paramListAction;
    }

    /**
     * Returns the current Page.<p>
     *
     * @return the current Page
     */
    public String getParamPage() {

        return m_paramPage;
    }

    /**
     * Returns the Search Filter.<p>
     *
     * @return the Search Filter
     */
    public String getParamSearchFilter() {

        return m_paramSearchFilter;
    }

    /**
     * Returns the Selected Items.<p>
     *
     * @return the Selelected Items
     */
    public String getParamSelItems() {

        return m_paramSelItems;
    }

    /**
     * Returns the sorted Column.<p>
     *
     * @return the sorted Column
     */
    public String getParamSortCol() {

        return m_paramSortCol;
    }

    /**
     * Returns the current selected item.<p>
     * 
     * @return the current selected item
     */
    public CmsListItem getSelectedItem() {

        try {
            return getList().getItem(
                CmsStringUtil.splitAsArray(getParamSelItems(), CmsHtmlList.ITEM_SEPARATOR)[0].trim());
        } catch (Exception e) {
            return null;
        }
    }

    /**
     * Returns a list of current selected items.<p>
     * 
     * @return a list of current selected items
     */
    public List getSelectedItems() {

        Iterator it = CmsStringUtil.splitAsList(getParamSelItems(), CmsHtmlList.ITEM_SEPARATOR, true).iterator();
        List items = new ArrayList();
        while (it.hasNext()) {
            String id = (String)it.next();
            items.add(getList().getItem(id));
        }
        return items;
    }

    /**
     * Returns the activation flag.<p>
     *
     * Useful for dialogs with several lists.<p>
     * 
     * Is <code></code> if the original <code>formname</code> parameter 
     * is equals to <code>${listId}-form</code>.<p>
     * 
     * @return the activation flag
     */
    public boolean isActive() {

        return m_active;
    }

    /**
     * This method re-read the rows of the list, the user should call this method after executing an action
     * that add or remove rows to the list. 
     */
    public synchronized void refreshList() {

        if (getList() == null) {
            return;
        }
        CmsListState ls = getList().getState();
        getList().clear(getLocale());
        fillList();
        getList().setState(ls, getLocale());
        listSave();
    }

    /**
     * Removes the list from the workplace settings.<p>
     * 
     * Next time the list is displayed the list will be reloaded.<p>
     */
    public void removeList() {

        setList(null);
        listSave();
    }

    /**
     * Sets the list.<p>
     *
     * @param list the list to set
     */
    public void setList(CmsHtmlList list) {

        m_list = list;
    }

    /**
     * Stores the given object as "list object" for the given list dialog in the current users session.<p> 
     * 
     * @param listDialog the list dialog class
     * @param listObject the list to store
     */
    public void setListObject(Class listDialog, CmsHtmlList listObject) {

        if (listObject == null) {
            // null object: remove the entry from the map
            getListObjectMap(getSettings()).remove(listDialog.getName());
        } else {
            if (listObject.getMetadata() != null && listObject.getMetadata().isVolatile()) {
                listObject.setMetadata(null);
            }
            getListObjectMap(getSettings()).put(listDialog.getName(), listObject);
        }
    }

    /**
     * Sets the form name.<p>
     *
     * @param formName the form name to set
     */
    public void setParamFormName(String formName) {

        m_paramFormName = formName;
    }

    /**
     * Sets the List Action.<p>
     *
     * @param listAction the list Action to set
     */
    public void setParamListAction(String listAction) {

        m_paramListAction = listAction;
    }

    /**
     * Sets the current Page.<p>
     *
     * @param page the current Page to set
     */
    public void setParamPage(String page) {

        m_paramPage = page;
    }

    /**
     * Sets the Search Filter.<p>
     *
     * @param searchFilter the Search Filter to set
     */
    public void setParamSearchFilter(String searchFilter) {

        m_paramSearchFilter = searchFilter;
    }

    /**
     * Sets the Selelected Items.<p>
     *
     * @param paramSelItems the Selelected Items to set
     */
    public void setParamSelItems(String paramSelItems) {

        m_paramSelItems = paramSelItems;
    }

    /**
     * Sets the sorted Column.<p>
     *
     * @param sortCol the sorted Column to set
     */
    public void setParamSortCol(String sortCol) {

        m_paramSortCol = sortCol;
    }

    /**
     * Writes the dialog html code, only if the <code>{@link #ACTION_DEFAULT}</code> is set.<p>
     * 
     * @throws IOException if writing to the JSP out fails, or in case of errros forwarding to the required result page
     */
    public void writeDialog() throws IOException {

        if (isForwarded()) {
            return;
        }
        JspWriter out = getJsp().getJspContext().getOut();
        out.print(defaultActionHtml());
    }

    /**
     * Can be overwritten to add some code after the list.<p>
     * 
     * @return custom html code
     */
    protected String customHtmlEnd() {

⌨️ 快捷键说明

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