Bonjour,
Etant debutant en JSF et java, je m'expose souvent a des problemes. Parfois j'arrive a les regler et d'autre non :
Voila dans ma datatable, je mets un commandLink qui a pour action un methode qui me selectionne un objet dans ma base de donnee.
Or impossible a faire fonctionner mon commandLink. Il n'appelle jamais la methode demandee
Voici un bout de code de la JSF :
Appelle cette methode :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 <html:dataTable value="#{Rubrique.liste_produit}" var="liste_produit" border="0" binding="Rubrique."> <html:column> <core:facet name="header"> <core:verbatim >Nom</core:verbatim> </core:facet> <html:outputText style="text-align: center; font-family:verdana; font-size:12; font-style:italic;" value="#{liste_produit.nom}"/> </html:column> <html:column> <html:commandLink action="#{Rubrique.fiche}"> <html:graphicImage value="#{liste_produit.image}" onmouseover="montre('Cliquer pour voir la description');" onmouseout="cache()" /> <core:param name="nom" value="#{liste_produit.nom}" /> </html:commandLink>
Le <return fiche> permet dans faces-config.xml de rediriger vers ma nouvelle JSF.
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 public String fiche() { System.out.println("fasdfasdfas"); fiche = new ArrayList<Object>(); Factory newFactory = new Factory(); newFactory.dbConnect(); FacesContext Context = FacesContext.getCurrentInstance(); Map map = Context.getExternalContext().getRequestParameterMap(); this.tmp = newFactory.select("produits"); Iterator<Object> itp = tmp.iterator(); while (itp.hasNext()) { Produits cur = (Produits)itp.next(); System.out.println(cur.getNom()); if (((String)map.get("nom")).compareTo(cur.getNom()) == 0) { fiche.add((Object)cur); } } return "fiche"; }
Merci d'avance
Partager