7
Good night! Here’s my problem:
I’m making a screen that has two calendars:
The program will return me a list that comprises the interval between two dates. One date is from the first calendar, and the other from the second calendar.
However, my code below is not working.
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:p="http://primefaces.org/ui">
<h:head>
<title>Sistema de Integração Moriah</title>
<style type="text/css">
#painel {
font-family: geneva, arial, helvetica, sans-serif;
font-size: 100%;
margin-top: 220px;
margin-left: 300px;
margin-right: 300px;
text-align: center;
}
#form {
padding-left: 60px;
}
</style>
</h:head>
<body>
<ui:decorate template="menubardecorate.xhtml"></ui:decorate>
<p:panel header="Selecione como deseja as Ordens de Serviço" id="painel">
<h:form id="form">
<h:panelGrid columns="5">
<p:outputLabel value="Datas da OS:" />
<p:outputLabel for="de" value="De:" />
<p:calendar id="de" value="#{ListaOsBean.dataDe}" mindate="01/01/10" maxdate="" update="ate" />
<p:outputLabel for="ate" value="Até:" />
<p:calendar id="ate" value="{ListaOsBean.dataAte}" mindate="#{ListaOsBean.getDataDe()}" maxdate="" />
</h:panelGrid>
</h:form>
</p:panel>
</body>
</html>
The "#{ListaOsBean.dataDe}"
is not receiving the date passed by the user, and is not returning to the other <p:calendar/>
in mindate="#{ListaOsBean.getDataDe()}"
.
What I want is that as soon as I click on the date of the first calendar, it will only be available in the second calendar, the numbers after the date I selected in the first. In this way:
My Bean is like this:
package br.com.moriahitg.bean;
import br.com.moriahitg.dao.SZA990DAO;
import br.com.moriahitg.modelo.SZA990;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
@ManagedBean
@SessionScoped
public class ListaOsBean {
List<SZA990> list = new ArrayList<SZA990>();
Date dataDe;
String dataDeS, dataAteS;
@SuppressWarnings("unchecked")
public String addOSNaListaPorCliente() {
HttpServletRequest request = (HttpServletRequest) FacesContext.getCurrentInstance().getExternalContext()
.getRequest();
HttpSession session = request.getSession(true);
String a1_cod = (String) session.getAttribute("A1_COD");
SZA990DAO szadao = new SZA990DAO();
list = szadao.getOSPorCliente(a1_cod);
return "/listaDeOSs.xhtml?faces-redirect=true";
}
public List<SZA990> getList() {
return list;
}
public void setList(List<SZA990> list) {
this.list = list;
}
public Date getDataDe() {
return dataDe;
}
public void setDataDe(Date dataDe) {
this.dataDe = dataDe;
}
// public Date getDataAte() {
// return dataAte;
// }
// public void setDataAte(Date dataAte) {
// this.dataAte = dataAte;
// }
public String getDataDeS() {
return dataDeS;
}
public void setDataDeS(String dataDeS) {
this.dataDeS = dataDeS;
}
public String getDataAteS() {
return dataAteS;
}
public void setDataAteS(String dataAteS) {
this.dataAteS = dataAteS;
}
}
Should I use a slider, or ajax? Thanks in advance for the answer! I searched and did not find anything specific.
Well, the solution was to use the Listener. The "noClick()" method within <p:ajax> adds the field content to the dataDe variable. In turn, this variable returns to the second calendar in "maxdate" like this: maxdate="#{Listosbean.getDataDe()}".
– Neemias Carvalho