operations on validated text fields in jsf - jsf-2

I'm Using Primefaces 3.5. I have around 10 input text fields in my .xhtml page.Few text fields are made mandatory with attribute required="true".
I have a search button that displays Data from Database in a Data Table.The functionality of my page is to insert the values into these fields by on row select() the data in the Data Table of Search Button.
The Problem here is the data is inserting into the Fields which are highlighted with the red border ie fields with validations applied.
Example:
Transport Field has no validation but it had value that has to be inserted. These type of things are happening to many of my Input Fields.
Please give me some suggestions.
.xhtml file is:
<p:inputText id="email" value="#{addcust.c.email}" required="true"
validatorMessage="Enter Valid Email">
<f:validateRegex pattern="^[_A-Za-z0-9-\+]+(\.[_A-Za-z0-9-]+)*#[A-Za-z0-9-]+(\.[A-Za-z0-9]+)*(\.[A-Za-z]{2,})$"/></p:inputText>
<h:outputLabel value="Transport"></h:outputLabel>
<p:inputText value="#{addcust.c.transport}" </p:inputText>
<p:commandButton value="add" type="submit" update=":form,:msg" actionListener="#{addcust.onAddSelect}"</p:commandButton>
<p:commandButton value="Search" type="submit" onclick="ser.show() "></p:commandButton>
<p:dialog id="dialog11" header=" Search" widgetVar="ser" resizable="false" showEffect="fade"
hideEffect="explode" >
<p:dataTable id="dt" var="sd" value="#{addcust.al}" selection="#{addcust.c}">
<p:ajax event="rowSelect" update=":form" listener="#{addcust.onRowSelect}"
oncomplete="ser.hide()"/>
<p:column>
<f:facet name="header">
<h:outputText value="Email"/>
</f:facet>
<h:outputText value="#{sd.email}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Transport"/>
</f:facet>
<h:outputText value="#{sd.transport}"/>
</p:column>
</p:dataTable>
customerbean.java
public class customerbean {
private String email;
private String transport;
public String getTransport() {
return transport;
}
public void setTransport(String transport) {
this.transport = transport;
}
return email;
}
public void setEmail(String email) {
this.email = email;
}
addcust.java
public customerbean c = new customerbean();
public ArrayList<customerbean> al;
public void onAddSelect(){
// Inserted my values into customer table.
}
public void onSearchSelect() {
try {
st = con.createStatement();
ResultSet rs = st.executeQuery("select * from customer where cmpid=" + getCurrcompanyid() + "");
al = new ArrayList<customerbean>();
while (rs.next()) {
customerbean s = new customerbean();
s.setEmail(rs.getString(1));
s.setTransport(rs.getString(2));
}
} catch (Exception e) {
System.out.println(e);
}
}
public void onRowSelect(SelectEvent event) throws SQLException {
customerbean r = (customerbean)event.getObject();
c = r;
}
If I'm not clear enough please leave me a comment .Thanks for Reading.

Related

Rendered attribute for PrimeFaces datatable not working

I have a primeface table that shows data from an database stored in a List called notificationList based on a search from. I want the table to be displayed after the submit button is clicked however after I add the rendered attribute the table not displaying at all. Can someone tell what I'm doing wrong and how to fix it? I've tried two methods to do this.
Using rendered=#{not empty notificationSearchBean.results.notificationList} which didn't work even though the list isn't empty (I know bc I printed out the results in the console)
Creating a boolean called visible like in this post "Want to show a data table populated with data after a button click". This also isn't displaying the table regardless of whether visible is set to true or false. What's weird is that I've tried initializing visible with true and the table is still not being rendered.
This is my code for the table:
<h:panelGroup id = "table-wrapper" styleClass="searchResults">
<h:form id="result" >
<p:dataTable id="notTable" var="notifications" value="#{notificationSearchBean.results.notificationList}" row="15">
<p:column headerText="Notification No.">
<h:outputText value="#{notifications.notificationNo}"/>
</p:column>
<p:column headerText="Service">
<h:outputText value="#{notifications.srvce}"/>
</p:column>
<p:column headerText="Operation">
<h:outputText value="#{notifications.oprtn}"/>
</p:column>
<p:column headerText="Service Version">
<h:outputText value="#{notifications.srvceVrsn}"/>
</p:column>
<p:column headerText="Event Date">
<h:outputText value="#{notifications.evntDt}" >
<f:convertDateTime pattern="dd-MMM-yyyy 'at' HH:mm:ss.SSS" />
</h:outputText>
</p:column>
</p:dataTable>
</h:form>
</h:panelGroup>
And code for the submit button:
<h:panelGrid align="center" columns="2">
<p:commandButton value="Start Search" action="#{notificationSearchBean.getAllNotificationsForQuery}" update="table-wrapper"/>
</h:panelGrid>
And the NotificationSearchBean:
#ManagedBean(name = "notificationSearchBean" )
#SessionScoped
public class NotificationSearchBean implements Serializable {
private static final long serialVersionUID = 1L;
private TransactionsDao transactionsDao = (TransactionsDao)((Login)FacesContext.getCurrentInstance().getExternalContext().getSessionMap().get("login")).getTransDao();
#Inject
private SearchCriteria search;
#Inject
private ResultSet results;
#PostConstruct
public void initialize() {
//setting attributes for search form
}
//getters and setters for search
public ResultSet getResults() {
return results;
}
public void setResults(ResultSet results) {
this.results = results;
}
public String getAllNotificationsForQuery() {
List<NotificationLogT> notifications=transactionsDao.getAllNotifications(this.search);
int temp=notifications.size();
this.results.setNotificationList(notifications);
if(temp==0){
//prints out not results return message
}
return "success";
}
}
And also the ResultSet class:
public class ResultSet implements Serializable {
private List<NotificationLogT> notificationList;
private boolean visible = false;
//private Integer dataSize;
public boolean isVisible() {
return visible;
}
public void setVisible(boolean visible) {
this.visible = visible;
}
public List<NotificationLogT> getNotificationList() {
setVisible(true);
return notificationList;
}
public void setNotificationList(List<NotificationLogT> notificationList) {
this.notificationList = notificationList;
}
}

To fetch checkbox selected values from primefaces datatable to managed bean

I am trying to fetch the checkbox selected values selectedCars from primefaces datatable to my managed bean named TableBean.I am getting null pointer exception at the point where I am trying to fetch the values in the function getSelection() please help me with this
My JSF page:
<h:form id="form">
<p:dataTable id="multiCars" var="car"
value="#{tableBean.mediumCarsModel}" paginator="true" rows="10"
selection="#{tableBean.selectedCars}">
<f:facet name="header">
Checkbox Based Selection
</f:facet>
<p:column selectionMode="multiple" style="width:2%" />
<p:column headerText="Model" style="width:25%">
#{car.model}
</p:column>
<p:column headerText="Year" style="width:25%">
#{car.year}
</p:column>
<p:column headerText="Manufacturer" style="width:24%">
#{car.manufacturer}
</p:column>
<p:column headerText="Color" style="width:24%">
#{car.color}
</p:column>
<f:facet name="footer">
<p:commandButton id="multiViewButton" value="View"
icon="ui-icon-search" update=":form:displayMulti"
oncomplete="multiCarDialog.show()" />
</f:facet>
</p:dataTable>
<p:dialog id="multiDialog" header="Car Detail"
widgetVar="multiCarDialog" height="300" showEffect="fade"
hideEffect="explode">
<p:dataList id="displayMulti" value="#{tableBean.selectedCars}"
var="selectedCar">
Model: #{selectedCar.model}, Year: #{selectedCar.year}
</p:dataList>
</p:dialog>
</h:form>
My managed bean
#SessionScoped
#ManagedBean
public class TableBean implements Serializable {
private List<Car> cars;
private Car[] selectedCars;
private CarDataModel mediumCarsModel;
Connection connection;
Statement stmt;
ResultSet rs;
public TableBean() {
cars = new ArrayList<Car>();
getCars();
getSelection();
mediumCarsModel = new CarDataModel(cars);
}
public Car[] getSelectedCars() {
return selectedCars;
}
public void setSelectedCars(Car[] selectedCars) {
this.selectedCars = selectedCars;
}
public void getCars() {
int i = 0;
try {
Class.forName("net.sourceforge.jtds.jdbc.Driver");
connection = DriverManager.getConnection("jdbc:jtds:sqlserver://cvgapp106I/dev2_LPSR");
System.out.println("connected to the database");
stmt = connection.createStatement();
ResultSet rs = stmt.executeQuery("select * from test");
while(rs.next()) {
cars.add(i,new Car(rs.getString("Model"),rs.getInt("Year"),rs.getString("Manufacturer"),rs.getString("Color")));
i++;
}
} catch (Exception e) {
e.printStackTrace();
}
}
public void getSelection() {
System.out.println(selectedCars[0].getModel());
}
public CarDataModel getMediumCarsModel() {
return mediumCarsModel;
}
public void setMediumCarsModel(CarDataModel mediumCarsModel) {
this.mediumCarsModel = mediumCarsModel;
}
}
public void getSelection() {
System.out.println(selectedCars[0].getModel());
}
This will throw NullPointerException if the list is empty.
If you really want to use this then you should try check if the list not null
if(selectedCars!=null && !selectedCars.isEmpty()){
System.out.println(selectedCars[0].getModel());
}
Do not call getSelection() in your constructor. There selectedCars will be always null

NumberFormatException for input String in datatable

I have the following method in my DAO where I retrieve a list of persons :
public List<Personne> getAllUsers() {
Query query = em.createQuery("SELECT p FROM Personne p where TYPE(p) =Utilisateur");
#SuppressWarnings("unchecked")
List <Personne> personnes = query.getResultList();
return personnes;
}
I want to show the list of persons in a datatable :
<p:dataTable value="#{desacBean.users}" var="us" paginator="true" selection="# {desacBean.selectedUser}" selectionMode="single" rowKey="#{desacBean.getId(us)}}" first="1">
<p:ajax event="rowSelect" listener="#{desacBean.onUserSelect}"/>
<p:column>
<f:facet name="n">
<h:outputText value="nom" />
</f:facet>
<h:outputText value="#{us.nom}"/>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="prenom" />
</f:facet>
<h:outputText value="#{us.prenom}"/>
</p:column>
</p:dataTable>
my BEAN :
#ManagedBean(name="desacBean")
#SessionScoped
public class DesactiveBean implements Serializable{
private static final long serialVersionUID = 1L;
private List<Personne> users = new ArrayList<Personne>();
private Personne selectedUser;
private boolean panelRendered;
UserDAO daoUser = new UserDaoImpl();
public void rowSelect(SelectEvent event){
selectedUser = (Personne)event.getObject();
System.out.println("selectedUser = "+selectedUser.getNom_ut());
this.panelRendered = true;
}
public int getId(Personne car)
{
return System.identityHashCode(car);
}
public void onUserSelect(SelectEvent event){
this.selectedUser = (Personne)event.getObject();
System.out.println("selectedUser = "+selectedUser.getNom_ut());
}
I have the following error when trying to show this dataTable :
java.lang.NumberFormatException: For input string: "prenom"
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:492)
at java.lang.Integer.parseInt(Integer.java:527)
For input string: "prenom"
how can I fix it?
You'll probably encountering the same issue as the question answered here: NumberFormatException for input String

Primefaces Collector Remove not working

I am testing the primefaces collector example given in Showcase for my code
I read somewhere that its necessary to override the equals and hashcode method for that.
Even after overriding the methods , I am still getting the same error.
Kindly tell me whats wrong in my code
User.java
#ManagedBean
public class User implements Serializable{
public String name;
public String designation;
public String division;
public User(String name,String division){
setName(name);
setDivision(division);
}
public User(){
}
public String getDesignation() {
return designation;
}
public void setDesignation(String designation) {
this.designation = designation;
}
public String getDivision() {
return division;
}
public void setDivision(String userDivision) {
this.division = userDivision;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
}
commApprover.java
#ManagedBean
#ViewScoped
public class CommApprover implements Serializable{
private User approver = new User();
private List<User> approvers = new ArrayList<User>();
public String reinit() {
approver = new User();
return null;
}
public User getApprover() {
return approver;
}
public void setApprover(User approver) {
this.approver = approver;
}
public List<User> getApprovers() {
return approvers;
}
public void setApprovers(List<User> approvers) {
this.approvers = approvers;
}
#Override
public boolean equals(Object o)
{
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
if (approver!= null ? !approver.equals(this.approver) : this.approver != null)
return false;
return true;
}
#Override
public int hashCode()
{
int result = approver.hashCode();
return result;
}
}
index.xhtml
<p:growl id="msgs" />
<p:panel header="Approval Route ">
<h:panelGrid columns="3" id="grid">
<h:outputText value="Name*" />
<h:outputText value="Designation*" />
<h:outputText value="Division*" />
<p:inputText id="app_name" value="#{commApprover.approver.name}" required="true"/>
<p:inputText id="app_designation" value="#{commApprover.approver.designation}" required="true"/>
<p:inputText id="app_division" required="true" value="# {commApprover.approver.division}" />
<p:commandButton id="btn_add" value="Add" update="approvers #parent" action="#{commApprover.reinit}" >
<p:collector value="#{commApprover.approver}" addTo="#{commApprover.approvers}" />
</p:commandButton>
</h:panelGrid>
</p:panel>
<p:outputPanel id="approvers">
<p:dataTable id="approversTable" value="#{commApprover.approvers}" var="approver">
<p:column>
<f:facet name="header">
<h:outputText value="Name" />
</f:facet>
<h:outputText value="#{approver.name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Designation" />
</f:facet>
<h:outputText value="#{approver.designation}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Division" />
</f:facet>
<h:outputText value="#{approver.division}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="Operation" />
</f:facet>
<p:commandLink ajax="true" value="Remove" update=":appform:approvers" process=":appform:approvers">
<p:collector value="#{approver}" removeFrom="#{commApprover.approvers}" />
</p:commandLink>
</p:column>
</p:dataTable>
</p:outputPanel>
</h:form>
This post is old but I ran into the same problem and after some debuging I found out that this problem is related to incorrectly implemented hashCode and equals, when using converters or p:collector you have to implement hashCode and equals to compare all fields in your entity otherwise it fails even if the item you are trying to remove is the correct one. Also it is recomended that you override those properties in your Pojo not in you ManagedBean. This post helped me to understand the problem https://blog.art-of-coding.eu/jsf-converters-and-equals-hashcode/

How to do CRUD operation with PrimeFaces datatable

I have one datatable created with a PrimeFaces 3.3 datatable. This table is populated from a database.
On a row selection, I populate similar fields for editing. Once edited, I want to write to the db. Similarly, I want to be able to create a new record in text items and once the user saves it the datatable to be refreshed.
Data selection works fine, however, when I cant figure out way for add/edit/delete, different errors come with different approach and I have tried all methods I could find on Google. These errors are some time logical errors and some times nullpointerexception or class initiation errors. I have tried over a dozen examples available on net for jtable + crud but seems nothing works fine for me.
For example, data is displayed in data table and instant selection in the text fields is also done but when i click add button, nothing happens, I expect fields in 'edit properties' panel to be cleared, sometimes I get a NullPointerException, even if I modify values in text items and press save, values are not written. When I debugged, I found error coming in em.getTransaction().begin line.
If I use em.joinTransaction it again throws an error on the commit statement. Since I am new to Java EE I think I am making some terrible mistakes.
I will appreciate if some one can give some example of a similar scenario: jtable + bound fields + add / edit / delete operations.
below is my code:
#Entity
#Table(name = "users")
#XmlRootElement
#NamedQueries({
#NamedQuery(name = "Users.findAll", query = "SELECT u FROM Users u"),
#NamedQuery(name = "Users.findByIduser", query = "SELECT u FROM Users u WHERE u.iduser = :iduser"),
#NamedQuery(name = "Users.findByLogin_Name", query = "SELECT u FROM Users u WHERE u.login_name = :login_name"),
#NamedQuery(name = "Users.findByFullName", query = "SELECT u FROM Users u WHERE u.fullName = :fullName"),
#NamedQuery(name = "Users.findByPassword", query = "SELECT u FROM Users u WHERE u.password = :password"),
#NamedQuery(name = "Users.authenticate", query = "SELECT u FROM Users u WHERE u.login_name = :login_name and u.password = :password and u.active=1"),
#NamedQuery(name = "Users.findByActive", query = "SELECT u FROM Users u WHERE u.active = :active"),
#NamedQuery(name = "Users.findByUserType", query = "SELECT u FROM Users u WHERE u.userType = :userType"),
#NamedQuery(name = "Users.findByEmail", query = "SELECT u FROM Users u WHERE u.email = :email"),
#NamedQuery(name = "Users.findByPhone", query = "SELECT u FROM Users u WHERE u.phone = :phone"),
#NamedQuery(name = "Users.findByCreated", query = "SELECT u FROM Users u WHERE u.created = :created"),
#NamedQuery(name = "Users.findByUpdated", query = "SELECT u FROM Users u WHERE u.updated = :updated")})
public class Users implements Serializable {
#Basic(optional = false)
#NotNull
#Column(name = "created")
#Temporal(TemporalType.TIMESTAMP)
private Date created;
#Basic(optional = false)
#NotNull
#Column(name = "updated")
#Temporal(TemporalType.TIMESTAMP)
private Date updated;
private static final long serialVersionUID = 1L;
#Id
#GeneratedValue(strategy = GenerationType.AUTO )
#Basic(optional = false)
#NotNull
#Column(name = "iduser")
private Integer iduser;
//getter & setters ....
#Stateless
public class UsersFacade extends AbstractFacade<Users> {
#PersistenceContext(unitName = "VUProjectPU")
private EntityManager em;
///////////////////////////////////////////////////////////////////////////////
#Override
protected EntityManager getEntityManager() {
return em;
}
///////////////////////////////////////////////////////////////////////////////
public UsersFacade() {
super(Users.class);
}
///////////////////////////////////////////////////////////////////////////////
public Users authenticate(String login_id, String pwd) {
List <Users> userList = new ArrayList();
Users user =null;
userList = em.createNamedQuery("Users.authenticate")
.setParameter("login_name", login_id)
.setParameter("password", pwd)
.getResultList();
if (userList.isEmpty()) {
return null;
}
else{
user = userList.get(0);
}
return user;
}
///////////////////////////////////////////////////////////////////////////////
public Users deactivateUser (Users u){
u.setActive(false);
return u;
}
///////////////////////////////////////////////////////////////////////////////
public Users activateUser (Users u){
u.setActive(true);
return u;
}
///////////////////////////////////////////////////////////////////////////////
public Users createAnalyst(Users u){
u.setActive(false);
u.setUserType("Analyst");
u.setCreated(new Date());
u.setUpdated(new Date());
em.persist(u);
em.flush();
em.refresh(u);
return u;
}
}
#ManagedBean
#ViewScoped
public class UsersList implements Serializable {
private List<Users> uList;
private Users selUser ;
private Users user;
private String operation;
private #EJB UsersFacade ufs;
private FacesContext context;
private FacesMessage msg;
private Boolean edit=false;
public UsersList(){
ufs = new UsersFacade();
}
public void getAllUsersList(){
uList=ufs.findAll();
}
public Boolean isEdit() {
return edit;
}
public void add(){
context = FacesContext.getCurrentInstance();
operation = "new";
edit=true;
selUser = new Users();
}
public void save(){
context = FacesContext.getCurrentInstance();
if (operation.equals("new")){
ufs.create(selUser);
}
ufs.save(selUser);
operation = null;
msg = new FacesMessage(FacesMessage.SEVERITY_INFO,"Success", "Record Saved");
context.addMessage(null, msg);
edit=false;
getAllUsersList(); //refresh table
}
public void delete(Users u){
context = FacesContext.getCurrentInstance();
ufs.delete(u);
msg = new FacesMessage(FacesMessage.SEVERITY_INFO,"Success", "Record Deleted");
context.addMessage(null, msg);
}
public void refresh(){
context = FacesContext.getCurrentInstance();
getAllUsersList();
msg = new FacesMessage(FacesMessage.SEVERITY_INFO,"Success", "Data Refreshed");
context.addMessage(null, msg);
}
public List<Users> getuList() {
uList = ufs.findAll();
return uList;
}
public void setuList(List<Users> uList) {
this.uList = uList;
}
public Users getSelUser() {
return selUser;
}
public void setSelUser(Users selUser) {
this.selUser = selUser;
}
public void onRowSelect(SelectEvent event) {
edit=true;
context = FacesContext.getCurrentInstance();
msg = new FacesMessage("User Selected", ((Users) event.getObject()).getLogin_name());
context.addMessage(null, msg);
}
public void onRowUnSelect(UnselectEvent event) {
edit=false;
context = FacesContext.getCurrentInstance();
msg = new FacesMessage("User Unselected", ((Users) event.getObject()).getLogin_name());
context.addMessage(null, msg);
}
public Users getUser() {
return user;
}
}
below is user.xhtml
<?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:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://java.sun.com/jsf/core">
<body>
<ui:composition template="./../../WEB-INF/Templates/Template.xhtml">
<ui:define name="menu">
</ui:define>
<ui:define name="content">
<h:form id="form">
<p:growl id="growl" showDetail="true"/>
<p:dataTable id="utable" var="users"
value="#{usersList.getuList()}"
selection="#{usersList.selUser}"
rowKey="#{users.iduser}"
selectionMode="single"
paginator="true" rows="5"
paginatorPosition="bottom"
editable="true"
>
<p:ajax event="rowSelect" listener="#{usersList.onRowSelect}" update=":form:display :form:growl" />
<p:ajax event="rowUnselect" listener="#{usersList.onRowUnSelect}" update=":form:growl"/>
<f:facet name="header">
List of Users
</f:facet>
<p:column id="login" sortBy ="#{users.login_name}">
<f:facet name="header">Login</f:facet>
<h:outputText value="#{users.login_name}" />
</p:column>
<p:column id="fullname" sortBy ="#{users.fullName}">
<f:facet name="header">User Name</f:facet>
<h:outputText value="#{users.fullName}" />
</p:column>
<p:column id="email" sortBy ="#{users.email}">
<f:facet name="header">E-mail</f:facet>
<h:outputText value="#{users.email}" />
</p:column>
<p:column id="phone" sortBy ="#{users.phone}">
<f:facet name="header">Phone</f:facet>
<h:outputText value="#{users.phone}" />
</p:column>
<p:column id="created" sortBy ="#{users.created}">
<f:facet name="header">Created On</f:facet>
<h:outputText value="#{users.created}" />
</p:column>
<p:column id="active" sortBy ="#{users.active}">
<f:facet name="header">Active</f:facet>
<h:outputText value="#{users.active}" />
</p:column>
<p:column id="userType" sortBy ="#{users.userType}">
<f:facet name="header">User Type</f:facet>
<h:outputText value="#{users.userType}" />
</p:column >
</p:dataTable>
<p:panel header="Edit User Properties">
<h:panelGrid id="display" columns="6" cellpadding="4" >
<h:outputText value="Login:" />
<p:inputText readonly="#{usersList.edit}"
value="#{usersList[usersList.edit ? 'user' : 'selUser'].login_name}" />
<h:outputText value="Password:" />
<p:inputText readonly="#{usersList.edit}"
value="#{usersList[usersList.edit ? 'user' : 'selUser'].password}" />
<h:outputText value="User Name:" />
<p:inputText readonly="#{usersList.edit}"
value="#{usersList[usersList.edit ? 'user' : 'selUser'].fullName}" />
<h:outputText value="E-mail:" />
<p:inputText readonly="#{usersList.edit}"
value="#{usersList[usersList.edit ? 'user' : 'selUser'].email}" />
<h:outputText value="Phone:" />
<p:inputText readonly="#{usersList.edit}"
value="#{usersList[usersList.edit ? 'user' : 'selUser'].phone}" />
<h:outputText value="User Type:" />
<p:inputText readonly="#{usersList.edit}"
value="#{usersList[usersList.edit ? 'user' : 'selUser'].userType}" />
<h:outputText value="Active:" />
<p:selectBooleanCheckbox
value="#{usersList[usersList.edit ? 'user' : 'selUser'].active}"/>
</h:panelGrid>
<h:panelGrid id="command" columns="6" cellpadding="4" >
<p:commandButton id="new" value="New" actionListener="#{usersList.add()}"
update="result,utable,display"
rendered="#{usersList.edit}}">
</p:commandButton>
<p:commandButton id="save" value="Save" actionListener="#{usersList.save()}" update="result utable">
</p:commandButton>
<p:commandButton id="delete" value="Delete" actionListener="#{usersList.delete()}" update="result utable">
</p:commandButton>
<p:commandButton id="refresh" value="Refresh" actionListener="#{usersList.refresh()}" update="result utable">
</p:commandButton>
</h:panelGrid>
<p:messages id="result" showDetail="true" autoUpdate="true"/>
</p:panel>
</h:form>
</ui:define>
</ui:composition>
</body>
</html>

Resources