API Overview API Index Package Overview Direct link to this page
JavaOnTracks 0.1.2
  net.jot.web.views. JOTLightweightView 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package net.jot.web.views;

import net.jot.web.view.*;
import java.util.Hashtable;
import net.jot.web.forms.JOTForm;

/**
 * This is a lightweight view object, which is decoupled from the webcontainer
 * whereas JOTVIew is tightly coupled.
 * This is mianly used to take advantage/use the  template mechanism/parser of JOT
 * without needing a webapp server running.
 * As in JOTVIew you can subclass this and add your own custom method and call them from the template
 * ex: getUserName(){} ->  in template: %lt;jot:var value="userName"/>
 *
 * @author thibautc
 */
public abstract class JOTLightweightView implements JOTViewParserData
{

    private Hashtable variables = new Hashtable();
    private Hashtable blocks = new Hashtable();
    private Hashtable tags = new Hashtable();
    private Hashtable forms = new Hashtable();

    public Hashtable getBlocks()
    {
        return variables;
    }

    public Hashtable getTags()
    {
        return tags;
    }

    public Hashtable getVariables()
    {
        return variables;
    }

    public Hashtable getForms()
    {
        return forms;
    }

    /**
     * Adds a variable to this View
     * Then you can use the varibale in the view:
     * Ex: jot:var value="id"
     * @param name
     * @param value
     */
    public void addVariable(String id, Object value)
    {
        variables.put(id, value);
    }

    /**
     * Adds a Form to this View. The form can then be used/rendered in the template.
     * @param name
     * @param value
     */
    protected void addForm(JOTForm form)
    {
        forms.put(form.getClass().getName(), form);
    }

    /**
     * Defines a page block to be "defined" on the fly at runtime
     * For example <jot:block dataId="toto">blah</jot:block> will be replaced by the data provided
     * in the view element with dataId "toto" if it exists.
     * You can also use blocks to easily show/hide whole html parts
     * @param dataId
     * @param element
     */
    protected void addBlock(String id, JOTViewBlock element)
    {
        blocks.put(id, element);
    }

    /**
     * Defines an HTML tag to be "redefined" on the fly at runtime
     * For example <div jotid="toto"></div>, content will be replaced by the data provided
     * in the view element with dataId "toto" if it exists.
     * @param dataId
     * @param element
     */
    protected void addTag(String id, JOTViewBlock element)
    {
        tags.put(id, element);
    }
    
    public JOTView getFullView()
    {
        // not avail for lightweight view
        return null;
    }
}

Generated By: JavaOnTracks Doclet 0.1.5     ©Thibaut Colar