JSF 2.0
PrimeFaces-2.2.RC2
Code: Select all
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.prime.com.tr/ui"
xmlns:f="http://java.sun.com/jsf/core">
<h:head>
<title>Facelet Title</title>
</h:head>
<h:body>
<h:form id="form1">
<p:panel header="#{msgs.standardName}">
<h:panelGrid columns="2">
<h:outputLabel value="id" />
<h:inputText value="#{stdAuditMastController.record.id}" />
....
<p:commandButton value="#{msgs.reset}" type="reset" />
<p:commandButton value="#{msgs.add}" update="stdauditmast_id" action="#{stdAuditMastController.insert}">
<p:collector value="#{stdAuditMastController.record}" addTo="#{stdAuditMastController.records}" />
</p:commandButton>
</h:panelGrid>
</p:panel>
<p:ajaxStatus style="width:16px;height:16px;">
<f:facet name="start">
<h:graphicImage value="../#{msgs.ajaxLoading}" />
</f:facet>
<f:facet name="complete">
<h:outputText value="" />
</f:facet>
</p:ajaxStatus>
<p:outputPanel id="stdauditmast_id">
<p:dataTable value="#{stdAuditMastController.records}" var="record" paginator="true" rows="10"
selection="#{stdAuditMastController.selectedRow}"
rowSelectListener="#{stdAuditMastController.onRowSelectNavigate}"
dblClickSelect="true">
<f:facet name="header">
In-Cell Editing
</f:facet>
<p:column headerText="ID">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{record.id}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{record.id}" style="width: 100px" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="#{msgs.auditCode}">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{record.auditCode}" />
</f:facet>
<f:facet name="input">
<h:inputText value="#{record.auditCode}" style="width: 100px" />
</f:facet>
</p:cellEditor>
</p:column>
...
<p:column headerText="Options">
<p:rowEditor />
</p:column>
</p:dataTable>
</p:outputPanel>
</h:form>
</h:body>
</html>
Code: Select all
import com.fellows.dot.hibernate.dao.tat_plugged.Stdauditmast;
import com.fellows.dot.hibernate.impl.tat_plugged.StdauditmastImpl;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import org.primefaces.event.RowEditEvent;
import org.primefaces.event.SelectEvent;
/**
*
* @author Administrator
*/
@ViewScoped
public class StdAuditMastController implements Serializable {
private StdauditmastImpl stdAuditmastImpl;
private Stdauditmast selectedRow;
private Stdauditmast record = new Stdauditmast();
private List<Stdauditmast> records = new ArrayList<Stdauditmast>();
/** Creates a new instance of StdAuditMastController */
public StdAuditMastController() {
initialize();
selectedRow = new Stdauditmast();
}
private void initialize() {
record = new Stdauditmast();
stdAuditmastImpl = new StdauditmastImpl();
records = stdAuditmastImpl.getAllRecord();
}
public Stdauditmast getRecord() {
return record;
}
public void setRecord(Stdauditmast record) {
this.record = record;
}
public List<Stdauditmast> getRecords() {
return records;
}
public void setRecords(List<Stdauditmast> records) {
this.records = records;
}
public Stdauditmast getSelectedRow() {
return selectedRow;
}
public void setSelectedRow(Stdauditmast selectedRow) {
this.selectedRow = selectedRow;
}
public String insert() {
System.out.println("StdAuditMast.insert()");
return null;
}
public String remove() {
System.out.println("StdAuditMast.remove()");
return null;
}
//DataTable Event Handlers
public String onRowSelectNavigate(SelectEvent event) {
System.out.println("onrowSelectNavigate");
FacesContext.getCurrentInstance().getExternalContext().getFlash().put("selectedStdauditmast", event.getObject());
return "stdlist?faces-redirect=true";
}