IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

JSF Java Discussion :

table avec jsf


Sujet :

JSF Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Par défaut table avec jsf
    bonjour;
    j'utilise jsp pour afficher des donnes dans ma base et maintenant je veut utiliser jsf je veut utiliser est ce que c'est la meme procedure que jsp ou non :
    ma procedure jsp ete :
    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
     
    <table width="90%" >
    <%
    Iterator it = ((Collection)request.getAttribute("listContacts")).iterator();
    while(it.hasNext()) {
    Contact contact = (Contact)it.next();
    %>
    <tr>
    <td><%= contact.getFirstname() %></td>
    <td><%= contact.getLastname() %></td>
    <td><%= contact.getAddress() %></td>
    <td><%= contact.getCity() %></td>
    <td><%= contact.getZipCode() %></td>
    <td><%= contact.getPhone() %></td>
    <td><%= contact.getMobile() %></td>
    </tr>
    <%
    }
    %>
    </table>
    sinon quel tags pourrai je utiliser et merci

  2. #2
    Expert éminent
    Avatar de tchize_
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Avril 2007
    Messages
    25 482
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 46
    Localisation : Belgique

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Avril 2007
    Messages : 25 482
    Par défaut
    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
    <h:dataTable value="#{listContacts}" var="entry">
         <h:column>
          <h:outputText value="#{entry.firstName}"/>
         </h:column> 
         <h:column>
          <h:outputText value="#{entry.lastName}"/>
         </h:column> 
         <h:column>
          <h:outputText value="#{entry.address}"/>
         </h:column> 
         <h:column>
          <h:outputText value="#{entry.city}"/>
         </h:column> 
         <h:column>
          <h:outputText value="#{entry.zipCode}"/>
         </h:column> 
         <h:column>
          <h:outputText value="#{entry.phone}"/>
         </h:column> 
         <h:column>
          <h:outputText value="#{entry.mobile}"/>
         </h:column> 
    </h:dataTable>

  3. #3
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Par défaut
    merci de votre aide;
    mon probleme actuel est que j'ai fait la solution precedente avec servlet et maintenant j'utilise ejb donc je ne sait pas comment proceder pour faire les afficher;
    j'ai fait un methode dans mon ejb qui retourn un variable de type : (collection<contact> listContacts ())
    et j'ai fait:
    <h:dataTable value="#{listContacts}" var="entry">
    mais cela ne fonctionnait pas

  4. #4
    Rédacteur
    Avatar de romaintaz
    Homme Profil pro
    Java craftsman
    Inscrit en
    Juillet 2005
    Messages
    3 790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Java craftsman
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2005
    Messages : 3 790
    Par défaut
    C'est normal, il faut que ta méthode s'appelle getListContacts().
    En fait, en expression EL, tu utilises les noms des propriétés de ton bean, mais JSF va faire appel à ton Getter.
    Donc pour une propriété bidule ("#{monBean.bidule}"), JSF a besoin de la méthode getBidule().
    Nous sommes tous semblables, alors acceptons nos différences !
    --------------------------------------------------------------
    Liens : Blog | Page DVP | Twitter
    Articles : Hudson | Sonar | Outils de builds Java Maven 3 | Play! 1 | TeamCity| CitConf 2009
    Critiques : Apache Maven

  5. #5
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Par défaut
    merci, mais je n'ai pas pu lister le contenu de ma base de donnes:


    j'utilise ejb3 et jsf;
    pour l'ajout des valeur a ma base tout ce passe bien.

    mais pour lister les valeur de ma base j'ai des problemes:
    j'ai mis une methode dans mon bean session conatcmanagerbean:


    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
     
    public collection<contact> listContact() {
    return em.createQuery("SELECT c FROM contact c").getResultList();
    }
    et dans ma page jsf j'ai mis

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
     
     
     
     
    <h:dataTable value="#{beanlist.listcontact}" var="entry">
         <h:column>
          <h:outputText value="#{entry.firstName}"/>
         </h:column> 
    </h:dataTable>
    et dans le beanlist cette methode(getconatactlist)

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
     
     
    ContactManager contactManager = ejblocator.getLocator().getContactManager();
    return contactManager.listconatct;

  6. #6
    Rédacteur
    Avatar de romaintaz
    Homme Profil pro
    Java craftsman
    Inscrit en
    Juillet 2005
    Messages
    3 790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Java craftsman
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2005
    Messages : 3 790
    Par défaut
    Et le résultat ? Une erreur ? Un tableau vide ?
    Nous sommes tous semblables, alors acceptons nos différences !
    --------------------------------------------------------------
    Liens : Blog | Page DVP | Twitter
    Articles : Hudson | Sonar | Outils de builds Java Maven 3 | Play! 1 | TeamCity| CitConf 2009
    Critiques : Apache Maven

  7. #7
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Par défaut
    j'ai fait une verification est j'ai conclu que l'erreur est dans la communication entre ma jsp et le beanlist donc:
    le jsp:
    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
     
    <?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
    <!--
        Licensed to the Apache Software Foundation (ASF) under one
        or more contributor license agreements.  See the NOTICE file
        distributed with this work for additional information
        regarding copyright ownership.  The ASF licenses this file
        to you under the Apache License, Version 2.0 (the
        "License"); you may not use this file except in compliance
        with the License.  You may obtain a copy of the License at
     
        http://www.apache.org/licenses/LICENSE-2.0
     
        Unless required by applicable law or agreed to in writing,
        software distributed under the License is distributed on an
        "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
        KIND, either express or implied.  See the License for the
        specific language governing permissions and limitations
        under the License.
     
    -->
    <jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.0"
    	xmlns:f="http://java.sun.com/jsf/core"
    	xmlns:tr="http://myfaces.apache.org/trinidad"
    	xmlns:h="http://java.sun.com/jsf/html">
    	<jsp:directive.page contentType="text/html;charset=utf-8" />
    	<f:view>
    		<tr:document title="Apache Trinidad Blank Demo">
    			<tr:form>
    <tr:panelBox text="bonjour"></tr:panelBox>
    				<tr:panelPage>
     
    					<tr:outputText value="le tableau est : " ></tr:outputText>
     
     
    					<tr:table value="#{Beanlist.Listcontact}" var="entry">
     
    					<tr:column>
    					<tr:outputText value="entry.firstname"></tr:outputText>
    					</tr:column>
     
     
     
    					</tr:table>
     
    					<tr:outputText value="fin du tableau " ></tr:outputText>
     
    				</tr:panelPage>
     
    			</tr:form>
    		</tr:document>
    	</f:view>
    </jsp:root>
    et 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
    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
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
     
    /*
     *  Licensed to the Apache Software Foundation (ASF) under one
     *  or more contributor license agreements.  See the NOTICE file
     *  distributed with this work for additional information
     *  regarding copyright ownership.  The ASF licenses this file
     *  to you under the Apache License, Version 2.0 (the
     *  "License"); you may not use this file except in compliance
     *  with the License.  You may obtain a copy of the License at
     * 
     *  http://www.apache.org/licenses/LICENSE-2.0
     * 
     *  Unless required by applicable law or agreed to in writing,
     *  software distributed under the License is distributed on an
     *  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
     *  KIND, either express or implied.  See the License for the
     *  specific language governing permissions and limitations
     *  under the License.
     */
    package org.apache.myfaces.trinidad.imaf;
     
    import javax.faces.context.FacesContext;
     
    import org.apache.myfaces.trinidad.render.ExtendedRenderKitService;
    import org.apache.myfaces.trinidad.util.Service;
    import com.labosun.cj.ejb3.entity.Contact;
    import com.labosun.cj.ejb3.session.ContactManager;
    import com.labosun.cj.web.locator.EjbLocator;
    import java.util.List;
    /**
     * A typical simple backing bean, that is backed to <code>helloworld.jsp</code>
     * 
     */
    public class Beanlist
    {
     
      //properties
    	private String firstname;
     
    	private String lastname;
     
    	private String address;
     
    	private int zipCode;
     
    	private String city;
     
    	private String phone;
     
    	private String mobile;
     
    	private List<Contact> Listcontact;
     
      /**
       * default empty constructor
       */
      public Beanlist()
      {   
      }
     
      //-------------------getter & setter
    //debut
      public String getfirstname()
      {
    	  //firstname = "anis";
        return firstname;
      }
     
      public void setfirstname(String name)
      {
        this.firstname = name;
      }
    //fin
    //debut
      public String getlastname()
      {
        return lastname;
      }
     
      public void setlastname(String name)
      {
        this.lastname = name;
      }
    //fin
    //debut
      public String getaddress()
      {
        return address;
      }
     
      public void setaddress(String name)
      {
        this.address = name;
      }
    //fin
    //debut
      public int getzipCode()
      {
        return zipCode;
      }
     
      public void setzipCode(int name)
      {
        this.zipCode = name;
      }
    //fin
    //debut
      public String getcity()
      {
        return city;
      }
     
      public void setcity(String name)
      {
        this.city = name;
      }
    //fin
    //debut
      public String getphone()
      {
        return phone;
      }
     
      public void setphone(String name)
      {
        this.phone = name;
      }
    //fin
    //debut
      public String getmobile()
      {
        return mobile;
      }
     
      public void setmobile(String name)
      {
        this.mobile = name;
      }
    //fin
     
     
     
     public List<Contact> getListcontact()
      {
    	  ContactManager contactManager = EjbLocator.getLocator().getContactManager();
     
    	    Listcontact = contactManager.getlistContact();
    	    System.out.println(Listcontact.toString());
    	  return Listcontact;
     
      }
     
     
     
     
    }

  8. #8
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Par défaut
    j'ai trouver l'erreur c'est la specification des bean il ne faut pas commencer un attribut avec une majiscule;
    mais al'issue de cela je n'ai pas d'erreur mais au lieu d'avoir les nom j'ai eu comme cela:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
     
    entry.firstname
    entry.firstname
    entry.firstname
    entry.firstname
    entry.firstname
    entry.firstname
    entry.firstname
    et mon code est:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    <tr:table value="#{Beanlist.Listcontact}" var="entry">
     
    					<tr:column>
    					<tr:outputText value="entry.firstname"></tr:outputText>
    					</tr:column>
     
     
     
    					</tr:table>

  9. #9
    Rédacteur
    Avatar de romaintaz
    Homme Profil pro
    Java craftsman
    Inscrit en
    Juillet 2005
    Messages
    3 790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Java craftsman
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2005
    Messages : 3 790
    Par défaut
    Normal !

    Il faut faire ça :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <tr:outputText value="#{entry.firstname}"/>
    Sinon, tu lui demandes d'afficher un simple texte dans ta colonne...
    Nous sommes tous semblables, alors acceptons nos différences !
    --------------------------------------------------------------
    Liens : Blog | Page DVP | Twitter
    Articles : Hudson | Sonar | Outils de builds Java Maven 3 | Play! 1 | TeamCity| CitConf 2009
    Critiques : Apache Maven

  10. #10
    Membre éprouvé Avatar de anisj1m
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juillet 2006
    Messages
    1 067
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 42
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : High Tech - Éditeur de logiciels

    Informations forums :
    Inscription : Juillet 2006
    Messages : 1 067
    Par défaut
    merci pour vous;
    finalement c'est resolu.

  11. #11
    Rédacteur
    Avatar de romaintaz
    Homme Profil pro
    Java craftsman
    Inscrit en
    Juillet 2005
    Messages
    3 790
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 47
    Localisation : France, Yvelines (Île de France)

    Informations professionnelles :
    Activité : Java craftsman
    Secteur : Finance

    Informations forums :
    Inscription : Juillet 2005
    Messages : 3 790
    Par défaut
    Citation Envoyé par anisj1m Voir le message
    merci pour vous;
    finalement c'est resolu.
    De rien, content pour toi
    Pense juste à cliquer sur le bouton Résolu maintenant...
    Nous sommes tous semblables, alors acceptons nos différences !
    --------------------------------------------------------------
    Liens : Blog | Page DVP | Twitter
    Articles : Hudson | Sonar | Outils de builds Java Maven 3 | Play! 1 | TeamCity| CitConf 2009
    Critiques : Apache Maven

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 1
    Dernier message: 10/10/2013, 16h45
  2. Remplir deux tables en relation avec JSF
    Par dalidali86 dans le forum JSF
    Réponses: 0
    Dernier message: 12/09/2009, 22h54
  3. Export des tables avec JSF
    Par hassounbs dans le forum JSF
    Réponses: 3
    Dernier message: 31/10/2008, 09h45
  4. [Visual Web] woodstock table avec visual web jsf
    Par supernova dans le forum NetBeans
    Réponses: 0
    Dernier message: 21/07/2008, 16h39
  5. Création de table avec index
    Par Seb7 dans le forum Requêtes
    Réponses: 2
    Dernier message: 10/04/2003, 16h11

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo