KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > domimpl > HTMLIFrameElementImpl


1 package org.lobobrowser.html.domimpl;
2
3 import org.lobobrowser.html.*;
4 import org.lobobrowser.html.js.Window;
5 import org.w3c.dom.Document JavaDoc;
6 import org.w3c.dom.html2.HTMLIFrameElement;
7
8 public class HTMLIFrameElementImpl extends HTMLAbstractUIElement implements
9         HTMLIFrameElement, FrameNode {
10     private volatile BrowserFrame browserFrame;
11     
12     public HTMLIFrameElementImpl(String JavaDoc name) {
13         super(name);
14     }
15     
16     public void setBrowserFrame(BrowserFrame frame) {
17         this.browserFrame = frame;
18         if(frame != null) {
19             String JavaDoc src = this.getAttribute("src");
20             if(src != null) {
21                 try {
22                     frame.loadURL(this.getFullURL(src));
23                 } catch(java.net.MalformedURLException JavaDoc mfu) {
24                     this.warn("setBrowserFrame(): Unable to navigate to src.", mfu);
25                 }
26             }
27         }
28     }
29     
30     public BrowserFrame getBrowserFrame() {
31         return this.browserFrame;
32     }
33
34     public String JavaDoc getAlign() {
35         return this.getAttribute("align");
36     }
37
38     public Document JavaDoc getContentDocument() {
39         //TODO: Domain-based security
40
BrowserFrame frame = this.browserFrame;
41         if(frame == null) {
42             // Not loaded yet
43
return null;
44         }
45         return frame.getContentDocument();
46     }
47     
48     public Window getContentWindow() {
49         BrowserFrame frame = this.browserFrame;
50         if(frame == null) {
51             // Not loaded yet
52
return null;
53         }
54         return Window.getWindow(frame.getHtmlRendererContext());
55     }
56
57     public String JavaDoc getFrameBorder() {
58         return this.getAttribute("frameborder");
59     }
60
61     public String JavaDoc getHeight() {
62         return this.getAttribute("height");
63     }
64
65     public String JavaDoc getLongDesc() {
66         return this.getAttribute("longdesc");
67     }
68
69     public String JavaDoc getMarginHeight() {
70         return this.getAttribute("marginheight");
71     }
72
73     public String JavaDoc getMarginWidth() {
74         return this.getAttribute("marginwidth");
75     }
76
77     public String JavaDoc getName() {
78         return this.getAttribute("name");
79     }
80
81     public String JavaDoc getScrolling() {
82         return this.getAttribute("scrolling");
83     }
84
85     public String JavaDoc getSrc() {
86         return this.getAttribute("src");
87     }
88
89     public String JavaDoc getWidth() {
90         return this.getAttribute("width");
91     }
92
93     public void setAlign(String JavaDoc align) {
94         this.setAttribute("align", align);
95     }
96
97     public void setFrameBorder(String JavaDoc frameBorder) {
98         this.setAttribute("frameborder", frameBorder);
99     }
100
101     public void setHeight(String JavaDoc height) {
102         this.setAttribute("height", height);
103     }
104
105     public void setLongDesc(String JavaDoc longDesc) {
106         this.setAttribute("longdesc", longDesc);
107     }
108
109     public void setMarginHeight(String JavaDoc marginHeight) {
110         this.setAttribute("marginHeight", marginHeight);
111     }
112
113     public void setMarginWidth(String JavaDoc marginWidth) {
114         this.setAttribute("marginWidth", marginWidth);
115     }
116
117     public void setName(String JavaDoc name) {
118         this.setAttribute("name", name);
119     }
120
121     public void setScrolling(String JavaDoc scrolling) {
122         this.setAttribute("scrolling", scrolling);
123     }
124
125     public void setSrc(String JavaDoc src) {
126         this.setAttribute("src", src);
127     }
128
129     public void setWidth(String JavaDoc width) {
130         this.setAttribute("width", width);
131     }
132
133     protected void assignAttributeField(String JavaDoc normalName, String JavaDoc value) {
134         if("src".equals(normalName)) {
135             BrowserFrame frame = this.browserFrame;
136             if(frame != null) {
137                 try {
138                     frame.loadURL(this.getFullURL(value));
139                 } catch(java.net.MalformedURLException JavaDoc mfu) {
140                     this.warn("assignAttributeField(): Unable to navigate to src.", mfu);
141                 }
142             }
143         }
144         else {
145             super.assignAttributeField(normalName, value);
146         }
147     }
148 }
149
Popular Tags