Clover Coverage Report - itracker
Coverage timestamp: Tue May 1 2012 16:42:12 CEST
21   94   12   2.62
4   55   0.57   8
8     1.5  
1    
 
 
  AddErrorTag       Line # 34 21 12 0% 0.0
 
No Tests
 
1    /*
2    * This software was designed and created by Jason Carroll.
3    * Copyright (c) 2002, 2003, 2004 Jason Carroll.
4    * The author can be reached at jcarroll@cowsultants.com
5    * ITracker website: http://www.cowsultants.com
6    * ITracker forums: http://www.cowsultants.com/phpBB/index.php
7    *
8    * This program is free software; you can redistribute it and/or modify
9    * it only under the terms of the GNU General Public License as published by
10    * the Free Software Foundation; either version 2 of the License, or
11    * (at your option) any later version.
12    *
13    * This program is distributed in the hope that it will be useful,
14    * but WITHOUT ANY WARRANTY; without even the implied warranty of
15    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16    * GNU General Public License for more details.
17    */
18   
19    package org.itracker.web.taglib;
20   
21    import javax.servlet.http.HttpServletRequest;
22    import javax.servlet.jsp.JspException;
23    import javax.servlet.jsp.tagext.TagSupport;
24   
25    import org.apache.struts.Globals;
26    import org.apache.struts.action.ActionErrors;
27    import org.apache.struts.action.ActionMessage;
28    import org.apache.struts.action.ActionMessages;
29   
30    /**
31    * @deprecated errors should be handled by Action classes, not JSPs!
32    */
33    @Deprecated
 
34    public final class AddErrorTag extends TagSupport {
35    /**
36    *
37    */
38    private static final long serialVersionUID = 1L;
39    private String name = Globals.ERROR_KEY;
40    private String key;
41   
 
42  0 toggle public String getName() {
43  0 return name;
44    }
45   
 
46  0 toggle public void setName(String value) {
47  0 name = value;
48    }
49   
 
50  0 toggle public String getKey() {
51  0 return key;
52    }
53   
 
54  0 toggle public void setKey(String value) {
55  0 key = value;
56    }
57   
 
58  0 toggle public int doStartTag() throws JspException {
59  0 return (SKIP_BODY);
60    }
61   
 
62  0 toggle public int doEndTag() throws JspException {
63  0 ActionErrors errors = null;
64  0 HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
65   
66  0 if(request == null || getKey() == null) {
67  0 return EVAL_PAGE;
68    }
69   
70  0 try {
71  0 errors = (ActionErrors) request.getAttribute(getName());
72    } catch(ClassCastException cce) {
73    }
74   
75  0 if(errors == null) {
76  0 errors = new ActionErrors();
77    }
78   
79  0 errors.add(ActionMessages.GLOBAL_MESSAGE, new ActionMessage(getKey()));
80  0 request.setAttribute(getName(), errors);
81  0 clearState();
82  0 return EVAL_PAGE;
83    }
84   
 
85  0 toggle public void release() {
86  0 super.release();
87  0 clearState();
88    }
89   
 
90  0 toggle private void clearState() {
91  0 name = Globals.ERROR_KEY;
92  0 key = null;
93    }
94    }