|
What this is
Other links
The source code/* $Id: configMode.java,v 1.14 2001/04/23 03:15:31 agarcia3 Exp $ webEditor. The new way in content management Copyright (C) 2001 Alfredo Garcia This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ package webEditor.interfaces; import java.io.*; import java.lang.reflect.*; import java.util.*; import javax.servlet.*; import javax.servlet.http.*; import org.w3c.dom.*; import webEditor.util.*; import webEditor.core.*; /** * Configuration interface; This class shows the page with the editor parameters * @author <a href="mailto:agarcia@mundofree.com">Alfredo Garcia */ public class configMode { /** * Configuration values */ private configuration initValues; /** * Editor root */ private String wEd_root; /** * Path for the data configuration files */ private String dataDir; /** * Path for the XSL template files */ private String tplDir; /** * Configuration parser */ private xml_parser confParser= null; /** * Presentation Management */ private presentation myEditor= null; /** * Class constructor * @param initParam Initial values */ public configMode (configuration initParam) { this.initValues = initParam; this.wEd_root = initParam.readValue ("webEditor_Root","wEd_root"); this.dataDir = initParam.readValue ("directories","dataDir"); this.dataDir = this.wEd_root + "/" + this.dataDir; this.tplDir = initParam.readValue ("directories","tplDir"); this.tplDir = this.dataDir + "/" + this.tplDir; } /** * Operations over the configuration values * @param request HTTP request * @param out Servlet Output * @return void */ public void showConfig (HttpServletRequest request, PrintWriter out) throws ServletException, IOException { String outputString = ""; this.confParser = new xml_parser (); this.myEditor = new presentation (this.initValues); String opCode = this.initValues.readValue ("HTTP Parameters", "code"); if (opCode == null) { // Default operation mode opCode = "show"; } try { // We use reflection to invoque the proper method Method m = getClass().getMethod(opCode, new Class[] {HttpServletRequest.class, PrintWriter.class} ); m.invoke(this,new Object[] {request, out}); } catch (Exception e) { out.println ("Code not supported"); } } /** * Edition of the configuration values * @param request HTTP request * @param out Servlet Output * @return void */ public void edit (HttpServletRequest request, PrintWriter out) throws ServletException, IOException { String action = this.initValues.readValue ("HTTP Parameters", "action"); if (action == null) { action = "show"; } configuration configValues = null; if ( action.equals ("Save") ) { // We load into the config hash the http parameters Hashtable http_params = this.initValues.readCategory ("HTTP Parameters"); configValues = new configuration (this.wEd_root + "/general.xml"); Document oldConfig = this.confParser.writeDOM ("general", configValues.returnData()); // And then, we write the new http values ... oldConfig = configValues.writeDoc (http_params, oldConfig); configValues.saveConfig (this.wEd_root + "/general.xml", oldConfig); } configValues = new configuration (this.wEd_root + "/general.xml"); Document doc = this.confParser.writeDOM ("general", configValues.returnData()); String outputString = this.myEditor.showConfigEditor (doc); out.println (outputString); } /** * Simple configuration presentation * @param request HTTP request * @param out Servlet Output * @return void */ public void show (HttpServletRequest request, PrintWriter out) throws ServletException, IOException { // With the content of the hash table, build a DOM tree Document doc = this.confParser.writeDOM ("general", this.initValues.returnData()); String outputString = this.myEditor.showConfig (doc); out.println (outputString); } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.