有人可以推薦任何框架來促進JSF 2.0中的CRUD開發嗎?推薦的JSF 2.0 CRUD框架
方面I值最:
- 作爲輕質成爲可能; 第三方庫有限依賴
- 支持的進化域模型
- 有限公司需要進行重複編碼;支持腳手架和/或metaannotations
任何提示高度讚賞! 您的 J.
有人可以推薦任何框架來促進JSF 2.0中的CRUD開發嗎?推薦的JSF 2.0 CRUD框架
方面I值最:
任何提示高度讚賞! 您的 J.
CRUD確實是使用JSF 2.0提供的標準設施的一塊蛋糕:@ViewScoped
bean與<h:dataTable>
組合基本上已經足夠。這是一個代碼示例,從this article無恥複製。
豆:
package com.example;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
@ManagedBean
@ViewScoped
public class Bean implements Serializable {
private List<Item> list;
private Item item = new Item();
private boolean edit;
@PostConstruct
public void init() {
// list = dao.list();
// Actually, you should retrieve the list from DAO. This is just for demo.
list = new ArrayList<Item>();
list.add(new Item(1L, "item1"));
list.add(new Item(2L, "item2"));
list.add(new Item(3L, "item3"));
}
public void add() {
// dao.create(item);
// Actually, the DAO should already have set the ID from DB. This is just for demo.
item.setId(list.isEmpty() ? 1 : list.get(list.size() - 1).getId() + 1);
list.add(item);
item = new Item(); // Reset placeholder.
}
public void edit(Item item) {
this.item = item;
edit = true;
}
public void save() {
// dao.update(item);
item = new Item(); // Reset placeholder.
edit = false;
}
public void delete(Item item) {
// dao.delete(item);
list.remove(item);
}
public List<Item> getList() {
return list;
}
public Item getItem() {
return item;
}
public boolean isEdit() {
return edit;
}
// Other getters/setters are actually unnecessary. Feel free to add them though.
}
頁:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:h="http://java.sun.com/jsf/html">
<h:head>
<title>Really simple CRUD</title>
</h:head>
<h:body>
<h3>List items</h3>
<h:form rendered="#{not empty bean.list}">
<h:dataTable value="#{bean.list}" var="item">
<h:column><f:facet name="header">ID</f:facet>#{item.id}</h:column>
<h:column><f:facet name="header">Value</f:facet>#{item.value}</h:column>
<h:column><h:commandButton value="edit" action="#{bean.edit(item)}" /></h:column>
<h:column><h:commandButton value="delete" action="#{bean.delete(item)}" /></h:column>
</h:dataTable>
</h:form>
<h:panelGroup rendered="#{empty bean.list}">
<p>Table is empty! Please add new items.</p>
</h:panelGroup>
<h:panelGroup rendered="#{!bean.edit}">
<h3>Add item</h3>
<h:form>
<p>Value: <h:inputText value="#{bean.item.value}" /></p>
<p><h:commandButton value="add" action="#{bean.add}" /></p>
</h:form>
</h:panelGroup>
<h:panelGroup rendered="#{bean.edit}">
<h3>Edit item #{bean.item.id}</h3>
<h:form>
<p>Value: <h:inputText value="#{bean.item.value}" /></p>
<p><h:commandButton value="save" action="#{bean.save}" /></p>
</h:form>
</h:panelGroup>
</h:body>
</html>
此外,Netbeans的具有some useful wizards到genreate基於一個數據模型一個CRUD應用。
JSF 2.0本身。 CRUD很容易處理JSF,不需要任何其他框架。您需要
@ManagedBean
註釋)<h:dataTable>
與edit
鏈接/按鈕,通過它你設置託管bean中的當前行對象(使用action="#{bean.edit(currentRowObject)}"
)。 (在JSF 1.2這是通過<f:setPropertyActionListener>
實現)void
,不帶參數)來處理的操作@PostConstruct
初始加載數據。我發現這篇文章有用的:EE 6
http://www.andygibson.net/blog/tutorial/pattern-for-conversational-crud-in-java-ee-6/
會話CRUD在Java中通過安迪·吉布森
我有同樣的問題描述:在JEE6中儘可能快地創建CRUD-App。
美麗的發電機在發現:http://sourceforge.net/projects/jbizmo/
定義(圖形編輯器後!)您的業務模型/域模型,JBizMo創建數據庫和一個完整的CRUD-App。
@ Jav_Rock,Michael Leitner我在哪裏可以找到JBizMo的教程? – Sam 2013-08-27 07:59:04
@Sampath本教程也位於sourceforge的下載(= Files)部分。 – 2013-12-30 18:49:20
我創造了這個一個加快的過程jsf crud應用程序創建:https://github.com/ignl/happyfacescrud 即時搜索,懶惰數據表,查看/編輯,自定義組件,大幅降低代碼,當然靈活。
我發現JSF + Primefaces
http://minuteproject.wikispaces.com/Primefaces
一個開源的CRUD發電機並且還產生了最http://minuteproject.wikispaces.com/
跨越Krank剛剛來到框架的CRUD,但它不是非常活躍:HTTP ://code.google.com/p/krank/不支持JSF2,但我喜歡這些想法。這是否激勵某人? – Jan 2010-07-06 14:51:39
爲什麼不使用一些可以爲你生成「crud應用程序」的工具?例如,Netbeans可以這樣做http://netbeans.org/kb/docs/web/jsf20-crud.html – corsair 2012-09-13 12:35:20