API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.web.views. JOTErrorView View Javadoc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62

/*
------------------------------------
JavaOnTracks          Thibaut Colar
tcolar-jot AT colar DOT net
Artistic Licence 2.0
http://www.javaontracks.net
------------------------------------
 */
package net.jot.web.views;

import net.jot.JOTInitializer;
import net.jot.utils.JOTHTMLUtilities;
import net.jot.web.view.JOTView;

/**
 * Standard error page View, leave as-is to use the bultin template, or cuse with yor own template.
 * @author thibautc
 */
public class JOTErrorView extends JOTView
{
	public static final String EXCEPTION_ATTRIB="JOT_Exception";
	
	public void prepareViewData() throws Exception
	{	
		setBuiltinTemplate(JOTBuiltinTemplates.ERROR_TEMPLATE);
		
		addVariable("version",JOTInitializer.VERSION);
		Throwable t=(Throwable)request.getAttribute(EXCEPTION_ATTRIB);
        
		if(t!=null)
		{
			addVariable("title",htmlEncode(t.toString()));
			//JOTLogger.log(JOTLogger.CAT_FLOW,JOTLogger.TRACE_LEVEL, JOTViewParser.class, "###getmessage:"+t.getMessage());
			addVariable("exception", t);
			if(t.getCause()!=null)
			{
				addVariable("cause", (Throwable)t.getCause());
				addVariable("causeTitle",htmlEncode(t.getCause().toString()));
			}
		}
	}

    public StackTraceElement[] getStackTrace(Throwable t)
    {
        return t.getStackTrace();
    }

	// Here we want html tags to be shown, not interpreted.
	public String htmlEncode(String s)
	{
		return JOTHTMLUtilities.textToHtml(s);
	}
	public String htmlEncode(StackTraceElement e)
	{
		return htmlEncode(e.toString());
	}

	public boolean validatePermissions()
	{
		return true;
	}
}

Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar