Salut tout le monde,
j'essaye en vain de faire fonctionner un lieen commandLink dans un datatable mais rien a faire
lorsque je sors ce meme lien du datatable il fonctionne tres bien pourtant
il y a bien un <h:form> dans ma page et y en a aucun imbriqué (probleme deja eut)
je ne vois pas d'ouvrir l'erreur peut provenir, ma methode du bean n'est jamais appelé
Auriez-vous une idée
ps : JSF+Facelet
Ma page .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 <!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:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:c="http://java.sun.com/jstl/core" xmlns:f="http://java.sun.com/jsf/core"> <ui:composition template="/templates/template.xhtml"> <ui:define name="contenu"> <h:messages/> <h:outputText value="Les Posts"/> <h:form> <h:dataTable value="#{postBean.dataModelPost}" var="item" width="100%" headerClass="list-header" binding="#{postBean.datable}"> <h:column> <f:facet name="header"> <h:outputText value="Titre"/> </f:facet> <h:commandLink id="bt" action="#{postBean.initDetails}" > <h:outputText value="#{item.title}" /> </h:commandLink> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Created at / Updated at"/> </f:facet> <h:outputText value="Created at #{item.creationdate} by #{item.author.username}"/> <h:outputText value="Updated at #{item.lastmodificationdate}" rendered="#{item.lastmodificationdate ne null}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Content"/> </f:facet> <h:outputText value="#{item.content}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Categories"/> </f:facet> <h:outputText value="Categories : "/> <h:dataTable var="categorie" value="#{item.categories}"> <h:outputText value="#{categorie.name}"/> </h:dataTable> </h:column> <h:column> <f:facet name="header"> <h:outputText value="Action"/> </f:facet> <h:commandLink value="Edit" rendered="#{item.author.id eq userBean.user.id}"/> </h:column> </h:dataTable> </h:form> </ui:define> </ui:composition> </html>
Mon 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
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 @ManagedBean @SessionScoped public class PostBean { .......................... ............. private DataModel dataModelPost = new ListDataModel(); private List<Post> postsItems; private Post post = new Post(); private Post postSelected; private UIData datable; /** Creates a new instance of PostBean */ public PostBean() { } public String init(){ if(postsItems == null){ postsItems = new ArrayList<Post>(); } postsItems = postFacade.findAllPost(); if(postsItems != null && !postsItems.isEmpty()){ dataModelPost.setWrappedData(postsItems); } return "success"; } /** * Methode permettant d'afficher le detail d'un post * @return */ public String initDetails(){ System.out.println("-- initDetails - "); setDetail(true); return "success"; } public DataModel getDataModelPost() { return dataModelPost; } public void setDataModelPost(DataModel dataModelPost) { this.dataModelPost = dataModelPost; } public UIData getDatable() { return datable; } public void setDatable(UIData datable) { this.datable = datable; } }
Partager