I am trying to show an error message for each row inside a primefaces datatable
Here is my xhtml, I removed some of the tags and some javascript functions are omitted for the sake of clarity
<f:view>
<h:form id="mainEditForm">
<!-- <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true" /> -->
<p:dataTable id="configTable"
value="#{favoriteReportsQueries.myFavoriteReportsQueriesPreferences}"
var="repList"
selection="#{favoriteReportsQueries.selectedFavoriteReportsQueries}"
rowKey="#{repList.reportFavoriteName}">
<p:column headerText="Report / Query">
<h:selectOneMenu id="reportQuery" value="#{repList.reportURL} onchange="submit();" update="reportGivenName">
<f:valueChangeListener type="cmecf.ui.favoritereports.validator.CustomNameValueChangeListener" />
<f:selectItems
value="#{favoriteReportsQueries.applicationReportsAndQueries}"
var="appRepList" itemValue="#{appRepList.value}"
itemLabel="#{appRepList.label}" />
</h:selectOneMenu>
</p:column>
**<p:column headerText="Custom Name">
<p:inputText id="reportGivenName"
value="#{repList.reportFavoriteName}" size="50"/>
<f:validator validatorId="cmecf.favoritereports.CustomValidator" for="reportGivenName"/>
<p:message for="reportGivenName"/>
</p:column>**
<p:column style="width:10px;">
<f:facet name="header">
Delete
</f:facet>
<p:selectBooleanCheckbox id="deleteId"
styleClass="selectBooleanCheckbox"
value="#{repList.delete}">
<p:ajax event="valueChange" process="#this"></p:ajax>
</p:selectBooleanCheckbox>
</p:column>
</p:dataTable>
<h:panelGrid columns="7">
<p:column>
<p:commandButton id="savePrefs"
action="#{favoriteReportsQueries.storeReportsPreferences}"
oncomplete="resizeiFrame()"
value="Save" ajax="false" />
</p:column>
<p:column></p:column>
<p:column>
<p:commandLink value="Add New"
action="#{favoriteReportsQueries.addNewRow}"
oncomplete="resizeiFrame()"
update="configTable" />
</p:column>
<p:spacer width="2px"></p:spacer>
<p:column>
<p:commandLink type="reset" value="Clear"
action="#{favoriteReportsQueries.restorePreferences}"
oncomplete="resizeiFrame()"
update="configTable" ajax="false" />
</p:column>
<p:column></p:column>
<p:column>
<p:commandLink value="Cancel"
action="#{favoriteReportsQueries.cancel}"
ajax="false" />
</p:column>
</h:panelGrid>
</h:form>
</f:view>
I implemented the validator which just returns an error message
import javax.faces.application.FacesMessage;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.validator.FacesValidator;
import javax.faces.validator.Validator;
import javax.faces.validator.ValidatorException;
#FacesValidator("cmecf.favoritereports.CustomValidator")
public class CustomNameValidator implements Validator{
#Override
public void validate(FacesContext context, UIComponent component,
Object value) throws ValidatorException {
FacesMessage msg =
new FacesMessage("Name already exists",
"Invalid name");
msg.setSeverity(FacesMessage.SEVERITY_ERROR);
throw new ValidatorException(msg);
}
}
When I run this app I am getting this error
<f:validator> Parent not composite component or an instance of EditableValueHolder: org.primefaces.component.column.Column#be0296
Thanks in advance
Sai
try this..
<p:inputText id="reportGivenName"
value="#{repList.reportFavoriteName}" size="50">
<f:validator validatorId="cmecf.favoritereports.CustomValidator" />
</p:inputText>
Related
I want to implement Primefaces wizard with finish button at the bottom. Example code:
<h:form>
<p:growl id="growl" sticky="true" showDetail="true"/>
<p:wizard flowListener="#{newSensor.onFlowProcess}">
<p:tab id="personal" title="General">
<p:panel header="Sensor Details">
<p:messages />
<h:panelGrid columns="2" columnClasses="label, value">
......
<h:outputText value="Enabled " />
<h:selectBooleanCheckbox value="#{newSensor.sensor.enabled}" />
</h:panelGrid>
</p:panel>
</p:tab>
<p:tab id="confirm" title="Confirmation">
<p:panel header="Confirmation">
<h:panelGrid id="confirmation" columns="3" columnClasses="grid,grid,grid">
<h:panelGrid columns="2" columnClasses="label, value">
......
<h:outputText value="Age: " />
<h:outputText value="#{newSensor.sensor.enabled}" styleClass="outputLabel"/>
</h:panelGrid>
</h:panelGrid>
<p:commandButton value="Submit" actionListener="#{newSensor.save}" update="growl" process="#this"/>
</p:panel>
</p:tab>
</p:wizard>
</h:form>
Want to get this visual result:
How I can get this visual result?
I think it's best to implement your own UI for the navigation and just control when the Submit button will be displayed.
First hide the navigation bar as such:
<p:wizard showNavBar="false" widgetVar="wiz">
...
</p:wizard>
Then just create some codes for the NEXT,BACK,SUBMIT, ETC.
<p:outputPanel id="updateAsNeeded">
<h:outputLink value="#" onclick="PF('wiz').next();">Next</h:outputLink>
<h:outputLink value="#" onclick="PF('wiz').back();">Back</h:outputLink>
<p:commandButton value="Submit" rendered="#{bean.isEndReached}">Submit</p:commandButton>
</p:outputPanel>
Then you define a FlowListener to determine :
<p:wizard flowListener="#{bean.handleFlow}">
...
</p:wizard>
For your bean:
public String handleFlow(FlowEvent event) {
String currentStepId = event.getCurrentStep();
String stepToGo = event.getNextStep();
//check if stepToGo is on the last page
//endReached = true;
RequestContext.update("updateAsNeeded");
return event.getNextStep();
}
Hope this helps or guides you forward.
I use primefaces in my project and i'm facing some issues with it's components.
I have a dataTabe inside an accordion and both of them are populated with a list in my managed bean. The thing is, before I put this dataTable inside the accordion the filter used to work just fine. When it was into the accordion, actualy the results were corresponding to the filter, but if I click on a comandButton in any row the object that I get from the "f:setPropertyActionListener" is not corresponding to the list after the filter.
Edit:
-Primefaces 6.0
-Dynamic Web Module 3.0
-Java 1.7
-Mojarra JSF Implementation 2.2.3
The .xhtml:
<h:form id="frmPrincipal" enctype="multipart/form-data">
<p:toolbar style="background : none; border:0px">
<f:facet name="left">
<p:commandButton value="Novo Documento" oncomplete="PF('dlgIncluirDocumento').show();"
actionListener="#{MyBean.prepararInclusao()}" update=":frmIncDocVal:pngIncDoc
:frmIncDocVal:pnlTblEmail :frmIncDocVal:pnlEmailNvDoc" />
</f:facet>
</p:toolbar>
<p:accordionPanel dynamic="true" value="#{MyBean.grupos}" var="grupo">
<p:tab title="#{grupo.nome}">
<p:dataTable id="tbValidadeDocFiltrado" widgetVar="#{grupo.idComponente}"
emptyMessage="Nenhum registro enccontrado" lazy="false"
value="#{grupo.documentos}" var="item" filteredValue="#{grupo.documentosFiltrados}"
paginator="true" rows="30" paginatorPosition="bottom" rowsPerPageTemplate="15,30,45">
<f:facet name="header"><p:outputLabel value="Validade Documento" /></f:facet>
<p:column headerText="Empresa" sortBy="#{item.tipoDocumento.empresa.nome}" filterBy="#{item.tipoDocumento.empresa.nome}">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('#{grupo.idComponente}').filter()" >
<f:selectItem itemLabel="Selecione" itemValue="#{null}"
noSelectionOption="true" />
<f:selectItems value="#{MyBean.itensEmpresa}"
var="empresa" itemValue="#{empresa.nome}"
itemLabel="#{empresa.nome}" />
</p:selectOneMenu>
</f:facet>
<p:outputLabel value="#{item.tipoDocumento.empresa.nome}" />
</p:column>
<p:column headerText="Departamento"
sortBy="#{item.tipoDocumento.departamento.nome}"
filterBy="#{item.tipoDocumento.departamento.nome}">
<f:facet name="filter">
<p:selectOneMenu onchange="PF('#{grupo.idComponente}').filter()">
<f:selectItem itemLabel="Selecione" itemValue="#{null}"
noSelectionOption="true" />
<f:selectItems value="#{MyBean.itensDepartamento}"
var="departamento" itemValue="#{departamento.nome}"
itemLabel="#{departamento.nome}" />
</p:selectOneMenu>
</f:facet>
<p:outputLabel value="#{item.tipoDocumento.departamento.nome}" />
</p:column>
<p:column headerText="Documento" sortBy="#{item.tipoDocumento.nome}"
filterBy="#{item.tipoDocumento.nome}">
<p:outputLabel value="#{item.tipoDocumento.nome}" />
</p:column>
<p:column headerText="Arquivo">
<p:commandLink title="Download" value="#{item.arquivo.nome}" ajax="false" onclick="PrimeFaces.monitorDownload(start, stop);" rendered="#{item.cadastroDocumentoDownload}" disabled="#{ ! item.icArquivo}">
<f:setPropertyActionListener value="#{item}" target="#{MyBean.validadeDocumento}" />
<p:fileDownload value="#{MyBean.fileDown}" />
</p:commandLink>
</p:column>
<p:column headerText="Opções" exportable="false" width="160">
<p:commandButton icon="ui-icon-pencil" title="Alterar"
oncomplete="PF('dialog1').show();"
disabled="false" rendered="#{item.cadastroDocumentoEditar}"
action="#{MyBean.prepararAlterarTipoDocumento()}"
update=":idTituloTpDocTituloTelaDlgAlt :frmAltTpDoc:pngAltDoc">
<f:setPropertyActionListener value="#{item}" target="#{MyBean.validadeDocumento}" />
</p:commandButton>
</p:column>
</p:dataTable>
</p:tab>
</p:accordionPanel>
</h:form>
Print with the command button working:
Print with the command button not working after filter:
I'm trying to make editable primefaces datatable. I'm using http://www.primefaces.org/showcase/ui/datatableRowEditing.jsf. All database table data showing up, but then I trying to edit data in a table I'm getting following error:
/index.xhtml #23,90 listener="#{tableBean.onEdit}": Target Unreachable, identifier 'tableBean' resolved to null: javax.el.PropertyNotFoundException: /index.xhtml #23,90 listener="#{tableBean.onEdit}": Target Unreachable, identifier 'tableBean' resolved to null
index.xhtml
<h:head>
<title>index.xhtml</title>
</h:head>
<h:body>
<h:form id="form">
<p:growl id="messages" showDetail="true"/>
<p:dataTable var="u" value="#{logonTest.userList}" id="carList" editable="true">
<f:facet name="header">
In-Cell Editing
</f:facet>
<p:ajax event="rowEdit" listener="#{tableBean.onEdit}" update=":form:messages" />
<p:ajax event="rowEditCancel" listener="#{tableBean.onCancel}" update=":form:messages" />
<p:column headerText="Name" style="width:30%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{u.name}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{u.name}" style="width:100%"/>
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Surname" style="width:20%">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{u.surname}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{u.surname}" style="width:100%" />
</f:facet>
</p:cellEditor>
</p:column>
TableBean.java
public void onEdit(RowEditEvent event) {
FacesMessage msg = new FacesMessage(" Edited", ((User) event.getObject()).getName());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
public void onCancel(RowEditEvent event) {
FacesMessage msg = new FacesMessage(" Cancelled", ((User) event.getObject()).getName());
FacesContext.getCurrentInstance().addMessage(null, msg);
}
I have a smiliar problem like here: Primefaces: commandButton in confirmDialog cannot update datatable in the same form
I have a table with games. In the last column there are 2 buttons: delete and details.
The delete button should delete the game
The button does delete the game but the update doesn't work.
update=":form1:overviewTableGame" --> no reaction (no refresh)
update="#form" --> update performes (table refreshes), but the entire scren is locked. i think due to the fact, that the form which contains the dialog is updated...
The table code:
<h:form id="form1">
<p:messages id="messages" showDetail="true" autoUpdate="true"
closable="true" />
<p:dataTable id="overviewTableGame" var="game" value="#{gameMB.list}">
<p:column headerText="#{msg.ID}" sortBy="#{game.id}">
<h:outputText value="#{game.id}" />
</p:column>
<p:column headerText="#{msg.NAME}" sortBy="#{game.name}">
<h:outputText value="#{game.name}" />
</p:column>
<p:column headerText="#{msg.DESCRIPTION}"
sortBy="#{game.description}">
<h:outputText value="#{game.description}" />
</p:column>
<p:column headerText="#{msg.ADMIN}" sortBy="#{game.admin.firstname}">
<h:outputText value="#{game.admin.firstname}" />
</p:column>
<p:column headerText="#{msg.ACTION}">
<p:commandButton id="commandButtonDELETE" value="löschen"
onclick="confirmation.show()" type="button"
update=":form1:display">
<f:setPropertyActionListener value="#{game}"
target="#{gameMB.selectedGame}" />
</p:commandButton>
<p:commandButton id="commandButtonDETAIL" value="detail"
action="#{gameMB.details()}">
<f:param name="id" value="#{game.id}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:confirmDialog id="confirmDialog"
message="Are you sure about destroying the world?"
header="Initiating destroy process" severity="alert"
widgetVar="confirmation">
<h:panelGrid id="display" columns="2" cellpadding="4"
style="margin:0 auto;">
<h:outputText value="Name:" />
<h:outputText value="#{gameMB.selectedGame.name}"
style="font-weight:bold" />
<p:commandButton id="confirm" value="Yes Sure"
oncomplete="confirmation.hide()"
actionListener="#{gameMB.delete(gameMB.selectedGame)}"
update=":form1:overviewTableGame">
</p:commandButton>
</h:panelGrid>
<p:commandButton id="decline" value="Not Yet"
onclick="confirmation.hide()" type="button" />
</p:confirmDialog>
</h:form>
The Delete Method:
public void delete(Game game) {
//FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO,"DELETE", "Game Deleted!"));
System.out.println("==================");
System.out.println(game);
getGameService().removeGame(game);
//this.gameList = gameService.listAllGames();
}
The selectedGame
private Game selectedGame;
public Game getSelectedGame() {
return selectedGame;
}
public void setSelectedGame(Game selectedGame) {
this.selectedGame = selectedGame;
}
Any ideas?
Thanks
Separate your dialog from p:dataTable. Following code is working:
The xhtml:
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" template="/WEB-INF/templates/globalTemplate.xhtml">
<ui:define name="title">15344819</ui:define>
<ui:define name="content">
<p:growl id="growl" showDetail="true" />
<h:form id="form">
<p:dataTable id="students" value="#{so15344819.students}" var="student">
<p:column>
<p:commandButton id="selectButton" update=":form:display" oncomplete="studentDialog.show()" icon="ui-icon-search" title="View">
<f:setPropertyActionListener value="#{student}" target="#{so15344819.selectedStudent}" />
</p:commandButton>
</p:column>
</p:dataTable>
<p:dialog header="Student Detail" widgetVar="studentDialog" resizable="false" id="studentDlg"
showEffect="fade" hideEffect="explode" modal="true">
<h:panelGrid id="display" columns="2" cellpadding="4" style="margin:0 auto;">
<h:outputText value="Name:" />
<h:outputText value="#{so15344819.selectedStudent.name}" style="font-weight:bold"/>
<p:commandButton id="deleteButton" actionListener="#{so15344819.delete(so15344819.selectedStudent)}" oncomplete="studentDialog.hide()"
update=":form:students" value="Delete"/>
<p:commandButton id="cancelButton" onclick="studentDialog.hide()" value="Cancel"/>
</h:panelGrid>
</p:dialog>
</h:form>
</ui:define>
</ui:composition>
The managed bean:
package app.so.dev.web.controller;
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;
import app.so.dev.web.model.Student;
#ManagedBean(name = "so15344819")
#ViewScoped
public class SO15344819 implements Serializable {
private static final long serialVersionUID = 6686378446131077581L;
private List<Student> students;
private Student selectedStudent;
#PostConstruct
public void init() {
students = new ArrayList<Student>();
students.add(new Student("Student 1"));
students.add(new Student("Student 2"));
}
public void delete(Student student) {
System.out.println("==================");
System.out.println(student);
students.remove(student);
}
public List<Student> getStudents() {
return students;
}
public void setStudents(List<Student> students) {
this.students = students;
}
public Student getSelectedStudent() {
return selectedStudent;
}
public void setSelectedStudent(Student selectedStudent) {
this.selectedStudent = selectedStudent;
}
}
Feel free to revert.
I am using primefaces3.3 version. I have a datatable to show the details and the CRUD buttons as part of the footer of the datatable. A Dialog would be shown on click of the CRUD buttons after selecting a particular row in the datatable.
This dialog contains the input fields with requiredMessage and validationMessage properties and a Save button. When i do not enter any input and click on the save button in the dialog the validation message is showing up. However, upon closing the dialog , only the old data is showing up even if a different row is selected in the datatable. I have attached both the BackingBean and xhtml code.
account.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:f="http://java.sun.com/jsf/core"
xmlns:p="http://primefaces.org/ui">
<h:head>
</h:head>
<h:body>
<ui:composition template="/template.xhtml">
<ui:define name="body">
<h:form id="form" prependId="false">
<p:contextMenu for="dataTable">
<p:menuitem value="View" update=":form2:accountDisplay"
icon="ui-icon-search" oncomplete="accountDialog.show()"
process="#this">
<f:setPropertyActionListener value="#{account}"
target="#{accountBean.selectedAccount}" />
</p:menuitem>
<p:menuitem value="Edit" update=":form2:accountDisplay"
icon="ui-icon-edit" oncomplete="accountDialog.show()"
process="#this" immedeate="true">
<f:setPropertyActionListener value="#{account}"
target="#{accountBean.currentAccount}" />
</p:menuitem>
<p:menuitem value="Delete" update=":dialogForm:confirmDialog"
icon="ui-icon-close" oncomplete="confirmation.show()" />
</p:contextMenu>
<h:panelGroup id="dataPanel">
<p:dataTable var="account" value="#{accountBean.accounts}"
paginator="true" rows="20" rowKey="#{account.accountCode}"
paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
selection="#{accountBean.selectedAccount}" selectionMode="single"
id="dataTable">
<p:column id="accountCode" headerText=" Account Code"
sortBy="#{account.accountCode}" filterBy="#{account.accountCode}"
filterMatchMode="startsWith" footerText="startsWith">
<h:outputText value="#{account.accountCode}" />
</p:column>
<p:column id="accountCode" headerText=" Account Code"
sortBy="#{account.accountDescription}" filterBy="#{account.accountDescription}"
filterMatchMode="startsWith" footerText="startsWith">
<h:outputText value="#{account.accountDescription}" />
</p:column>
<f:facet name="footer">
<p:toolbar>
<p:toolbarGroup align="left">
<p:commandButton id="btnAdd" value="Add" title="Add New Account"
icon="ui-icon-add"
oncomplete="accountDialog.show()" />
<p:commandButton id="editButton" value="Edit" icon="ui-icon-edit"
update=":form2:accountDisplay" oncomplete="accountDialog.show()">
</p:commandButton>
<p:commandButton id="showDialogButton" icon="ui-icon-delete"
value="Delete"
title="Delete Account Details" oncomplete="confirmation.show()">
</p:commandButton>
<p:commandButton id="viewButton" value="View"
icon="ui-icon-search" update=":form2:display"
oncomplete="accountDialog.show()" />
<p:commandButton id="btnRefresh" styleClass="refreshButton"
title="Refresh Account Information" value="Refresh"
icon="ui-icon-refresh"
actionListener="#{accountBean.populateAccounts}"
update=":form:dataTable"/>
</p:toolbarGroup>
</p:toolbar>
</f:facet>
</p:dataTable>
</h:panelGroup>
</h:form>
<h:form id="form2">
<!-- <p:growl id="growl" showDetail="true" sticky="true" /> -->
<p:dialog id="basicDialog" header="Account Details"
widgetVar="detailDialog" resizable="false">
<h:panelGrid id="display" columns="2">
<h:outputText value="#{bundle.AccountLabel_accountCode}" />
<h:outputText value="#{accountBean.selectedAccount.accountCode}"
title="#{bundle.AccountTitle_accountCode}" />
<h:outputText value="#{bundle.AccountLabel_accountDescription}" />
<h:outputText value="#{accountBean.selectedAccount.accountDescription}"
title="#{bundle.AccountTitle_alertCode}" />
</h:panelGrid>
</p:dialog>
<p:dialog header="Account Detail" widgetVar="accountDialog"
resizable="false" height="600" width="600" showEffect="clip"
hideEffect="fold" id="dialog" modal="true">
<h:panelGrid id="accountDisplay" columns="2" cellpadding="4">
<f:facet name="header">
<p:messages id="messages" autoUpdate="true" />
</f:facet>
<h:outputLabel value="Account Code:" for="accountCode" />
<p:inputText label="Account Code" id="accountCode"
value="#{accountBean.selectedAccount.accountCode}"
title="Account Code" required="true"
validatorMessage="#{bundle.AccountValidationAccountCode}" requiredMessage="#{bundle.AccountRequiredMessage_accountCode}">
</p:inputText>
<h:outputLabel value="Account Description:" for="accountDescripition" />
<p:inputText label="Account Description" id="accountDescription"
value="#{accountBean.selectedAccount.accountDescription}"
title="Account Description" required="true"
validatorMessage="#{bundle.AccountValidationAccountDescription}" requiredMessage="#{bundle.AccountRequiredMessage_accountDescription}">
</p:inputText>
<f:facet name="footer">
<!-- <p:commandButton value="New" icon="ui-icon-check"/> -->
<h:outputLabel />
<p:commandButton styleClass="saveButton" value="Save"
icon="ui-icon-check"
actionListener="#{accountBean.createOrUpdate}"
update=":form:dataTable,:form2:accountDisplay" oncomplete="if (!args.validationFailed) {accountDialog.hide();}"/>
<p:commandButton styleClass="cancelButton" value="Cancel"
icon="ui-icon-cancel" oncomplete="accountDialog.hide()" process="#this"/>
</f:facet>
</h:panelGrid>
</p:dialog>
</h:form>
<h:form id="dialogForm">
<p:confirmDialog id="confirmDialog" header="Confirm Delete Account"
severity="alert" widgetVar="confirmation">
<f:facet name="message">
<h:outputText
value="Delete #{accountBean.selectedAccount.accountCode}?" />
</f:facet>
<p:commandButton id="confirm" value="Yes"
oncomplete="confirmation.hide()" update=":form:dataTable"
actionListener="#{accountBean.remove}" ajax="false"/>
<p:commandButton id="decline" value="No"
onclick="confirmation.hide()" type="button" ajax="false"/>
</p:confirmDialog>
</h:form>
</ui:define>
</ui:composition>
AccountBean.java
package com.cba.web.beans;
import java.io.Serializable;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import org.primefaces.context.RequestContext;
import com.cba.services.AccountService;
import com.cba.utils.ServiceLocator;
import com.cba.web.model.Account;
#ManagedBean(name = "accountBean")
#ViewScoped
public class AccountBean implements Serializable {
private transient AccountService accountService;
private List<Account> accounts;
private Account selectedAccount = new Account();
private Account currentAccount = new Account();
public Account getSelectedAccount() {
return selectedAccount;
}
public void setSelectedAccount(Account selectedAccount) {
this.selectedAccount = selectedAccount;
}
public Account getCurrentAccount() {
return currentAccount;
}
public void setCurrentAccount(Account currentAccount) {
this.currentAccount = currentAccount;
}
public AccountBean() {
populateAccounts();
}
public AccountService getAccountService() {
return accountService;
}
public void setAccountService(AccountService accountService) {
this.accountService = accountService;
}
public List<Account> getAccounts() {
return accounts;
}
public void populateAccounts() {
accountService = (AccountService) ServiceLocator.getInstance().getBean(
"accountService");
accounts = accountService.getAccountDetails();
}
public void createOrUpdate(ActionEvent e) {
try {
System.out.println("entering createOrUpdate in AccountBean");
accountService = (AccountService) ServiceLocator.getInstance()
.getBean("accountService");
accountService.updateAccountDetails(selectedAccount);
} catch (Exception ex) {
ex.printStackTrace();
}
}
public void remove(ActionEvent e) {
try {
accountService = (AccountService) ServiceLocator.getInstance()
.getBean("accountService");
accountService.deleteAccountDetails(selectedAccount);
selectedAccount = new Account();
populateAccounts();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
I am using Google Chrome 19 and IE 8. Any input on this would be appreciated. Thanks in advance