KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jdon > strutsutil > ModelDispAction


1 /**
2  * Copyright 2003-2006 the original author or authors.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6
7  http://www.apache.org/licenses/LICENSE-2.0
8
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */

15
16 package com.jdon.strutsutil;
17
18 import javax.servlet.http.HttpServletRequest JavaDoc;
19 import javax.servlet.http.HttpServletResponse JavaDoc;
20
21 import org.apache.struts.action.ActionForm;
22 import org.apache.struts.action.ActionForward;
23 import org.apache.struts.action.ActionMapping;
24 import org.apache.struts.action.ActionMessage;
25 import org.apache.struts.action.ActionMessages;
26
27 import com.jdon.controller.model.ModelIF;
28 import com.jdon.model.ModelForm;
29 import com.jdon.util.Debug;
30
31 /**
32  * 专门显示Model类。
33  *
34  * 为安全起è§?,å?•ç‹¬è®¾ç«‹ä¸€ä¸ªç±»ã€‚å?Œæ—¶åŠ å…¥ç¼“存机制。 requestçš„nocacheå?‚数表示失效缓存机制。 modelDispAction.do?nocache
35  *
36  * <p>
37  * Copyright: Jdon.com Copyright (c) 2003
38  * </p>
39  * <p>
40  * </p>
41  *
42  * @author banq
43  * @version 1.0
44  */

45 public class ModelDispAction extends ModelBaseAction {
46
47     private final static String JavaDoc module = ModelDispAction.class.getName();
48
49     public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response)
50             throws Exception JavaDoc {
51
52         Debug.logVerbose("[JdonFramework]--> enter ModelDispAction process ", module);
53         intContext(this.getServlet().getServletContext());
54         
55         ModelForm modelForm = FormBeanUtil.getModelForm(actionMapping, actionForm, request);
56
57         ModelIF model = viewPageUtil.getModelForEdit(actionMapping, modelForm, request);
58
59         if (model == null) { //如果查询失败,显示出错信æ?¯
60
ActionMessages errors = new ActionMessages();
61             Debug.logError("[JdonFramework]id.notfound in database", module);
62             ActionMessage error = new ActionMessage("id.notfound");
63             errors.add(ActionMessages.GLOBAL_MESSAGE, error);
64             saveErrors(request, errors);
65             ActionForward af = actionMapping.findForward(FormBeanUtil.FORWARD_FAILURE_NAME);
66             if (af != null)
67                 return af;
68             else
69                 return actionMapping.findForward(FormBeanUtil.FORWARD_SUCCESS_NAME);
70         } else {
71             return actionMapping.findForward(FormBeanUtil.FORWARD_SUCCESS_NAME);
72         }
73
74     }
75     
76     
77
78 }
79
Popular Tags