jsf初學資料表 DataTable 的繫結

2022-02-14 05:11:18 字數 2684 閱讀 4867

來看看簡單的datatable例子:

faces:

<

h:form

>

<

h:datatable

value

="#"

var="name"

>

<

h:column

>

#,

h:column

>

<

h:column

>

#

h:column

>

h:datatable

>

h:form

>

view code

在上面的頁面中有幾個屬性值得注意,

value:表示資料來源,一般為list、arraylist、陣列等,是從bean得到的資料

var:可以看著是資料來源中的一條資料的別名。

在看看bean如下:

@named //

or @managedbean

@sessionscoped

public

class tabledata implements

serializable ;

public name getnames()

}

view code

就這樣乙個簡單datatable例子。

在開發中一般**都是有表頭和表尾的,表頭在datatable中用表示。修改下上面faces如下:

<

h:datatable

value

="#"

var="name"

>

<

h:column

>

<

f:facet

name

="header"

>last

f:facet

>

#,

h:column

>

<

h:column

>

<

f:facet

name

="header"

>first

f:facet

>

#

h:column

>

h:datatable

>

view code

當然樣式是可以自己控制的。

二:在我們快速開發中特別是在mvc中使用html標籤很多。這裡還有一種方法來代替datatable比如下面的例子:

<

table

class

="table-list"

>

<

thead

>

<

tr>

<

th>

th>

<

th style

="width:140px"

>

isbn

th>

<

th style

="width:182px"

>

書名

th>

<

th>

出版日期

th>

<

th>

單價

th>

tr>

thead

>

<

tbody

>

<

ui:repeat

value

="#"

var="name"

varstatus

="status"

>

<

tr>

<

td>#

td>

<

td>

#

td>

<

td title

="#"

>

<

input

type

="text"

readonly

="readonly"

value

="#"

style

="background-color:#ffffff; border:1px; width:180px;"

/>

td>

<

td>

#

td>

<

td>

#

td>

tr>

ui:repeat

>

tbody

>

table

>

<

ui:repeat>來代替datatable。

repeat的具體用法和datatable一樣。。

建立資料表和修改資料表

建立表 sql中建立和刪除資料庫物件的語句被稱為資料定義語言 data definition language,ddl 操作這些物件中資料的語句被稱為資料操作語言 data manipulation language,dml 建立語句屬於ddl,用create table命令 create temp...

庫房資料表

已生成 2015 05 23 08 33 49 伺服器 postgresql 9.4 localhost 5432 資料庫 v9 架構 public 名稱 資料型別 非空?主鍵?預設注釋 autoid integer是是 nextval b warehouse autoid seq regclass...

資料表操作

1 建立資料表 create table if not exists table name column name data type,2 檢視資料表 show tables show tables from mysql 3 檢視資料表結構 show columns from tbl name 4 ...