View Javadoc

1   
2   package net.wotonomy.web;
3   
4   import net.wotonomy.foundation.NSArray;
5   import net.wotonomy.foundation.NSDictionary;
6   
7   public class WOFrame extends WODynamicElement {
8   
9       public WOFrame() {
10          super();
11      }
12  
13      public WOFrame(String aName, NSDictionary assocs, WOElement template) {
14          super(aName, assocs, template);
15      }
16  
17      public String frameName(WOContext c) {
18          String x = (String)valueForProperty("name", c.component());
19          if (x != null)
20              return x;
21          return c.elementID();
22      }
23  
24      public String url(WOContext c) {
25          //Check if the href property is set
26          String href = stringForProperty("href", c.component());
27          if (href != null)
28              return href;
29          href = stringForProperty("pageName", c.component());
30          if (href != null || associations.objectForKey("action") != null) { //write this component's URL
31                  return c.componentActionURL();
32          }
33          href = stringForProperty("directActionName", c.component());
34          if (href != null) { //compose the direct action URL
35              String fullActionName = stringForProperty("actionClass", c.component());
36              if (fullActionName != null)
37                  fullActionName = fullActionName + "/" + href;
38              else
39                  fullActionName = href;
40              return c.directActionURLForActionNamed(fullActionName,
41                  urlFields(c.component()));
42          }
43          //Coded needed here to support filename/framework and data/mimeType.
44          return null;
45      }
46  
47      public void appendToResponse(WOResponse r, WOContext c) {
48          r.appendContentString("<FRAME NAME=\"");
49          r.appendContentString(frameName(c));
50          r.appendContentString("\" SRC=\"");
51          r.appendContentString(url(c));
52          r.appendContentString("\"");
53          String moreFields = additionalHTMLProperties(c.component(), new NSArray(new Object[]{
54              "name", "href", "pageName", "directActionName", "actionClass" }));
55          if (moreFields != null && moreFields.length() > 0)
56              r.appendContentString(moreFields);
57          r.appendContentString(">");
58      }
59  
60  }