01: package com.technoetic.xplanner.actions;
02:
03: import java.util.Properties;
04: import javax.servlet.http.HttpServletRequest;
05: import javax.servlet.http.HttpServletResponse;
06:
07: import org.apache.commons.lang.StringUtils;
08: import org.apache.struts.action.Action;
09: import org.apache.struts.action.ActionForm;
10: import org.apache.struts.action.ActionForward;
11: import org.apache.struts.action.ActionMapping;
12:
13: import com.technoetic.xplanner.XPlannerProperties;
14:
15: /**
16: * Created by IntelliJ IDEA.
17: * User: sg620641
18: * Date: Oct 24, 2005
19: * Time: 2:49:12 PM
20: * To change this template use File | Settings | File Templates.
21: */
22: public class EditPropertiesAction extends Action {
23: protected static final String PROPERTY_NAME_PARAM = "propertyName";
24: protected static final String PROPERTY_VALUE_PARAM = "propertyValue";
25: protected static final String RETURN_TO_PARAM = "returnto";
26:
27: public ActionForward execute(ActionMapping mapping,
28: ActionForm form, HttpServletRequest request,
29: HttpServletResponse response) throws Exception {
30: XPlannerProperties properties = new XPlannerProperties();
31: String propertyName = request.getParameter(PROPERTY_NAME_PARAM);
32: String propertyValue = request
33: .getParameter(PROPERTY_VALUE_PARAM);
34: String returnTo = request.getParameter(RETURN_TO_PARAM);
35: if (!StringUtils.isEmpty(propertyName) && propertyValue != null) {
36: getPropertiesToUpdate(properties).setProperty(propertyName,
37: propertyValue);
38: }
39: if (returnTo != null) {
40: return new ActionForward(returnTo, true);
41: } else {
42: return mapping.findForward("view/projects");
43: }
44: }
45:
46: protected Properties getPropertiesToUpdate(
47: XPlannerProperties properties) {
48: return properties.get();
49: }
50: }
|