summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOBody.java
blob: 9f0707de5aa65396547855dcfdd42e5755714d1d (plain)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*
Wotonomy: OpenStep design patterns for pure Java applications.
Copyright (C) 2003 Intersect Software Corporation

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, see http://www.gnu.org
*/

package net.wotonomy.web;

import net.wotonomy.foundation.NSArray;
import net.wotonomy.foundation.NSData;
import net.wotonomy.foundation.NSDictionary;

/**
* WOBody represents a page's "body" tag and is used to dynamically 
* set the background image for a page, and therefore works much like WOImage.
*
* Bindings are:
* <UL>
* <li>src: A static URL for the image source.</li>
* <li>data: A NSData object with the image content. Must be used with mimeType.</li>
* <li>mimeType: The MIME type for the image data. Can be used with filename or data bindings.</li>
* <li>filename: The path to a file containing an image.</li>
* <li>framework: The optional framework from whence the image should be retrieved (used in conjunction with filename).</li>
* <li>key: A key under which this resource will be cached for repeated access.</li>
*
* @author michael@mpowers.net
* @author $Author: cgruber $
* @version $Revision: 905 $
*/
public class WOBody extends WOImage {

    protected String src;
    protected String filename;
    protected String framework;
    protected NSData data;
    protected String mimeType;

    protected WOBody() {
        super();
    }

    public WOBody(String aName, NSDictionary aMap, WOElement template) {
        super(aName, aMap, template);
    }

    void ensureAwakeInContext (WOContext aContext)
    {
        if ( rootElement != null )
	    {
	    	rootElement.ensureAwakeInContext( aContext );
	    }
    }

    public void takeValuesFromRequest (WORequest aRequest, WOContext aContext)
    {
        if ( rootElement != null )
	    {
	    	rootElement.takeValuesFromRequest( aRequest, aContext );
	    }
    }        
        
    public WOActionResults invokeAction (WORequest aRequest, WOContext aContext)
    {
        if ( rootElement != null )
	    {
	    	return rootElement.invokeAction( aRequest, aContext );
	    }
        return null;
    }        
        
    public void appendToResponse(WOResponse r, WOContext c) 
    {
        r.appendContentString("<body background=\"");
        r.appendContentString(sourceURL(c));
        r.appendContentString("\"");
        r.appendContentString(additionalHTMLProperties(c.component(), new NSArray(new Object[]{
            "src", "filename", "framework", "data", "mimeType" })));
        r.appendContentString(">");
        if ( rootElement != null )
        {
            rootElement.appendToResponse( r, c );
        }
        r.appendContentString("</body>");
    }

}

/*
 * $Log$
 * Revision 1.2  2006/02/19 01:44:02  cgruber
 * Add xmlrpc files
 * Remove jclark and replace with dom4j and javax.xml.sax stuff
 * Re-work dependencies and imports so it all compiles.
 *
 * Revision 1.1  2006/02/16 13:22:22  cgruber
 * Check in all sources in eclipse-friendly maven-enabled packages.
 *
 * Revision 1.4  2003/08/07 00:15:14  chochos
 * general cleanup (mostly removing unused imports)
 *
 * Revision 1.3  2003/01/27 15:57:28  mpowers
 * Now participates in all parts of request/response cycle.
 *
 * Revision 1.2  2003/01/27 15:08:23  mpowers
 * Now appending to response.
 *
 *
 */