KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > killingar > forum > actions > EditAppearance


1 /* Copyright 2000-2005 Anders Hovmöller
2  *
3  * The person or persons who have associated their work with
4  * this document (the "Dedicator") hereby dedicate the entire
5  * copyright in the work of authorship identified below (the
6  * "Work") to the public domain.
7  *
8  * Dedicator makes this dedication for the benefit of the
9  * public at large and to the detriment of Dedicator's heirs
10  * and successors. Dedicator intends this dedication to be an
11  * overt act of relinquishment in perpetuity of all present
12  * and future rights under copyright law, whether vested or
13  * contingent, in the Work. Dedicator understands that such
14  * relinquishment of all rights includes the relinquishment of
15  * all rights to enforce (by lawsuit or otherwise) those
16  * copyrights in the Work.
17  *
18  * Dedicator recognizes that, once placed in the public
19  * domain, the Work may be freely reproduced, distributed,
20  * transmitted, used, modified, built upon, or otherwise
21  * exploited by anyone for any purpose, commercial or non-
22  * commercial, and in any way, including by methods that have
23  * not yet been invented or conceived.
24  */

25
26 package net.killingar.forum.actions;
27
28 import net.killingar.forum.internal.managers.OptionsManager;
29 import webwork.action.ParameterAware;
30
31 import java.util.ArrayList JavaDoc;
32 import java.util.List JavaDoc;
33 import java.util.Map JavaDoc;
34
35 public class EditAppearance
36     extends net.killingar.forum.actions.area.ActionAreaSupport
37     implements ParameterAware
38 {
39     OptionsManager optionmgr;
40     List JavaDoc stringOptions;
41     String JavaDoc customHtml;
42     Map JavaDoc parameters;
43
44     static final String JavaDoc stringOptionsData[][] =
45     {
46         {"arrow down url", "URL for down arrow picture", "/_common/img/arrowdown.gif"},
47         {"arrow up url", "URL for up arrow picture", "/_common/img/arrowup.gif"},
48         {"bar image", "default bar image for polls", "servlet/Pixel?722899"},
49         {"hr", "horizontal ruler", "<img SRC=\"/_common/img/color.gif\" width=\"100%\" height=\"13\" alt=\"horizontal ruler\"/><br />"},
50         {"logo url", "contents logo url", "/_common/img/logo_small.gif"},
51     };
52
53     public void setParameters(Map JavaDoc map) { parameters = map; }
54     public void setSession(Map JavaDoc map)
55     {
56         super.setSession(map);
57         try
58         {
59             synchronized (map)
60             {
61                 optionmgr = (OptionsManager)manager.getManager(OptionsManager.class.getName());
62                 if (optionmgr == null)
63                     addErrorMessage("failed to initialize options manager, null returned");
64             }
65         }
66         catch (Exception JavaDoc exception)
67         {
68             addErrorMessage("failed to initialize options manager, exception thrown (" + exception.toString() + ")");
69             exception.printStackTrace();
70         }
71     }
72
73     public List JavaDoc getStringOptions() { return stringOptions; }
74
75     protected String JavaDoc doExecute()
76     {
77         try
78         {
79             if (parameters.containsKey("change"))
80             {
81                 for (int k = 0; k < stringOptionsData.length; k++)
82                 {
83                     if (parameters.containsKey(stringOptionsData[k][0]))
84                     {
85                         String JavaDoc s = ((String JavaDoc[])parameters.get(stringOptionsData[k][0]))[0];
86                         if (s != null && s.equals(stringOptionsData[k][2]))
87                             s = null;
88                         optionmgr.set(stringOptionsData[k][0], s);
89                     }
90                 }
91
92             }
93             stringOptions = new ArrayList JavaDoc();
94             for (int i = 0; i < stringOptionsData.length; i++)
95                 stringOptions.add(new StringOption(stringOptionsData[i][0], stringOptionsData[i][1], optionmgr.get(stringOptionsData[i][0]), stringOptionsData[i][2]));
96
97             return SUCCESS;
98         }
99         catch (Exception JavaDoc exception)
100         {
101             addErrorMessage("edit options failed, exception thrown (" + exception.toString() + ")");
102             exception.printStackTrace();
103             return ERROR;
104         }
105     }
106 }
Popular Tags