j ai un pb en créeant une classe implémentant un PhaseListener pour afficher mes messages d erreurs personalisés
j ai donc dans ma page JSF :
puis mon listener
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <h:outputText id="lblAssignationDate" value="#{text.common_assignationDate}" styleClass="text_label" /> <t:inputCalendar id="assignationDate" value="#{productGui.selectedData.assignationDate}" renderAsPopup="true" renderPopupButtonAsImage="true"> <f:convertDateTime pattern="#{text.cst_dateFormat_short}" timeZone="#{actionGui.timeZone}"/> </t:inputCalendar> <f:attribute name="fieldDate" value="date test" /> <h:message for="assignationDate" showSummary="true" showDetail="false" errorClass="errorMessageSmall"></h:message>
lorsque je rentre une date incorrecte le msg de d erreur n est pas le bon
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 .... public void beforePhase(PhaseEvent e) { FacesContext fc = e.getFacesContext(); UIViewRoot root = fc.getViewRoot(); String mbName = fc.getApplication().getMessageBundle(); Locale locale = root.getLocale(); ResourceBundle rb = ResourceBundle.getBundle("Messages", locale); Iterator i = fc.getClientIdsWithMessages(); while (i.hasNext()) { String clientId = (String) i.next(); UIComponent c = root.findComponent(clientId); String fieldDate = (String) c.getAttributes().get("fieldDate"); if (fieldDate != null) { Iterator j = fc.getMessages(clientId); while (j.hasNext()) { FacesMessage fm = (FacesMessage) j.next(); String detail = fm.getDetail(); if ("DATE_ERR_MSG".equals(detail)) { String custMsgPattern = rb.getString("CUST_DATE_ERR_MSG_detail"); Object[] params = new Object[1]; params[0] = ((EditableValueHolder) c). getSubmittedValue(); String custMsg = MessageFormat.format(custMsgPattern, params); fm.setDetail(custMsg); } fm.setDetail(fieldDate + ": " + fm.getDetail()); } } } }
et lorsque je rentre une date correct il me lève une exception expr NullPointerException
quelqu un aurait une idée la dessus ?
Partager