Bonjour,
je veux affciher un pie chart et le raifraichier à chaque fois l'end user entre les paramétres de pie:
je travaile avec spring, hibernate jpa et jsf primefaces
mon daoImpl:
men serviceImpl
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137 @Repository public class HttpDAOImpl implements HttpDAO { @PersistenceContext private EntityManager em; public EntityManager getEm() { return em; } private String host; private Date startDate; private Date endDate; public String getHost() { return host; } public void setHost(String host) { this.host = host; } public Date getStartDate() { return startDate; } public void setStartDate(Date startDate) { this.startDate = startDate; } public Date getEndDate() { return endDate; } public void setEndDate(Date endDate) { this.endDate = endDate; } @Transactional public Long sumNb1xx() { /*Création d'un objet Query requete calcul somme de classe de réponse 1XX*/ Query q1xx = em.createQuery("SELECT SUM(h.nb1xx) FROM HttpEntity h WHERE h.host = :host and h.date_http BETWEEN :startDate and :endDate "); q1xx.setParameter("host", getHost()); q1xx.setParameter("startDate", getStartDate()); q1xx.setParameter("endDate", getEndDate()); //Exécution et récupération du resultat du requete Long sum1xx = (Long) q1xx.getSingleResult(); return sum1xx; } @Transactional public Long sumNb2xx() { /*Création d'un objet Query requete calcul somme de classe de réponse 2XX*/ Query q2xx = em.createQuery("SELECT SUM(h.nb2xx) FROM HttpEntity h WHERE h.host = :host and h.date_http BETWEEN :startDate and :endDate"); q2xx.setParameter("host", getHost()); q2xx.setParameter("startDate", getStartDate()); q2xx.setParameter("endDate", getEndDate()); //Exécution et récupération du resultat du requete Long sum2xx = (Long) q2xx.getSingleResult(); return sum2xx; } @Transactional public Long sumNb3xx() { /*Création d'un objet Query requete calcul somme de classe de réponse 3XX*/ Query q2xx = em.createQuery("SELECT SUM(h.nb3xx) FROM HttpEntity h WHERE h.host = :host and h.date_http BETWEEN :startDate and :endDate"); q2xx.setParameter("host", getHost()); q2xx.setParameter("startDate", getStartDate()); q2xx.setParameter("endDate", getStartDate()); //Exécution et récupération du resultat du requete Long sum3xx = (Long) q2xx.getSingleResult(); return sum3xx; } @Transactional public Long sumNb4xx() { /*Création d'un objet Query requete calcul somme de classe de réponse 4XX*/ Query q4xx = em.createQuery("SELECT SUM(h.nb4xx) FROM HttpEntity h WHERE h.host = :host and h.date_http BETWEEN :startDate and :endDate"); q4xx.setParameter("host", getHost()); q4xx.setParameter("startDate", getStartDate()); q4xx.setParameter("endDate", getEndDate()); //Exécution et récupération du resultat du requete Long sum4xx = (Long) q4xx.getSingleResult(); return sum4xx; } @Transactional public Long sumNb5xx() { /*Création d'un objet Query requete calcul somme de classe de réponse 5XX*/ Query q5xx = em.createQuery("SELECT SUM(h.nb5xx) FROM HttpEntity h WHERE h.host = :host and h.date_http BETWEEN :startDate and :endDate"); q5xx.setParameter("host", getHost()); q5xx.setParameter("startDate", getStartDate()); q5xx.setParameter("endDate",getEndDate()); //Exécution et récupération du resultat du requete Long sum5xx = (Long) q5xx.getSingleResult(); return sum5xx; }
mon managedBean
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 @Service(value="httpService") public class HttpServiceImpl implements HttpService { @Autowired HttpDAO httpDAO; public Long sumNb1xx() { return httpDAO.sumNb1xx(); } public Long sumNb2xx() { return httpDAO.sumNb2xx(); } public Long sumNb3xx() { return httpDAO.sumNb3xx(); } public Long sumNb4xx() { return httpDAO.sumNb4xx(); } public Long sumNb5xx() { return httpDAO.sumNb5xx(); } public List<HttpEntity[]> findHttpByRtt() { return httpDAO.findHttpByRtt(); } public List<HttpEntity[]> FindHttpByDelayReqAns() { return httpDAO.FindHttpByDelayReqAns(); } }
et ma page jsf .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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70 @Component(value="httpMB") @Scope(value="session") public class HttpManagedBean implements Serializable { /** The Constant serialVersionUID. */ private static final long serialVersionUID = 1L; @Autowired HttpService httpService; private PieChartModel pieModel; private String host; private Date startDate; private Date endDate; @PostConstruct public void createPieModel(){ pieModel = new PieChartModel(); pieModel.set("Classe de réponse 1XX", getVal1xx()); pieModel.set("Classe de réponse 2XX", getVal2xx()); pieModel.set("Classe de réponse 3XX", getVal3xx()); pieModel.set("Classe de réponse 4XX", getVal4xx()); pieModel.set("Classe de réponse 4XX", getVal5xx()); } public PieChartModel getPieModel() { return pieModel; } public void setPieModel(PieChartModel pieModel) { this.pieModel = pieModel; } public String getHost() { return host; } public Date getStartDate() { return startDate; } public Date getEndDate() { return endDate; } public Long getVal1xx(){ return httpService.sumNb1xx(); } public Long getVal2xx(){ return httpService.sumNb2xx(); } public Long getVal3xx(){ return httpService.sumNb3xx(); } public Long getVal4xx(){ return httpService.sumNb4xx(); } public Long getVal5xx(){ return httpService.sumNb5xx(); } }
aidez moi svp j'arrive pas à le faire je veux que l'user entre les paramétre de la requete puis pie chart se rafraichie et s'affiche via la commandButton
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 <h:outputText value="Date début: " /> <p:calendar value="#{httpMB.startDate}" pattern="dd/MM/yyyy HH:mm:ss" /> <p:spacer height="20%" width="20%" /> <h:outputText value="Date fin: " /> <p:calendar value="#{httpMB.endDate}" pattern="dd/MM/yyyy HH:mm:ss" /> <p:spacer height="20%" width="20%" /> <h:outputText value="Host:" /> <h:inputText value="#{httpMB.host}" ></h:inputText> <p:commandButton value="Submit" ajax="true" update="sample , custom" actionListner="#{httpMB.createPieModel}" /> <f:view contentType="text/html"> <p:pieChart id="sample" value="#{httpMB.pieModel}" legendPosition="w" style="width:400px;height:300px" /> </f:view> <p:pieChart id="custom" value="#{httpMB.pieModel}" legendPosition="e" fill="false" showDataLabels="true" style="width:400px;height:300px" sliceMargin="5" diameter="150" />
dans mon console j'ai vu la requete mais avec ses paramétres de condition avec un point d'interrogation donc les paramétres n'arrivent pas à la méthode
comment le faire ?
Merci d'avance pour ton aide
Partager