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

📄 setup3.jsp

📁 java开发的一套非常好用的oa系统
💻 JSP
📖 第 1 页 / 共 2 页
字号:
<%
/**
 * $RCSfile: setup3.jsp,v $
 * $Revision: 1.1.1.1 $
 * $Date: 2002/09/09 13:50:32 $
 *
 * Copyright (C) 1999-2001 CoolServlets, Inc. All rights reserved.
 *
 * This software is the proprietary information of CoolServlets, Inc.
 * Use is subject to license terms.
 */
%>

<%@ page import="java.io.*,
                 java.lang.reflect.*,
                 java.util.*,
                 java.sql.*,
                 java.beans.*,
                 com.jivesoftware.forum.*,
                 com.jivesoftware.forum.util.*,
                 com.jivesoftware.forum.database.*"%>

<%! // global methods/classes/variables

    /**
     * A helper class for comparing PropertyDescriptor objects.
     */
    class PropertyDescriptorComparator implements Comparator {
        public static final int NAME = 1;
        public static final int DISPLAY_NAME = 2;
        public static final int CLASS_NAME = 3;
        public static final int SORT_ORDER = 4;
        private int field = NAME;

        public PropertyDescriptorComparator(int field) {
            this.field = field;
        }
        public int compare(Object obj1, Object obj2) {
            PropertyDescriptor pd1 = (PropertyDescriptor)obj1;
            PropertyDescriptor pd2 = (PropertyDescriptor)obj2;
            if (field == NAME) {
                return (pd1.getName().compareTo(pd2.getName()));
            }
            else if (field == DISPLAY_NAME) {
                return (pd1.getDisplayName().compareTo(pd2.getDisplayName()));
            }
            else if (field == CLASS_NAME) {
                String pd1Classname = pd1.getClass().getName();
                String pd2Classname = pd2.getClass().getName();
                return (pd1Classname.compareTo(pd2Classname));
            }
            else {
                return 0;
            }
        }
        public boolean equals(Object obj) {
            return true;
        }
    }

    /**
     *
     */
    private static final String getHTML(HttpServletRequest request,
            ConnectionProvider conProvider, PropertyDescriptor descriptor)
    {
        // HTML of the customizer for this property
        String HTML = null;
        // Get the name of the property (this becomes the name of the form element)
        String propName = descriptor.getName();
        // Get the parameter value
        String paramValue = request.getParameter(propName);
        // Reader method
        Method readMethod = descriptor.getReadMethod();
        // Get the current value of the property
        Object value = null;
        try {
            value = readMethod.invoke(conProvider, null);
        }
        catch (Exception e) {}
        // Get the class of this property
        Class propClass = descriptor.getPropertyType();
        String className = propClass.getName();
        if ("int".equals(className) ||
            "double".equals(className) ||
            "long".equals(className))
        {
            HTML = "<input type=\"text\" name=\"" + propName + "\" size=\"6\" maxlength=\"10\"";
            if (paramValue != null) {
                HTML += " value=\"" + paramValue + "\"";
            }
            else if (value != null) {
                HTML += " value=\"" + value.toString() + "\"";
            }
            HTML += ">";
        }
        else if ("java.lang.String".equals(className)) {
            if (propName.toLowerCase().equals("password")) {
                HTML = "<input type=\"password\"";
            }
            else {
                HTML = "<input type=\"text\"";
            }
            HTML += " name=\"" + propName + "\" size=\"30\" maxlength=\"150\"";
            if (paramValue != null) {
                HTML += " value=\"" + paramValue + "\"";
            }
            else if (value != null) {
                HTML += " value=\"" + value.toString() + "\"";
            }
            HTML += ">";
        }
        else {
            return null;
        }
        return HTML;
    }

    /**
     *
     */
    private static final boolean isParameterValid(HttpServletRequest request,
            ConnectionProvider conProvider, PropertyDescriptor descriptor)
    {
        boolean isValid = true;
        // Name of this parameters
        String name = descriptor.getName();
        // Get the parameter value
        String value = request.getParameter(name);
        // Get the class of this property
        String className = descriptor.getPropertyType().getName();
        try {
            if ("int".equals(className)) {
                if (value != null && !value.equals("")) {
                    if (Integer.parseInt(value) < 0) {
                        isValid = false;
                    }
                }
            }
            else if ("double".equals(className)) {
                if (value != null && !value.equals("")) {
                    if (Double.parseDouble(value) < 0.0) {
                        isValid = false;
                    }
                }
            }
            else if ("java.lang.String".equals(className)) {
                if (value == null || value.equals("")) {
                    isValid = false;
                }
            }
        }
        catch (Exception e) {
            isValid = false;
        }
        return isValid;
    }

    private static final PropertyDescriptor getPropertyDescriptor(PropertyDescriptor[] pd,
            String name)
    {
        for (int i=0; i<pd.length; i++) {
            if (name.equals(pd[i].getName())) {
                return pd[i];
            }
        }
        return null;
    }
%>

<%  // Figure out if we need to stay on this page or go to setup4.jsp
    if ("true".equals((String)session.getAttribute("setup3.done"))) {
        response.sendRedirect("setup4.jsp");
        return;
    }


    // Get the global Jive locale
	Locale locale = JiveGlobals.getLocale();
	// Set the JSP page to use the Jive locale
	response.setLocale(locale);
	// Load the appropriate resource bundle to display the page.
	ResourceBundle bundle = SkinUtils.getResourceBundle("skin_admin_setup", locale);

    // Load error messages from the bundle
    HashMap dbFieldErrorMessages = new HashMap();
    dbFieldErrorMessages.put("driver",bundle.getString("setup3.driver_errorMessage"));
    dbFieldErrorMessages.put("serverURL",bundle.getString("setup3.serverURL_errorMessage"));
    dbFieldErrorMessages.put("username",bundle.getString("setup3.username_errorMessage"));
    dbFieldErrorMessages.put("password",bundle.getString("setup3.password_errorMessage"));
    dbFieldErrorMessages.put("minConnections",bundle.getString("setup3.minConnections_errorMessage"));
    dbFieldErrorMessages.put("maxConnections",bundle.getString("setup3.maxConnections_errorMessage"));
    dbFieldErrorMessages.put("connectionTimeout",bundle.getString("setup3.connectionTimeout_errorMessage"));

    // Collect info about the database connection manager. The Jive connection
    // manager is really a bean, so we're going to use the BeanInfo introspection
    // classes to get and set its properties.

    // Get the Jive database connection provider.
    ConnectionProvider conProvider = new DefaultConnectionProvider();
    // Get the BeanInfo object associated with it (will load
    // com.jivesoftware.forum.database.DefaultConnectionProviderBeanInfo)
	BeanInfo beanInfo = Introspector.getBeanInfo(conProvider.getClass());
	// Get the connection provider's properties:
    PropertyDescriptor[] propDescriptors = beanInfo.getPropertyDescriptors();
    // Hard code the order of property descriptors
    String[] propertyNames = DefaultConnectionProviderBeanInfo.PROPERTY_NAMES;

    // Get parameters
    boolean validate = ParamUtils.getBooleanParameter(request,"validate");

    // Collect the database field prop values from the parameters, if requested
    // and validate the fields if necessary
    boolean errors = false;
    boolean[] validFields = new boolean[propDescriptors.length];
    if (validate) {
        for (int i=0; i<propertyNames.length; i++) {
            PropertyDescriptor descriptor = getPropertyDescriptor(propDescriptors, propertyNames[i]);

⌨️ 快捷键说明

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