KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The Lobo Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 /*
22  * Created on Oct 8, 2005
23  */

24 package org.lobobrowser.html.domimpl;
25
26 import org.lobobrowser.html.style.*;
27 import org.mozilla.javascript.Function;
28 import org.w3c.dom.Document JavaDoc;
29 import org.w3c.dom.html2.*;
30
31 public class HTMLBodyElementImpl extends HTMLAbstractUIElement implements
32         HTMLBodyElement {
33     public HTMLBodyElementImpl(String JavaDoc name) {
34         super(name);
35     }
36     
37     void setOwnerDocument(Document JavaDoc value, boolean deep) {
38         super.setOwnerDocument(value, deep);
39         if(value instanceof HTMLDocument) {
40             ((HTMLDocument) value).setBody(this);
41         }
42     }
43
44     void setOwnerDocument(Document JavaDoc value) {
45         super.setOwnerDocument(value);
46         if(value instanceof HTMLDocument) {
47             ((HTMLDocument) value).setBody(this);
48         }
49     }
50
51     public String JavaDoc getALink() {
52         return this.getAttribute("alink");
53     }
54
55     public void setALink(String JavaDoc aLink) {
56         this.setAttribute("alink", aLink);
57     }
58
59     public String JavaDoc getBackground() {
60         return this.getAttribute("background");
61     }
62
63     public void setBackground(String JavaDoc background) {
64         this.setAttribute("background", background);
65     }
66
67     public String JavaDoc getBgColor() {
68         return this.getAttribute("bgcolor");
69     }
70
71     public void setBgColor(String JavaDoc bgColor) {
72         this.setAttribute("bgcolor", bgColor);
73     }
74
75     public String JavaDoc getLink() {
76         return this.getAttribute("link");
77     }
78
79     public void setLink(String JavaDoc link) {
80         this.setAttribute("link", link);
81     }
82
83     public String JavaDoc getText() {
84         return this.getAttribute("text");
85     }
86
87     public void setText(String JavaDoc text) {
88         this.setAttribute("text", text);
89     }
90
91     public String JavaDoc getVLink() {
92         return this.getAttribute("vlink");
93     }
94
95     public void setVLink(String JavaDoc vLink) {
96         this.setAttribute("vlink", vLink);
97     }
98
99     protected RenderState createRenderState(RenderState prevRenderState) {
100         return new BodyRenderState(prevRenderState, this);
101     }
102     
103     public Function getOnload() {
104         Object JavaDoc document = this.document;
105         if(document instanceof HTMLDocumentImpl) {
106             return ((HTMLDocumentImpl) document).getOnloadHandler();
107         }
108         else {
109             return null;
110         }
111     }
112
113     public void setOnload(Function onload) {
114         Object JavaDoc document = this.document;
115         if(document instanceof HTMLDocumentImpl) {
116             //Note that body.onload overrides
117
//Window.onload.
118
((HTMLDocumentImpl) document).setOnloadHandler(onload);
119         }
120     }
121
122     protected void assignAttributeField(String JavaDoc normalName, String JavaDoc value) {
123         if("onload".equals(normalName)) {
124             Function onload = this.getEventFunction(null, normalName);
125             if(onload != null) {
126                 this.setOnload(onload);
127             }
128         }
129         else {
130             super.assignAttributeField(normalName, value);
131         }
132     }
133     
134     
135 }
136
Popular Tags