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.marshall.*; 020 021/** 022 * DTO for an HTML <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#the-table-element"><table></a> 023 * element. 024 * 025 * <p> 026 * The table element represents data with more than one dimension, in the form of a table. It contains 027 * rows and columns of data, with optional headers and footers. The table element is used to display 028 * tabular data in a structured format, making it easy to read and understand. It can contain 029 * caption, colgroup, thead, tbody, tfoot, and tr elements to organize the table structure. 030 * 031 * <h5 class='section'>Examples:</h5> 032 * <p class='bcode w800'> 033 * <jk>import static</jk> org.apache.juneau.bean.html5.HtmlBuilder.*; 034 * 035 * <jc>// Simple table with headers and data</jc> 036 * Table <jv>simple</jv> = <jsm>table</jsm>( 037 * <jsm>thead</jsm>( 038 * <jsm>tr</jsm>( 039 * <jsm>th</jsm>(<js>"Name"</js>), 040 * <jsm>th</jsm>(<js>"Age"</js>), 041 * <jsm>th</jsm>(<js>"City"</js>) 042 * ) 043 * ), 044 * <jsm>tbody</jsm>( 045 * <jsm>tr</jsm>( 046 * <jsm>td</jsm>(<js>"John"</js>), 047 * <jsm>td</jsm>(<js>"25"</js>), 048 * <jsm>td</jsm>(<js>"New York"</js>) 049 * ) 050 * ) 051 * ); 052 * 053 * <jc>// Table with caption and styling</jc> 054 * Table <jv>styled</jv> = <jsm>table</jsm>( 055 * <jsm>caption</jsm>(<js>"Employee Information"</js>), 056 * <jsm>thead</jsm>( 057 * <jsm>tr</jsm>( 058 * <jsm>th</jsm>(<js>"ID"</js>), 059 * <jsm>th</jsm>(<js>"Name"</js>), 060 * <jsm>th</jsm>(<js>"Department"</js>) 061 * ) 062 * ) 063 * ).class_(<js>"data-table"</js>).border(1); 064 * 065 * <jc>// Table with multiple sections</jc> 066 * Table complex = new Table() 067 * .children( 068 * new Caption().children("Sales Report"), 069 * new Thead() 070 * .children( 071 * new Tr() 072 * .children( 073 * new Th().children("Product"), 074 * new Th().children("Q1"), 075 * new Th().children("Q2") 076 * ) 077 * ), 078 * new Tbody() 079 * .children( 080 * new Tr() 081 * .children( 082 * new Td().children("Widget A"), 083 * new Td().children("100"), 084 * new Td().children("150") 085 * ) 086 * ), 087 * new Tfoot() 088 * .children( 089 * new Tr() 090 * .children( 091 * new Td().children("Total"), 092 * new Td().children("100"), 093 * new Td().children("150") 094 * ) 095 * ) 096 * ); 097 * </p> 098 * 099 * <h5 class='section'>See Also:</h5><ul> 100 * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanHtml5">juneau-bean-html5</a> 101 * </ul> 102 */ 103@Marshalled(typeName = "table") 104public class Table extends HtmlElementContainer<Table> { 105 106 /** 107 * Creates an empty {@link Table} element. 108 */ 109 public Table() {} 110 111 /** 112 * Creates a {@link Table} element with the specified child nodes. 113 * 114 * @param children The child nodes. Must not be <jk>null</jk>. 115 */ 116 public Table(Object...children) { 117 children(children); 118 } 119 120 /** 121 * <a class="doclink" href="https://www.w3.org/TR/html5/tabular-data.html#attr-table-border">border</a> attribute. 122 * 123 * @param value 124 * The new value for this attribute. 125 * Typically a {@link Number} or {@link String}. 126 * Can be <jk>null</jk> to unset the attribute. 127 * @return This object. 128 */ 129 public Table border(Object value) { 130 attr("border", value); 131 return this; 132 } 133 134}