KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sourceforge > formview > usecases > action > ProjectWithSubFormAction


1 package net.sourceforge.formview.usecases.action;
2
3 import javax.servlet.http.HttpServletRequest JavaDoc;
4 import javax.servlet.http.HttpServletResponse JavaDoc;
5
6 import net.sourceforge.formview.usecases.form.ProjectWithSubForm;
7 import net.sourceforge.formview.util.WEBFormViewUtil;
8 import net.sourceforge.jsptabcontrol.util.JSPTabControlUtil;
9
10 import org.apache.struts.action.ActionForm;
11 import org.apache.struts.action.ActionForward;
12 import org.apache.struts.action.ActionMapping;
13
14 public class ProjectWithSubFormAction extends ProjectAction {
15
16     public ActionForward display(ActionMapping mapping, ActionForm actionForm, HttpServletRequest JavaDoc request,
17             HttpServletResponse JavaDoc response) throws Exception JavaDoc {
18         String JavaDoc formName = mapping.getPath();
19         // 1. Save form view of subFormId=PROJECT_TABPAGE
20
WEBFormViewUtil.saveFormView(request, getServlet().getServletContext(), formName, "PROJECT_TABPAGE");
21
22         // 2. Save form view of subFormId=DEVELOPERS_TABPAGE
23
WEBFormViewUtil.saveFormView(request, getServlet().getServletContext(), formName, "DEVELOPERS_TABPAGE");
24         return super.display(mapping, actionForm, request, response);
25     }
26     
27     
28     public ActionForward refreshState(ActionMapping mapping, ActionForm actionForm, HttpServletRequest JavaDoc request,
29             HttpServletResponse JavaDoc response) throws Exception JavaDoc {
30         ProjectWithSubForm form = (ProjectWithSubForm)actionForm;
31         String JavaDoc projectTabPageState = form.getProjectTabPageState();
32         String JavaDoc developersTabPageState = form.getDevelopersTabPageState();
33         
34         String JavaDoc tabControlName = "FORMVIEW_WITH_JSPTABCONTROL";
35         
36         if (projectTabPageState != null && projectTabPageState.length() > 0) {
37             String JavaDoc subFormId = "PROJECT_TABPAGE";
38             // Project Tab page must be refresh with state
39
// 1. Update State of tab page (with JSPTAbControl) => tabPage = PROJECT_TABPAGE
40
WEBFormViewUtil.saveState(request, getServlet().getServletContext(), projectTabPageState, subFormId);
41
42             
43             // 2. Update State of content of tab page (with FormView) => subFormId=PROJECT_TABPAGE
44
JSPTabControlUtil.setTabPageState(getServlet().getServletContext(), request, tabControlName, subFormId, projectTabPageState);
45         }
46
47         if (developersTabPageState != null && developersTabPageState.length() > 0) {
48             String JavaDoc subFormId = "DEVELOPERS_TABPAGE";
49             // Project Tab page must be refresh with state
50
// 1. Update State of tab page (with JSPTAbControl) => tabPage = PROJECT_TABPAGE
51
WEBFormViewUtil.saveState(request, getServlet().getServletContext(), developersTabPageState, subFormId);
52             
53             // 2. Update State of content of tab page (with FormView) => subFormId=PROJECT_TABPAGE
54
JSPTabControlUtil.setTabPageState(getServlet().getServletContext(), request, tabControlName, subFormId, developersTabPageState);
55         }
56         
57         
58         return display(mapping, actionForm, request, response);
59     }
60 }
61
Popular Tags