001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.bean.html5;
018
019import org.apache.juneau.annotation.*;
020import org.apache.juneau.internal.*;
021
022/**
023 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/sections.html#the-body-element">&lt;body&gt;</a>
024 * element.
025 *
026 * <p>
027 * The body element represents the content of an HTML document. It contains all the visible content
028 * of the page, including text, images, links, forms, and other elements. The body element is
029 * typically the direct child of the html element and contains all the main content of the document.
030 *
031 * <h5 class='section'>Examples:</h5>
032 * <p class='bcode w800'>
033 *    <jc>// Simple body with text content</jc>
034 *    Body <jv>body1</jv> = <jsm>body</jsm>().text(<js>"Welcome to our website!"</js>);
035 * 
036 *    <jc>// Body with structured content</jc>
037 *    Body <jv>body2</jv> = <jsm>body</jsm>()
038 *       .children(
039 *          <jsm>header</jsm>().children(
040 *             <jsm>h1</jsm>().text(<js>"Page Title"</js>)
041 *          ),
042 *          <jsm>main</jsm>().children(
043 *             <jsm>p</jsm>().text(<js>"Main content goes here."</js>)
044 *          ),
045 *          <jsm>footer</jsm>().text(<js>"Copyright 2024"</js>)
046 *       );
047 * 
048 *    <jc>// Body with event handlers</jc>
049 *    Body <jv>body3</jv> = <jsm>body</jsm>()
050 *       .onload(<js>"initializePage()"</js>)
051 *       .onbeforeunload(<js>"return confirm('Are you sure you want to leave?')"</js>)
052 *       .text(<js>"Page content"</js>);
053 * </p>
054 *
055 * <p>
056 * The following convenience methods are provided for constructing instances of this bean:
057 * <ul class='javatree'>
058 *    <li class='jc'>{@link HtmlBuilder}
059 *    <ul class='javatree'>
060 *       <li class='jm'>{@link HtmlBuilder#body() body()}
061 *       <li class='jm'>{@link HtmlBuilder#body(Object, Object...) body(Object, Object...)}
062 *    </ul>
063 * </ul>
064 * </p>
065 *
066 * <h5 class='section'>See Also:</h5><ul>
067 *    <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a>
068 * </ul>
069 */
070@Bean(typeName="body")
071public class Body extends HtmlElementMixed {
072
073   /**
074    * Creates an empty {@link Body} element.
075    */
076   public Body() {}
077
078   /**
079    * Creates a {@link Body} element with the specified child nodes.
080    *
081    * @param children The child nodes.
082    */
083   public Body(Object...children) {
084      children(children);
085   }
086
087   /**
088    * <a class="doclink" href="https://www.w3.org/TR/html5/webappapis.html#handler-window-onafterprint">onafterprint</a>
089    * attribute.
090    *
091    * <p>
092    * Event handler for when the document has finished printing.
093    *
094    * @param onafterprint JavaScript code to execute when the afterprint event occurs.
095    * @return This object.
096    */
097   public Body onafterprint(String value) {
098      attr("onafterprint", value);
099      return this;
100   }
101
102   /**
103    * <a class="doclink" href="https://www.w3.org/TR/html5/webappapis.html#handler-window-onbeforeunload">onbeforeunload</a>
104    * attribute.
105    *
106    * <p>
107    * Event handler for when the document is about to be unloaded (page refresh, navigation, etc.).
108    *
109    * @param onbeforeunload JavaScript code to execute when the beforeunload event occurs.
110    * @return This object.
111    */
112   public Body onbeforeunload(String value) {
113      attr("onbeforeunload", value);
114      return this;
115   }
116
117   /**
118    * <a class="doclink" href="https://www.w3.org/TR/html5/webappapis.html#handler-window-onmessage">onmessage</a>
119    * attribute.
120    *
121    * <p>
122    * Event handler for when a message is received from another window or worker.
123    *
124    * @param onmessage JavaScript code to execute when the message event occurs.
125    * @return This object.
126    */
127   public Body onmessage(String value) {
128      attr("onmessage", value);
129      return this;
130   }
131
132   /**
133    * <a class="doclink" href="https://www.w3.org/TR/html5/webappapis.html#handler-window-ononline">ononline</a>
134    * attribute.
135    *
136    * <p>
137    * Event handler for when the browser has gone online.
138    *
139    * @param ononline JavaScript code to execute when the online event occurs.
140    * @return This object.
141    */
142   public Body ononline(String value) {
143      attr("ononline", value);
144      return this;
145   }
146
147   /**
148    * <a class="doclink" href="https://www.w3.org/TR/html5/webappapis.html#handler-window-onpageshow">onpageshow</a>
149    * attribute.
150    *
151    * <p>
152    * Event handler for when the page is displayed (including when returning from back/forward cache).
153    *
154    * @param onpageshow JavaScript code to execute when the pageshow event occurs.
155    * @return This object.
156    */
157   public Body onpageshow(String value) {
158      attr("onpageshow", value);
159      return this;
160   }
161
162   /**
163    * <a class="doclink" href="https://www.w3.org/TR/html5/webappapis.html#handler-window-onstorage">onstorage</a>
164    * attribute.
165    *
166    * <p>
167    * Event handler for when the storage area (localStorage or sessionStorage) is modified.
168    *
169    * @param onstorage JavaScript code to execute when the storage event occurs.
170    * @return This object.
171    */
172   public Body onstorage(String value) {
173      attr("onstorage", value);
174      return this;
175   }
176
177   //-----------------------------------------------------------------------------------------------------------------
178   // Overridden methods
179   //-----------------------------------------------------------------------------------------------------------------
180   @Override /* Overridden from HtmlElement */
181   public Body _class(String value) {  // NOSONAR - Intentional naming.
182      super._class(value);
183      return this;
184   }
185
186   @Override /* Overridden from HtmlElement */
187   public Body accesskey(String value) {
188      super.accesskey(value);
189      return this;
190   }
191
192   @Override /* Overridden from HtmlElement */
193   public Body contenteditable(Object value) {
194      super.contenteditable(value);
195      return this;
196   }
197
198   @Override /* Overridden from HtmlElement */
199   public Body dir(String value) {
200      super.dir(value);
201      return this;
202   }
203
204   @Override /* Overridden from HtmlElement */
205   public Body hidden(Object value) {
206      super.hidden(value);
207      return this;
208   }
209
210   @Override /* Overridden from HtmlElement */
211   public Body id(String value) {
212      super.id(value);
213      return this;
214   }
215
216   @Override /* Overridden from HtmlElement */
217   public Body lang(String value) {
218      super.lang(value);
219      return this;
220   }
221
222   @Override /* Overridden from HtmlElement */
223   public Body onabort(String value) {
224      super.onabort(value);
225      return this;
226   }
227
228   @Override /* Overridden from HtmlElement */
229   public Body onblur(String value) {
230      super.onblur(value);
231      return this;
232   }
233
234   @Override /* Overridden from HtmlElement */
235   public Body oncancel(String value) {
236      super.oncancel(value);
237      return this;
238   }
239
240   @Override /* Overridden from HtmlElement */
241   public Body oncanplay(String value) {
242      super.oncanplay(value);
243      return this;
244   }
245
246   @Override /* Overridden from HtmlElement */
247   public Body oncanplaythrough(String value) {
248      super.oncanplaythrough(value);
249      return this;
250   }
251
252   @Override /* Overridden from HtmlElement */
253   public Body onchange(String value) {
254      super.onchange(value);
255      return this;
256   }
257
258   @Override /* Overridden from HtmlElement */
259   public Body onclick(String value) {
260      super.onclick(value);
261      return this;
262   }
263
264   @Override /* Overridden from HtmlElement */
265   public Body oncuechange(String value) {
266      super.oncuechange(value);
267      return this;
268   }
269
270   @Override /* Overridden from HtmlElement */
271   public Body ondblclick(String value) {
272      super.ondblclick(value);
273      return this;
274   }
275
276   @Override /* Overridden from HtmlElement */
277   public Body ondurationchange(String value) {
278      super.ondurationchange(value);
279      return this;
280   }
281
282   @Override /* Overridden from HtmlElement */
283   public Body onemptied(String value) {
284      super.onemptied(value);
285      return this;
286   }
287
288   @Override /* Overridden from HtmlElement */
289   public Body onended(String value) {
290      super.onended(value);
291      return this;
292   }
293
294   @Override /* Overridden from HtmlElement */
295   public Body onerror(String value) {
296      super.onerror(value);
297      return this;
298   }
299
300   @Override /* Overridden from HtmlElement */
301   public Body onfocus(String value) {
302      super.onfocus(value);
303      return this;
304   }
305
306   @Override /* Overridden from HtmlElement */
307   public Body oninput(String value) {
308      super.oninput(value);
309      return this;
310   }
311
312   @Override /* Overridden from HtmlElement */
313   public Body oninvalid(String value) {
314      super.oninvalid(value);
315      return this;
316   }
317
318   @Override /* Overridden from HtmlElement */
319   public Body onkeydown(String value) {
320      super.onkeydown(value);
321      return this;
322   }
323
324   @Override /* Overridden from HtmlElement */
325   public Body onkeypress(String value) {
326      super.onkeypress(value);
327      return this;
328   }
329
330   @Override /* Overridden from HtmlElement */
331   public Body onkeyup(String value) {
332      super.onkeyup(value);
333      return this;
334   }
335
336   @Override /* Overridden from HtmlElement */
337   public Body onload(String value) {
338      super.onload(value);
339      return this;
340   }
341
342   @Override /* Overridden from HtmlElement */
343   public Body onloadeddata(String value) {
344      super.onloadeddata(value);
345      return this;
346   }
347
348   @Override /* Overridden from HtmlElement */
349   public Body onloadedmetadata(String value) {
350      super.onloadedmetadata(value);
351      return this;
352   }
353
354   @Override /* Overridden from HtmlElement */
355   public Body onloadstart(String value) {
356      super.onloadstart(value);
357      return this;
358   }
359
360   @Override /* Overridden from HtmlElement */
361   public Body onmousedown(String value) {
362      super.onmousedown(value);
363      return this;
364   }
365
366   @Override /* Overridden from HtmlElement */
367   public Body onmouseenter(String value) {
368      super.onmouseenter(value);
369      return this;
370   }
371
372   @Override /* Overridden from HtmlElement */
373   public Body onmouseleave(String value) {
374      super.onmouseleave(value);
375      return this;
376   }
377
378   @Override /* Overridden from HtmlElement */
379   public Body onmousemove(String value) {
380      super.onmousemove(value);
381      return this;
382   }
383
384   @Override /* Overridden from HtmlElement */
385   public Body onmouseout(String value) {
386      super.onmouseout(value);
387      return this;
388   }
389
390   @Override /* Overridden from HtmlElement */
391   public Body onmouseover(String value) {
392      super.onmouseover(value);
393      return this;
394   }
395
396   @Override /* Overridden from HtmlElement */
397   public Body onmouseup(String value) {
398      super.onmouseup(value);
399      return this;
400   }
401
402   @Override /* Overridden from HtmlElement */
403   public Body onmousewheel(String value) {
404      super.onmousewheel(value);
405      return this;
406   }
407
408   @Override /* Overridden from HtmlElement */
409   public Body onpause(String value) {
410      super.onpause(value);
411      return this;
412   }
413
414   @Override /* Overridden from HtmlElement */
415   public Body onplay(String value) {
416      super.onplay(value);
417      return this;
418   }
419
420   @Override /* Overridden from HtmlElement */
421   public Body onplaying(String value) {
422      super.onplaying(value);
423      return this;
424   }
425
426   @Override /* Overridden from HtmlElement */
427   public Body onprogress(String value) {
428      super.onprogress(value);
429      return this;
430   }
431
432   @Override /* Overridden from HtmlElement */
433   public Body onratechange(String value) {
434      super.onratechange(value);
435      return this;
436   }
437
438   @Override /* Overridden from HtmlElement */
439   public Body onreset(String value) {
440      super.onreset(value);
441      return this;
442   }
443
444   @Override /* Overridden from HtmlElement */
445   public Body onresize(String value) {
446      super.onresize(value);
447      return this;
448   }
449
450   @Override /* Overridden from HtmlElement */
451   public Body onscroll(String value) {
452      super.onscroll(value);
453      return this;
454   }
455
456   @Override /* Overridden from HtmlElement */
457   public Body onseeked(String value) {
458      super.onseeked(value);
459      return this;
460   }
461
462   @Override /* Overridden from HtmlElement */
463   public Body onseeking(String value) {
464      super.onseeking(value);
465      return this;
466   }
467
468   @Override /* Overridden from HtmlElement */
469   public Body onselect(String value) {
470      super.onselect(value);
471      return this;
472   }
473
474   @Override /* Overridden from HtmlElement */
475   public Body onshow(String value) {
476      super.onshow(value);
477      return this;
478   }
479
480   @Override /* Overridden from HtmlElement */
481   public Body onstalled(String value) {
482      super.onstalled(value);
483      return this;
484   }
485
486   @Override /* Overridden from HtmlElement */
487   public Body onsubmit(String value) {
488      super.onsubmit(value);
489      return this;
490   }
491
492   @Override /* Overridden from HtmlElement */
493   public Body onsuspend(String value) {
494      super.onsuspend(value);
495      return this;
496   }
497
498   @Override /* Overridden from HtmlElement */
499   public Body ontimeupdate(String value) {
500      super.ontimeupdate(value);
501      return this;
502   }
503
504   @Override /* Overridden from HtmlElement */
505   public Body ontoggle(String value) {
506      super.ontoggle(value);
507      return this;
508   }
509
510   @Override /* Overridden from HtmlElement */
511   public Body onvolumechange(String value) {
512      super.onvolumechange(value);
513      return this;
514   }
515
516   @Override /* Overridden from HtmlElement */
517   public Body onwaiting(String value) {
518      super.onwaiting(value);
519      return this;
520   }
521
522   @Override /* Overridden from HtmlElement */
523   public Body spellcheck(Object value) {
524      super.spellcheck(value);
525      return this;
526   }
527
528   @Override /* Overridden from HtmlElement */
529   public Body style(String value) {
530      super.style(value);
531      return this;
532   }
533
534   @Override /* Overridden from HtmlElement */
535   public Body tabindex(Object value) {
536      super.tabindex(value);
537      return this;
538   }
539
540   @Override /* Overridden from HtmlElement */
541   public Body title(String value) {
542      super.title(value);
543      return this;
544   }
545
546   @Override /* Overridden from HtmlElement */
547   public Body translate(Object value) {
548      super.translate(value);
549      return this;
550   }
551
552   @Override /* Overridden from HtmlElementMixed */
553   public Body child(Object value) {
554      super.child(value);
555      return this;
556   }
557
558   @Override /* Overridden from HtmlElementMixed */
559   public Body children(Object...value) {
560      super.children(value);
561      return this;
562   }
563}