summaryrefslogtreecommitdiff
path: root/projects/net.wotonomy.web/src/main/java/net/wotonomy/web/WOFrame.java
blob: 30dd4bc4a8ba510e033b6ed0d540f764c750b3e1 (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

package net.wotonomy.web;

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

public class WOFrame extends WODynamicElement {

    public WOFrame() {
        super();
    }

    public WOFrame(String aName, NSDictionary assocs, WOElement template) {
        super(aName, assocs, template);
    }

    public String frameName(WOContext c) {
        String x = (String)valueForProperty("name", c.component());
        if (x != null)
            return x;
        return c.elementID();
    }

    public String url(WOContext c) {
        //Check if the href property is set
        String href = stringForProperty("href", c.component());
        if (href != null)
            return href;
        href = stringForProperty("pageName", c.component());
        if (href != null || associations.objectForKey("action") != null) { //write this component's URL
                return c.componentActionURL();
        }
        href = stringForProperty("directActionName", c.component());
        if (href != null) { //compose the direct action URL
            String fullActionName = stringForProperty("actionClass", c.component());
            if (fullActionName != null)
                fullActionName = fullActionName + "/" + href;
            else
                fullActionName = href;
            return c.directActionURLForActionNamed(fullActionName,
                urlFields(c.component()));
        }
        //Coded needed here to support filename/framework and data/mimeType.
        return null;
    }

    public void appendToResponse(WOResponse r, WOContext c) {
        r.appendContentString("<FRAME NAME=\"");
        r.appendContentString(frameName(c));
        r.appendContentString("\" SRC=\"");
        r.appendContentString(url(c));
        r.appendContentString("\"");
        String moreFields = additionalHTMLProperties(c.component(), new NSArray(new Object[]{
            "name", "href", "pageName", "directActionName", "actionClass" }));
        if (moreFields != null && moreFields.length() > 0)
            r.appendContentString(moreFields);
        r.appendContentString(">");
    }

}