View Javadoc

1   /*
2    * Generated by MyEclipse Struts
3    * Template path: templates/java/JavaClass.vtl
4    */
5   package hu.elte.tribus.action;
6   
7   import hu.elte.tribus.form.TopicForm;
8   import hu.elte.tribus.interfaces.QaDao;
9   import hu.elte.tribus.model.Topic;
10  
11  import javax.servlet.http.HttpServletRequest;
12  import javax.servlet.http.HttpServletResponse;
13  
14  import org.apache.struts.action.ActionForm;
15  import org.apache.struts.action.ActionForward;
16  import org.apache.struts.action.ActionMapping;
17  import org.springframework.web.struts.ActionSupport;
18  
19  /*** 
20   * MyEclipse Struts
21   * Creation date: 11-12-2006
22   * 
23   * XDoclet definition:
24   * @struts.action validate="true"
25   */
26  public class SaveTopicAction extends ActionSupport {
27  	/*** 
28  	 * Method execute
29  	 * @param mapping
30  	 * @param form
31  	 * @param request
32  	 * @param response
33  	 * @return ActionForward
34  	 */
35  	public ActionForward execute(ActionMapping mapping, ActionForm form,
36  			HttpServletRequest request, HttpServletResponse response) {
37  		Topic topic;
38  		QaDao qaDao = (QaDao) getWebApplicationContext().getBean("qaDao");
39  		if(request.getParameter("id") != null)
40  		{
41  			topic = qaDao.getTopicById(Integer.parseInt(request.getParameter("id")));
42  		}
43  		else
44  		{
45  			topic = new Topic();
46  		}
47  		TopicForm topicForm = (TopicForm)form;
48  		topic.setName(topicForm.getName());
49  		topic.setDesc(topicForm.getDesc());
50  		qaDao.saveTopic(topic);
51  		request.setAttribute("topics", qaDao.getTopicList());
52  		
53  		return mapping.findForward("ok");
54  	}
55  }