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

📄 cmstabdialog.java

📁 cms是开源的框架
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
                result.append("</a></td>\n");
                lineRow.append("\t<td class=\"dialogtabrow\"></td>\n");
            }

            counter++;
        }
        result.append("\t<td class=\"maxwidth\"></td>\n");
        result.append("</tr>\n");
        result.append("<tr>\n");
        result.append(lineRow);
        result.append("\t<td class=\"dialogtabrow\"></td>\n");
        result.append("</tr>\n");
        result.append("</table>\n");
        return result.toString();
    }

    /**
     * Returns the number of the currently active tab depending on the request parameter.<p>
     * 
     * This method has to be called once in initWorkplaceRequestValues after filling the request parameters.<p>
     * 
     * @return the number of the currently active tab
     */
    public int getActiveTab() {

        if (m_activeTab < 0) {
            String paramTab = getParamTab();
            int tab = 1;
            if (CmsStringUtil.isNotEmpty(paramTab)) {
                try {
                    tab = Integer.parseInt(paramTab);
                } catch (NumberFormatException e) {
                    // do nothing, the first tab is returned
                    if (LOG.isInfoEnabled()) {
                        LOG.info(e.getLocalizedMessage());
                    }
                }
            }
            setParamTab("" + tab);
            m_activeTab = tab;
            return tab;
        } else {
            return m_activeTab;
        }
    }

    /**
     * Returns the localized name of the currently active tab.<p>
     * 
     * @return the localized name of the currently active tab or null if no tab name was found
     */
    public String getActiveTabName() {

        if (m_activeTab < 0) {
            getActiveTab();
        }
        List tabNames = getTabs();
        try {
            return (String)tabNames.get(m_activeTab - 1);
        } catch (IndexOutOfBoundsException e) {
            // should usually never happen
            if (LOG.isInfoEnabled()) {
                LOG.info(e.getLocalizedMessage());
            }
            return null;
        }
    }

    /**
     * Returns the value of the setpressed parameter.<p>
     * 
     * @return the value of the setpressed parameter
     */
    public String getParamSetPressed() {

        return m_paramSetPressed;
    }

    /**
     * Returns the value of the tab parameter.<p>
     * 
     * @return the value of the tab parameter
     */
    public String getParamTab() {

        return m_paramTab;
    }

    /**
     * Returns the order of the parameter prefixes for each tab.<p>
     * 
     * For example, all parameters stored in tab 1 have the prefix "Tab1", i.e.
     * the getter and setter methods must be getParam<b>Tab1</b>MyParameterName().<p>
     * 
     * To change the tab order, simply change the order in the String array 
     * and in the generated tab list.<p> 
     * 
     * @return the ordered parameter prefix List
     * @see org.opencms.workplace.CmsTabDialog#getTabs()
     */
    public abstract List getTabParameterOrder();

    /**
     * Returns a list with localized Strings representing the names of the tabs.<p>
     * 
     * @return list with localized String for the tabs
     */
    public abstract List getTabs();

    /**
     * Builds the start html of the page, including setting of DOCTYPE and 
     * inserting a header with the content-type.<p>
     * 
     * This overloads the default method of the parent class.<p>
     * 
     * @return the start html of the page
     */
    public String htmlStart() {

        return htmlStart(null);
    }

    /**
     * Builds the start html of the page, including setting of DOCTYPE and 
     * inserting a header with the content-type.<p>
     * 
     * This overloads the default method of the parent class.<p>
     * 
     * @param helpUrl the key for the online help to include on the page
     * @return the start html of the page
     */
    public String htmlStart(String helpUrl) {

        String stylesheet = null;
        if (isPopup()) {
            stylesheet = "popup.css";
        }
        StringBuffer result = new StringBuffer(super.pageHtmlStyle(HTML_START, null, stylesheet));
        if (getSettings().isViewExplorer()) {
            result.append("<script type=\"text/javascript\" src=\"");
            result.append(getSkinUri());
            result.append("commons/explorer.js\"></script>\n");
        }
        result.append("<script type=\"text/javascript\">\n");
        if (helpUrl != null) {
            result.append("top.head.helpUrl=\"");
            result.append(helpUrl + "\";\n");

        }
        // js to switch the dialog tabs
        result.append("function openTab(tabValue) {\n");
        result.append("\tdocument.forms[0]." + PARAM_TAB + ".value = tabValue;\n");
        result.append("\tdocument.forms[0]." + PARAM_ACTION + ".value = \"" + DIALOG_SWITCHTAB + "\";\n");
        result.append("\tdocument.forms[0].submit();\n");
        result.append("}\n");
        // js for the button actions, overwrites CmsDialog.dialogScriptSubmit() js method
        result.append("function submitAction(actionValue, theForm, formName) {\n");
        result.append("\tif (theForm == null) {\n");
        result.append("\t\ttheForm = document.forms[formName];\n");
        result.append("\t}\n");
        result.append("\ttheForm." + PARAM_FRAMENAME + ".value = window.name;\n");
        result.append("\tif (actionValue == \"" + DIALOG_SET + "\") {\n");
        result.append("\t\ttheForm." + PARAM_ACTION + ".value = \"" + DIALOG_SET + "\";\n");
        result.append("\t} else if (actionValue == \"" + DIALOG_CANCEL + "\") {\n");
        result.append("\t\ttheForm." + PARAM_ACTION + ".value = \"" + DIALOG_CANCEL + "\";\n");
        result.append("\t}\n");
        result.append("\ttheForm.submit();\n");
        result.append("\treturn false;\n");
        result.append("}\n");
        result.append("//-->\n</script>\n");
        return result.toString();
    }

    /**
     * Returns all initialized parameters of the current workplace class 
     * as hidden field tags that can be inserted in a form.<p>
     * 
     * This overwrites the method in CmsWorkplace because for each tab, 
     * only the hidden parameters of the non displayed tabs are added.<p> 
     * 
     * @return all initialized parameters of the current workplace class
     * as hidden field tags that can be inserted in a html form
     */
    public String paramsAsHidden() {

        StringBuffer result = new StringBuffer(512);
        String activeTab = (String)getTabParameterOrder().get(getActiveTab() - 1);
        Map params = paramValues();
        Iterator i = params.keySet().iterator();
        while (i.hasNext()) {
            String param = (String)i.next();
            if (!param.startsWith(activeTab)) {
                // add only parameters which are not displayed in currently active tab
                Object value = params.get(param);
                result.append("<input type=\"hidden\" name=\"");
                result.append(param);
                result.append("\" value=\"");
                result.append(CmsEncoder.encode(value.toString(), getCms().getRequestContext().getEncoding()));
                result.append("\">\n");
            }
        }
        return result.toString();
    }

    /**
     * Sets the value of the setpressed parameter.<p>
     * 
     * @param value the value to set
     */
    public void setParamSetPressed(String value) {

        m_paramSetPressed = value;
    }

    /**
     * Sets the value of the tab parameter.<p>
     * 
     * @param value the value to set
     */
    public void setParamTab(String value) {

        m_paramTab = value;
    }

}

⌨️ 快捷键说明

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