I have an entity that contain an attribute with #ElementCollection annotation. This attribute is a list of String that I add telphones(telefones). I display this telphones at a dataTable of primefaces.
How I can remove this telphone with row selected ?
I'm trying this.
Entity
#Entity
public class UnidadeEscolar implements Serializable{
private static final long serialVersionUID = 1L;
#Id #GeneratedValue(strategy=GenerationType.AUTO)
private Long id;
#NotNull #Size(min=5, message="Informe o nome da unidade escolar")
#Column(unique=true)
private String nome;
private String departamento;
#Embedded
private Endereco endereco;
#ElementCollection
#JoinTable(name="telefones_ue", joinColumns=#JoinColumn(name="ue_id"))
private List<String> telefones = new ArrayList<String>();
/** adiciona telefones */
public void addTelefone(String tel){
telefones.add(tel);
}
/** remove telefone */
public void removeTelefone(int row){
telefones.remove(row);
}
Managed Bean
#ManagedBean
#ViewScoped
public class UnidadeEscolarMB implements Serializable{
private static final long serialVersionUID = 1L;
private UnidadeEscolar bean;
private GenericDAO<UnidadeEscolar> dao;
private List<UnidadeEscolar> unidades = null;
private String telefone = "";
/** add telphone to entity */
public void addTelefones(){
//System.out.println(telefone);
bean.addTelefone(telefone);
telefone = "";
}
/** remove telphone of entity */
public void removeTelefone(){
bean.getTelefones().remove(telefone);
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
xhtml
<p:tab title="Contato">
<p:fieldset legend="Telefones">
<p:dataTable id="tabelaTelefones" widgetVar="datalistTelefones"
value="#{unidadeEscolarMB.bean.telefones}" var="fone"
emptyMessage="Nenhum registro encontrado"
selectionMode="single"
selection="#{unidadeEscolarMB.telefone}"
rowKey="#{unidadeEscolarMB.bean.id}"
>
<p:column headerText="Telefone">
<h:outputText value="#{fone}"/>
</p:column>
</p:dataTable>
<p:commandButton actionListener="#{unidadeEscolarMB.removeTelefone()}" value="-" update="tabelaTelefones"/>
</p:tab>
How I can delete telphone selected at dataTable ?
I solved the problem using <f:setPropertyActionListener/>
here how I did
<p:tab title="Contato">
<p:fieldset legend="Telefones">
<p:dataTable id="tabelaTelefones" widgetVar="datalistTelefones"
value="#{unidadeEscolarMB.bean.telefones}" var="fone"
emptyMessage="Nenhum registro encontrado"
>
<p:column headerText="Telefone">
<h:outputText value="#{fone}"/>
</p:column>
<p:column headerText="">
<p:commandLink action="#{unidadeEscolarMB.removeTelefone()}" value="Excluir" update="tabelaTelefones">
<f:setPropertyActionListener target="#{unidadeEscolarMB.telefone}" value="#{fone}"/>
</p:commandLink>
</p:column>
</p:dataTable>
<p:inputMask id="telefone" widgetVar="telefoneMask" value="#{unidadeEscolarMB.telefone}" mask="(99)9-9999-9999" />
<p:commandButton actionListener="#{unidadeEscolarMB.addTelefones()}" value="+" update="telefone, tabelaTelefones"/>
<p:selectBooleanCheckbox itemLabel="Adiciona9" onchange="setMaskTelefone()" id="checkBox" widgetVar="ckbox9" value="true" immediate="true"/>
</p:fieldset>
</p:tab>
#ManagedBean
#ViewScoped
public class UnidadeEscolarMB implements Serializable{
private static final long serialVersionUID = 1L;
private UnidadeEscolar bean;
private GenericDAO<UnidadeEscolar> dao;
private List<UnidadeEscolar> unidades = null;
private String telefone = "";
/** adiciona telefone ao bean */
public void addTelefones(){
//System.out.println(telefone);
bean.addTelefone(telefone);
telefone = "";
}
/** remove telefone do bean */
public void removeTelefone(){
bean.getTelefones().remove(telefone);
telefone = "";
}
public String getTelefone() {
return telefone;
}
public void setTelefone(String telefone) {
this.telefone = telefone;
}
Related
I am having a problem with showing cell value using primefaces datatable. Originally table was displaying fields from only one entity class (Document). I needed to add additional field from another class (DocData). I managed to do that by adding the transient field "oib" into the Document class (field name oib is stored in the third class DocTypeField).
The problem now is that after inserting new row only fields from Document class are displayed. Refresh page also doesn't help. Only thing that will result with displaying new data (oib) is server restart.
This is my database model:
This is Document class:
#Entity
#Table(name="ACQ_DOCUMENT")
#NamedQuery(name="Document.findAll", query="SELECT a FROM Document a")
#NoArgsConstructor
#ViewScoped
public #Data class Document implements Serializable {
private static final long serialVersionUID = 2611447987879527170L;
#Id
#SequenceGenerator(name = "DocumentSEQ",sequenceName = "ACQ_DOCUMENT_SEQ",allocationSize=1)
#GeneratedValue(strategy = GenerationType.IDENTITY,generator = "DocumentSEQ" )
#Column(name="DOCUMENT_ID")
private Integer id;
#Column(name="DOCUMENT_FIRST_NAME")
private String firstName;
#Column(name="DOCUMENT_LAST_NAME")
private String lastName;
#ManyToOne
#JoinColumn(name="DOCUMENT_DOC_TYPE_ID")
private DocType docType;
#OneToMany
#JoinColumn(name="DATA_DOCUMENT_ID")
private List<DocData> docData;
#Transient
private String oib;
public String getOib() {
if (oib == null) {
for(DocData dd : docData) {
if(dd.getDocTypeField().getName().equals("oib") && (dd.getDocument().getId().equals(id))) {
oib = dd.getStringValue();
}
}
}
return oib;
}
public void setOib(String oib){
this.oib = oib;
}
#Override
public String toString() {
return this.getClass().getName() + "[id=" + id + "]";
}
}
This is DocTypeField class:
#Entity
#Table(name="ACQ_DOC_TYPE_FIELD")
#NamedQuery(name="DocTypeField.findAll", query="SELECT a FROM DocTypeField a")
#NoArgsConstructor
public #Data class DocTypeField implements Serializable {
private static final long serialVersionUID = 2109749245241103862L;
#Id
#GeneratedValue(strategy=GenerationType.SEQUENCE, generator="ACQ_DOC_TYPE_FIELD_SEQ")
#Column(name="FIELD_ID")
private Integer id;
#Column(name="FIELD_NAME")
private String name;
#Column(name="field_type")
private String type;
//bi-directional many-to-one association to AcqDocType
#ManyToOne
#JoinColumn(name="FIELD_DOC_TYPE_ID")
private DocType docType;
#Column(name="field_active")
private Boolean active;
#Override
public String toString() {
return this.getClass().getName() + "[id=" + id + "]";
}
}
This is DocData class:
#Entity
#Table(name="ACQ_DOC_DATA")
#NamedQuery(name="DocData.findAll", query="SELECT a FROM DocData a")
#NoArgsConstructor
public #Data class DocData implements Serializable {
private static final long serialVersionUID = 915219051205073130L;
#Id
#SequenceGenerator(name = "DocDataSEQ",sequenceName = "ACQ_DOC_DATA_SEQ",allocationSize=1)
#GeneratedValue(strategy = GenerationType.IDENTITY,generator = "DocDataSEQ" )
#Column(name="DATA_ID")
private Integer id;
#Temporal(TemporalType.DATE)
#Column(name="DATA_DATE_VALUE")
private Date dateValue;
#Column(name="DATA_DECIMAL_VALUE")
private BigDecimal decimalValue;
#Column(name="DATA_INT_VALUE")
private Integer intValue;
#Column(name="DATA_STRING_VALUE")
private String stringValue;
#Lob
#Column(name="DATA_TEXT_VALUE")
private String textValue;
#Column(name="DATA_TIMESTAMP_VALUE")
private Timestamp timestampValue;
//bi-directional many-to-one association to AcqBlobValue
#OneToOne(cascade=CascadeType.ALL)
#JoinColumn(name="DATA_BLOB_VALUE_ID")
private BlobValue blobValue;
//bi-directional many-to-one association to AcqDocTypeField
#ManyToOne
#JoinColumn(name="DATA_DOC_TYPE_FIELD_ID")
private DocTypeField docTypeField;
//bi-directional many-to-one association to AcqDocument
#ManyToOne
#JoinColumn(name="DATA_DOCUMENT_ID")
private Document document;
#Override
public String toString() {
return this.getClass().getName() + "[id=" + id + "]";
}
}
And finally this is datatable definition:
<p:dataTable lazy="true" id="documents" var="item" value="#{documentManager.lazyModel}" selection="#{documentManager.formObject}"
selectionMode="single" rowKey="#{item.id}" sortBy="#{item.id}" sortMode="single"
paginator="true" rows="15" paginatorPosition="bottom" styleClass="alignTop">
<p:ajax event="rowSelect" listener="#{documentManager.onRowSelect}" />
<f:facet name="header">#{e['adrDocument']}</f:facet>
<p:column width="10%" sortBy="#{item.id}">
<f:facet name="header">#{e['adrDocument.id']}</f:facet>
<h:outputText value="#{item.id}" />
</p:column>
<p:column width="10%" sortBy="#{item.firstName}">
<f:facet name="header">#{e['adrDocument.firstName']}</f:facet>
<h:outputText value="#{item.firstName}" />
</p:column>
<p:column width="10%" sortBy="#{item.lastName}">
<f:facet name="header">#{e['adrDocument.lastName']}</f:facet>
<h:outputText value="#{item.lastName}" />
</p:column>
<p:column width="10%" sortBy="#{item.docType.descr}">
<f:facet name="header">#{e['adrDocument.tipDokumenta']}</f:facet>
<h:outputText value="#{item.docType.descr}" />
</p:column>
<p:column width="10%" sortBy="#{item.oib}">
<f:facet name="header">#{e['adrDocument.oib']}</f:facet>
<h:outputText value="#{item.oib}" />
</p:column>
<p:confirmDialog global="true" width="250">
<p:commandButton value="#{m['ui.edit.confirm.yes']}" type="button" styleClass="ui-confirmdialog-yes" icon="ui-icon-check"/>
<p:commandButton value="#{m['ui.edit.confirm.no']}" type="button" styleClass="ui-confirmdialog-no" icon="ui-icon-close"/>
</p:confirmDialog>
</p:dataTable>
So, item.oib isn't properly displayed. I also tried removing lazyloading, different oib fetching and so on... Have no more ideas.
Want to filter the resultset of a query which is displayed through a datatable. The row selection, row sorting clicking on column headers and the pagination functionnalities of the datatable works fine. When I add the primefaces filtering functionnality to the datatable, I then run into the
javax.faces.FacesException: DataModel must implement
org.primefaces.model.SelectableDataModel when selection is enabled.
Object Entity:
#Entity
#Table(name="Customer",
uniqueConstraints={#UniqueConstraint(columnNames={"ID"})})
public class Customer {
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
#Column(name="ID", nullable=false, unique=true, length=11)
private Integer id;
#Column(name="LASTNAME", length=40, nullable=false)
private String lastName;
#Column(name="FIRSTNAME", length=30, nullable=true)
private String firstName;
....
}
Managed Bean:
#ManagedBean(name = "customerController")
#ViewScoped
public class CustomerController implements Serializable {
private static final long serialVersionUID = 1L;
private Customer selectedCustomer = new Customer();
private List<Customer> customers = new ArrayList<Customer>();
private String message;
public CustomerController() {
}
#PostConstruct
void init() {
CustomerDAO custDAO = new CustomerDAO();
customers = custDAO.getAllCustomers();
// select first row
if (customers != null) selectedCustomer=customers.get(0);
}
public void onRowSelect(SelectEvent event) {
message = "";
}
public void onRowUnselect(UnselectEvent event) {
message = "";
}
// getters and setters
...
}
Facelet:
<ui:define name="contentPart1" >
<h:form id="contentPart1Form">
<p:dataTable id="singleSelection" var="customer" value="#{customerController.customers}" rowKey="#{customer.id}"
selection="#{customerController.selectedCustomer}" selectionMode="single" paginator="true" rows="10">
<p:ajax event="rowSelect" listener="#{customerController.onRowSelect}" />
<p:column headerText="#{msg['customerCRUD.labelIdentifier']}" style="width:15%;">
<h:outputText value="#{customer.id}" readonly="#{facesContext.currentPhaseId.ordinal eq 6}"/>
</p:column>
<p:column headerText="#{msg['customerCRUD.labelFirstName']}" sortBy="#{customer.firstName}" style="width:30%;">
<h:outputText value="#{customer.firstName}" />
</p:column>
<p:column headerText="#{msg['customerCRUD.labelLastName']}" filterBy="#{customer.lastName}" filterMatchMode="contains"
sortBy="#{customer.lastName}">
<h:outputText value="#{customer.lastName}" />
</p:column>
<f:facet name="footer">
<h:outputText value=" "/>
</f:facet>
</p:dataTable>
</h:form>
</ui:define>
After hours of investigation, I finally realized the object entity on which I was appliyng the filter to was not serializable.
The resolution was to inherit the object entity from the Serialization class.
#Entity
#Table(name="Customer",
uniqueConstraints={#UniqueConstraint(columnNames={"ID"})})
public class Customer implements Serializable{
/**
*
*/
private static final long serialVersionUID = 1L;{
#Id
#GeneratedValue(strategy=GenerationType.IDENTITY)
#Column(name="ID", nullable=false, unique=true, length=11)
private Integer id;
#Column(name="LASTNAME", length=40, nullable=false)
private String lastName;
#Column(name="FIRSTNAME", length=30, nullable=true)
private String firstName;
....
}
I have an object with this attributes: Id, name and status, and I have a List of this object. I want to save the status (enable or disable) for each element.
You can use SelectManyCheckbox Primefaces Component.
<p:selectManyCheckbox id="checkboxTest" value="#{myBean.selectedElements}">
<f:selectItems value="#{myBean.myElements}" var="elem" itemLabel="#{elem.value}" itemValue="#{elem.id}" />
</p:selectManyCheckbox>
You need to create in your backing bean a list that will be filled by the selected element (selectedElements in the example above) and use your list of object (myElements) to create the checkbox on the page. In this way on submit you will have the "selectedElements" list filled with the checked items.
See more:
Primefaces ManyCheckbox
here is a general example (using <h:dataTable...>):
XHTML:
<h:form>
<h:dataTable var="row" value="#{categoryMan.items}">
<h:column>
<h:selectBooleanCheckbox value="#{row.enabled}">
</h:selectBooleanCheckbox>
</h:column>
<h:column>
<h:outputText value="#{row.id}"></h:outputText>
</h:column>
<h:column>
<h:outputText value="#{row.name}"></h:outputText>
<f:facet name="footer">
<h:commandButton action="#{categoryMan.save}" value="Save">
</h:commandButton>
</f:facet>
</h:column>
</h:dataTable>
</h:form>
YourBean:
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.SessionScoped;
#ManagedBean(name="categoryMan")
#SessionScoped
public class CategoryManager implements Serializable {
private static final long serialVersionUID = -8453216983786165042L;
private List<Category> items;
public CategoryManager() {
}
#PostConstruct
private void init(){
try{
this.items = new ArrayList<Category>();
this.items.add(new Category("PS2001", "JSF", false));
this.items.add(new Category("PS2002", "ASP", true));
this.items.add(new Category("PS2002", "PHP", false));
}catch(Exception e){
e.printStackTrace();
}
}
public String save() {
for(Category cat: this.items){
System.out.println(cat.getName()+": "+cat.isEnabled());
}
return "yourNavigationRule";
}
public List<Category> getItems() {
return items;
}
public void setItems(List<Category> items) {
this.items = items;
}
}
Your Object:
import java.io.Serializable;
public class Category implements Serializable{
private static final long serialVersionUID = -8070175380194294502L;
private String id;
private String name;
private boolean enabled;
public Category(String id, String name, boolean enabled) {
super();
this.id = id;
this.name = name;
this.enabled = enabled;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
}
This is how i have displayed the list of dynamic checkboxes with specific question.
<p:row styleClass="ui-panelgrid-cell" rowspan="3">
<p:column>
<div style="overflow: auto; width: 100%;">
<p:dataTable var="tQuestions"
value="#{userPreferences.availableQuestions}"
emptyMessage="No Questions Found." id="sTable">
<p:column>
<h:outputText id="sName" styleClass="cellLabelMand"
value="#{tQuestions.shortText}" />
<h:outputText value="<br/><br/>" escape="false" />
<ui:repeat var="tCategoryList" value="#{tQuestions.categoryList}">
<p:selectBooleanCheckbox value="checked" />
<h:outputText value="#{tCategoryList.categoryValue}" />
</ui:repeat>
</p:column>
</p:dataTable>
</div>
</p:column>
</p:row>
I'm trying create a filter to one dataTable. I want that filter works with all keywords contained in datatable.
I am following examples at: http://www.primefaces.org/showcase/ui/data/datatable/filter.xhtml
but I can't do this works.
The problem is when I enter with any keywords the dataTable is clear showing message "No keyword found", if I delete keyword all results doesn't returns and message "No keyword found" keeps.
How can I solve this problem ?
Here how I'm trying.
XHTML
<p:dataTable id="tabelaAlunos" widgetVar="tableAlunos"
value="#{alunoMB.alunos}" var="x"
emptyMessage="No keyword found"
selectionMode="single"
selection="#{matriculaMB.aluno}"
rowKey="#{x.id}"
filteredValue="#{alunoMB.alunos}"
>
<f:facet name="header">
<p:outputPanel>
<h:outputText value="Filtrar: " />
<p:inputText id="globalFilter"
onkeyup="PF('tableAlunos').filter()"
style="width:150px" placeholder="Filtro"/>
</p:outputPanel>
</f:facet>
<p:column headerText="Nome">
<h:outputText value="#{x.nome}"/>
</p:column>
<p:column headerText="Sobrenome">
<h:outputText value="#{x.sobreNome}"/>
</p:column>
<p:column headerText="Endereço">
<h:outputText value="#{x.endereco.endereco}"/>
</p:column>
<p:column headerText="Número">
<h:outputText value="#{x.endereco.numero}"/>
</p:column>
<p:column headerText="Cidade">
<h:outputText value="#{x.endereco.cidade}"/>
</p:column>
<p:column headerText="Bairro">
<h:outputText value="#{x.endereco.bairro}"/>
</p:column>
<p:column headerText="Unidade escolar">
<h:outputText value="#{x.unidadeEscolar.nome}"/>
</p:column>
</p:dataTable>
Managed Bean Aluno
#ManagedBean
#ViewScoped
public class AlunoMB implements Serializable{
private static final long serialVersionUID = 1L;
private Aluno bean;
private GenericDAO<Aluno> dao;
private List<Aluno> alunos = null;
private String[] sexo = {"M", "F"};
private String telefone = "";
/** persiste o objeto */
public void insert(Aluno a){
dao = new GenericDAO<Aluno>(Aluno.class);
dao.insert(a);
alunos.add(a);
bean = new Aluno();
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso" ,"Cadastro realizado com sucesso!"));
}
/** altera o objeto */
public void update(Aluno a){
dao = new GenericDAO<Aluno>(Aluno.class);
dao.update(a);
}
/** prepara para inserir o objeto */
public void prepareCreate(){
bean = new Aluno();
}
/** retorna o objeto */
public Aluno getBean() {
return bean;
}
/** define o objeto */
public void setBean(Aluno bean) {
this.bean = bean;
}
/** retorna uma lista do objeto */
public List<Aluno> getAlunos() {
if(alunos == null){
dao = new GenericDAO<Aluno>(Aluno.class);
alunos = dao.findAll();
}
return alunos;
}
/** seta uma lista do objeto */
public void setAlunos(List<Aluno> alunos) {
this.alunos = alunos;
}
Managed Bean Matricula
#ManagedBean
#ViewScoped
public class MatriculaMB implements Serializable{
private static final long serialVersionUID = 1L;
private Matricula bean = new Matricula();
private GenericDAO<Matricula> dao;
private List<Matricula> matriculas = null;
private Turma turma;
private Aluno aluno = null;
/** persiste um novo objeto */
public void insert(Matricula m){
dao = new GenericDAO<Matricula>(Matricula.class);
dao.insert(m);
matriculas.add(m);
bean = new Matricula();
FacesContext context = FacesContext.getCurrentInstance();
context.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Sucesso" ,"Cadastro realizado com sucesso!"));
}
/** altera o objeto existente */
public void update(Matricula m){
dao = new GenericDAO<Matricula>(Matricula.class);
dao.update(m);
}
/** prepara para inserir uma nova matricula */
public void prepareCreate(){
bean = new Matricula();
}
/** retorna o objeto */
public Matricula getBean() {
return bean;
}
/** define o objeto */
public void setBean(Matricula bean) {
this.bean = bean;
}
/** retorna uma lista do objeto */
public List<Matricula> getMatriculas() {
dao = new GenericDAO<Matricula>(Matricula.class);
if(matriculas == null){
matriculas = dao.findAll();
}
return matriculas;
}
public Turma getTurma() {
return turma;
}
public void setTurma(Turma turma) {
this.turma = turma;
}
/** adiciona turma ao aluno */
public void addTurmaAluno(){
if(!bean.getAluno().getTurmas().contains(turma)){
bean.getAluno().addTurmas(this.turma);
}
}
public Aluno getAluno() {
return aluno;
}
public void setAluno(Aluno aluno) {
this.aluno = aluno;
bean.setAluno(this.aluno);
}
Just add a filteBy for each column.
<p:column headerText="Nome" filterBy="#{x.nome}">
<h:outputText value="#{x.nome}"/>
</p:column>
i have a rare situation in my page i have a "p:autoComplete" which is bind to a backing bean i can read that auto complete item form the backing bean.
but the problem is the selected value from that auto complete need to be passed as a parameter, when user pressed the button, with some other parameters. which i really don't know how to do it?
this is my page which has the autocomplete
<p:panel header="Employee sales" style="width:500px"
toggleable="true" toggleSpeed="500" closeSpeed="500">
<p:autoComplete id="user_auto_complete"
value="#{salesReportMainController.userFromAutoComplete}"
completeMethod="#{salesReportMainController.completeUser}"
var="user" itemLabel="#{user.userName}" itemValue="#{user}"
converter="#{userConverter}" forceSelection="true" />
<p:commandButton id="Search" value="Generate"
action="admin_common_barchart">
<f:param name="todaysDate"
value="#{salesReportMainController.todaysDate}" />
<f:param name="beforDate"
value="#{salesReportMainController.dateBeforOneYear}" />
<f:param name="employeeName"
value="#{salesReportMainController.userFromAutoComplete.userName}" />
</p:commandButton>
</p:panel>
and this is the backing bean that binds to that page
#ViewScoped
public class SalesReportMainController implements Serializable{
private static final long serialVersionUID = 1L;
#ManagedProperty(value = "#{userService}")
public UserService userService;
public DateTime todaysDate;
public DateTime dateBeforOneYear;
public DateTime dateBeforsixMonths;
public List<User> allUsers;
public List<User> acFilterdUsers;
public User userFromAutoComplete;
#PostConstruct
public void init(){
int oneYear = ConstantConfiguration.YearsInMonths.ONE_YEAR.getValue();
int sixMonths = ConstantConfiguration.YearsInMonths.SIX_MONTH.getValue();
todaysDate = new DateTime();
dateBeforOneYear = new DateTime(todaysDate).minusMonths(oneYear);
dateBeforsixMonths = new DateTime(todaysDate).minusMonths(sixMonths);
}
// public String buttonClick(){
// System.out.println("aaaaaaaa");
// return null;
// }
public List<User> completeUser(String query) {
allUsers = userService.getAllUsers();
acFilterdUsers = new ArrayList<User>();
for (User user : allUsers) {
if(user.getUserName().toLowerCase().startsWith(query)){
acFilterdUsers.add(user);
}
}
return acFilterdUsers;
}
public String getAutoCompleteUser() {
if (userFromAutoComplete != null) {
//i can get the value of the selected item form auto complete
}
return null;
}
//getters and setters
}
and this is the page that i want to load
<h:form id="common_chart_form" prependId="flase">
<p:growl id="growl" showDetail="true" autoUpdate="true"
sticky="false" />
<p:outputLabel id="labelvalue" value="aaaaaaaaaa"/>
<p:chart id="chart" type="bar"
model="#{commonChartController.barModel}" style="height:600px" />
<p:commandButton value="Print" type="button" icon="ui-icon-print">
<p:printer target="chart" />
</p:commandButton>
<p:commandButton value="Back" action="admin_sales_reports" />
</h:form>
and this the backing bean of the above page
#Component
#ManagedBean
#RequestScoped
public class CommonChartController implements Serializable{
private static final long serialVersionUID = 1L;
#ManagedProperty(value = "#{orderService}")
public OrderService orderService;
#ManagedProperty(value = "#{userService}")
public UserService userService;
List<MonthSales> salesList;
private BarChartModel barModel;
#PostConstruct
public void init() {
String dateTo = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("todaysDate");
String dateFrom = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("beforDate");
String employeeName = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("employeeName");
System.out.println("user Name : "+employeeName);
if(employeeName != null && !employeeName.equals("")){
User user = userService.getUserByUserName("admin");
salesList = orderService.getMonthlySalesByUserName(UserUtility.stringDateToJodaDateTime(dateFrom).toDate(), UserUtility.stringDateToJodaDateTime(dateTo).toDate(), user);
createBarModel(salesList, user);
}else {
salesList = orderService.getMonthlySales(UserUtility.stringDateToJodaDateTime(dateFrom).toDate(), UserUtility.stringDateToJodaDateTime(dateTo).toDate());
createBarModel(salesList);
}
//
// salesList = orderService.getMonthlySales(UserUtility.stringDateToJodaDateTime(dateFrom).toDate(), UserUtility.stringDateToJodaDateTime(dateTo).toDate());
// createBarModel(salesList);
}
}
i can read the "dateTo" param and "dateFrom" param. problem is "employeeName" param is alwayas null