KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > example > ajax > actions > SetActiveCategory


1 /*
2  * Copyright (c) 2005 Your Corporation. All Rights Reserved.
3  */

4 package com.opensymphony.webwork.example.ajax.actions;
5
6 import com.opensymphony.webwork.interceptor.SessionAware;
7 import com.opensymphony.xwork.ActionSupport;
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10
11 import java.util.Map JavaDoc;
12
13 /**
14  * SetActiveCategory
15  *
16  * @author Jason Carreira <jcarreira@eplus.com>
17  */

18 public class SetActiveCategory extends ActionSupport implements SessionAware {
19     private Map JavaDoc session;
20     private Integer JavaDoc categoryId;
21     private static Log LOG = LogFactory.getLog(SetActiveCategory.class);
22
23     public void setSession(Map JavaDoc session) {
24         this.session = session;
25     }
26
27     public void setCategoryId(Integer JavaDoc categoryId) {
28         this.categoryId = categoryId;
29     }
30
31     public Integer JavaDoc getCategoryId() {
32         return categoryId;
33     }
34
35     public String JavaDoc execute() throws Exception JavaDoc {
36         LOG.debug("Setting the active category to " + categoryId);
37         if (categoryId != null) {
38             session.put(ActiveCategory.ACTIVE_CATEGORY_ID, categoryId);
39         } else {
40             session.remove(ActiveCategory.ACTIVE_CATEGORY_ID);
41         }
42         return SUCCESS;
43     }
44 }
45
Popular Tags