bonjour tout le monde, j'ai un souci pour passer des parametres date .J'utlise les codes suivant:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
public List <Object[]>getMontantParVehicule(Date d1,Date d2) {
 
		Session session=HibernateUtil.getSessionFactory().openSession();
		try{
		session.beginTransaction();
		System.out.println("Stat HQL");
		SQLQuery q=session.createSQLQuery("select IMMAT,SUM(PRIX) as COUT,SUM(QUANTITE) as QUANTITE,COUNT(IMMAT) as nbre from BON_ESSENCE where DATE_BON between :debut and :fin  GROUP BY IMMAT ");
      //  Query q =session.createQuery("select immat,sum(prix) as mnt from BonEssence group by immat  ");
        q.setParameter("debut",d1  );
        q.setParameter("fin",d2  );
return q.list();
		}catch (RuntimeException e) {
		    session.getTransaction().rollback();
		    throw e;
		}finally{
 
			session.getTransaction().commit();
		}
 
 
    }
le bean
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private Date d1;
    private Date d2;
	public Date getD1() {
		return d1;
	}
	public void setD1(Date d1) {
		this.d1 = d1;
	}
	public Date getD2() {
		return d2;
	}
	public void setD2(Date d2) {
		this.d2 = d2;
	}
public List<Object[]> getMontantParVehiculeTotal(){
		return essenceService.getMontantParVehicule(d1, d2);
		}
l'objectif est de saisir les paramètres dans une page et d'affichez le deuxième page qui prend en compte les paramètres saisis.
me pages xhtml sont:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<!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:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
       xmlns:p="http://primefaces.org/ui">
 
        <h:head>
            <f:facet name="first">
                <meta http-equiv="X-UA-Compatible" content="EmulateIE8" />
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>Welcome</title>
            </f:facet>
 
            <link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/default.css" />
            <link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/syntaxhighlighter/syntaxhighlighter.css" />
 
            <style type="text/css">
                .ui-layout-north {
                    z-index:10 !important;
                    overflow:visible !important;;
                }
 
                .ui-layout-north .ui-layout-unit-content {
                    overflow:visible !important;
                }
            </style>
        </h:head>
 
	<h:panelGrid columns="2" id="grid2">
 
                    <h:outputLabel value=" debut: *" for="txt_d1" />
                     <p:calendar locale="fr" value="#{bonEssenceBean.d1}" id="txt_d1" datePattern="dd/yyyy/MM" required="true" ></p:calendar>
 
                    <h:outputLabel value=" Fin: *" for="txt_d2" />
                     <p:calendar locale="fr" value="#{bonEssenceBean.d2}" id="txt_d2" datePattern="dd/yyyy/MM" required="true" ></p:calendar>
 
 
                 <p:button id="btn_add" value="Enregistrer"
                    outcome="DetailBon" >
                    <f:param name="d1" value="#{bonEssenceBean.d1}"></f:param>
                    <f:param name="d2" value="#{bonEssenceBean.d2}"></f:param>
                    </p:button>
 
            </h:panelGrid>
</html>
et DetailBon.xhtml
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<!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:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">
 
	<ui:composition template="/Views/Template/common.xhtml">
	  <ui:define name="Edition">
	  <h:form id="form">
 
    </h:form>
 
	  </ui:define>
 
	  <ui:define name="Consultation">
	  <h:form id="form2">
	  <!-- //////////////////////////////////////////////////////////////////////////// -->
 
	  <p:dataTable id="statTable" var="item" value="#{bonEssenceBean.montantParVehiculeTotal}"  widgetVar="statTable" sortMode="single" rows="5" paginator="true" paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="5,15,25">    
      <f:facet name="header">
              <p:outputPanel>  
                   <h:outputText value="Search:" style="Height:30px"/>  
                   <p:inputText id="globalFilter" onkeyup="carsTable.filter()" style="width:150px" />  
              </p:outputPanel>  
 
           </f:facet>
            <p:column  headerText="Vehicule"   > 
 
                <h:outputText value="#{item[0]}" />
 
            </p:column>  
 
            <p:column  headerText="COUT">  
                <h:outputText value="#{item[1]}" />  
            </p:column>  
            <p:column  headerText="QUANTITE">  
                <h:outputText value="#{item[2]}" />  
            </p:column> 
             <p:column  headerText="Nombre de bon">  
                <h:outputText value="#{item[3]}" />  
 
            </p:column>
 
 
 
        </p:dataTable>
 
 
 
	</h:form>
	  </ui:define>
	</ui:composition>
</html>
mais d1 et d2 ne sont pas instanciés et restent null alors j'ai l'exception:transaction sot succefully started
La technique utilisée ou du moins celle que j'essaie est dans le manuel Primeface mais peut etre que je rate un truc