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 :

Pourquoi je n arrive pas à récuperer la ligne active de mon data table


Sujet :

JSF Java

  1. #1
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : Algérie

    Informations forums :
    Inscription : Mars 2007
    Messages : 176
    Points : 75
    Points
    75
    Par défaut Pourquoi je n arrive pas à récuperer la ligne active de mon data table
    Bonjour Mon EB:

    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
    package ms.marchandise.com;
     
    import java.util.List;
     
    import javax.faces.model.DataModel;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
     
    import com.marinesoft.DAO.PaysDao;
    import com.marinesoft.donnee.Pays;
     
    public class EBPays {
     
    	private List<Pays> Pays;
    	private DataModel PaysDataModel;
    	private String Selection;
     
     
     
    	//METHODE POUR RECUPERER UNE LISTE DE PAYS
    	public List<Pays> getPays() {
     
    		 try {
    			         Context context = new InitialContext();
    			         PaysDao pa = (PaysDao) context.lookup("PaysDaoJpa/remote");
    			         Pays = pa.findAll();
     
     
     
    			      } catch (NamingException e) {
    			         e.printStackTrace();
    			      }
    				return Pays;
    			}
     
     
    	public String getSelection() {
    		PaysDataModel.setWrappedData(Pays);
    		this.Selection= (String) PaysDataModel.getRowData();
    		return Selection;
    	}
     
     
    	public void setSelection(String selection) {
    		Selection = selection;
    	}
     
    }
    Ma page 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
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
     
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
        pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
    <%@ taglib uri="http://richfaces.org/rich" prefix="rich" %> 
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <rich:dataTable onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'" 
    id="table" rows="7" value="#{eBPays.pays}" var="P" rowKeyVar="row" style="width : 248px; height : 163px;">
    				<f:facet name="header">
                    <h:outputText value="Liste de Recherche"/>
                </f:facet>
    				<rich:column>
    				<f:facet name="header"><h:outputText value="Code"/></f:facet>
    				<h:outputText value="#{P.code}"/>
    				</rich:column>
    				<rich:column>
    				<f:facet name="header"><h:outputText value="Libelle"/></f:facet>
    				<h:outputText value="#{P.libelle}"/>
    				</rich:column>
    				<rich:column>
                    <f:facet name="header">
                            <h:outputText value="Actions"></h:outputText>
                    </f:facet>
                    <a4j:commandLink ajaxSingle="true" id="editlink" 
                        oncomplete="#{rich:component('editPanel')}.show()">
                        <h:graphicImage value="/image/edit.gif" style="border:0"/>
                        <f:setPropertyActionListener value="#{row}"
    		             target="#{eBPays.selection}" />
                    </a4j:commandLink>
                    <rich:toolTip for="editlink" value="Edit"/>
                    </rich:column>			
    </rich:dataTable>
    <rich:datascroller for="table" maxPages="3" style="height : 20px; width : 248px;"></rich:datascroller> 
        <rich:modalPanel id="editPanel" autosized="true" width="450">
            <f:facet name="header">
                <h:outputText value="Editer Pays" />
            </f:facet>
            <f:facet name="controls">
                <h:panelGroup>
                    <h:graphicImage value="/image/close.png"
                        id="hidelink" styleClass="hidelink"/>
                    <rich:componentControl for="editPanel" attachTo="hidelink"
                       operation="hide" event="onclick" />
                </h:panelGroup>
            </f:facet>
            <h:form>
                <rich:messages style="color:red;"></rich:messages>
                <h:panelGrid columns="1">
                <a4j:outputPanel ajaxRendered="true">
                    <h:panelGrid columns="2">
                        <h:outputText value="Code"/>
                        <h:inputText id="PanelCode" value="#{eBPays.selection.code}"/>
                        <h:outputText value="Libelle" />
                        <h:inputText id="PanelLibelle" value="#{eBPays.selection.libelle}" />
                    </h:panelGrid>
                </a4j:outputPanel>
                <a4j:commandButton value="Store"
                    oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />
                </h:panelGrid>  
            </h:form>
        </rich:modalPanel>
    </h:form>
    </f:view>
     
    </body>
    </html>
    je me base sur la faq et jboss rich faces mais sa ne marche pas pourquoi quel est le type avec le quel je dois remplir ma data table
    que est le type de la ligne selectionner avec getrow
    comment je peut exploiter cela au niveau d'un masque
    AIDEZ MOI SVP J essai de régler ce problème mais je n y arrive pas toute seul
    je remercie d avance tout ceux qui vont m aider

  2. #2
    Membre habitué
    Inscrit en
    Mars 2009
    Messages
    154
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 154
    Points : 149
    Points
    149
    Par défaut
    Il faut mettre une listDataModel dans ton tableau plutôt qu'une simple liste.

    Le reste de ta solution est là http://java.developpez.com/faq/jsf/?...le_active_row1

  3. #3
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : Algérie

    Informations forums :
    Inscription : Mars 2007
    Messages : 176
    Points : 75
    Points
    75
    Par défaut Tjs meme problème
    ERREUR:
    javax.servlet.ServletException: /Formulaire/DataPays.jsp(16,0) '#{eBPays.paysDataModel}' Error reading 'paysDataModel' on type ms.marchandise.com.EBPays

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Mars 2007
    Messages
    176
    Détails du profil
    Informations personnelles :
    Localisation : Algérie

    Informations forums :
    Inscription : Mars 2007
    Messages : 176
    Points : 75
    Points
    75
    Par défaut
    J ai fais comme tu mas dit

    Voila comment j ai modifier mon EB:
    package ms.marchandise.com;
    import java.util.List;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import com.marinesoft.DAO.PaysDao;
    import com.marinesoft.donnee.Pays;

    public class EBPays {

    private List<Pays> Pays;
    private DataModel PaysDataModel = new ListDataModel();
    private Pays Selection;
    private String code;
    private String libelle;

    public DataModel getPaysDataModel() {
    try {
    Context context = new InitialContext();
    PaysDao pa = (PaysDao) context.lookup("PaysDaoJpa/remote");
    Pays = pa.findAll();
    PaysDataModel.setWrappedData(Pays);
    } catch (NamingException e) {
    e.printStackTrace();
    }

    return PaysDataModel;
    }

    public void setPaysDataModel(ListDataModel paysDataModel) {
    PaysDataModel = paysDataModel;
    }


    public Pays getSelection() {
    Selection= (Pays) PaysDataModel.getRowData();
    this.code=Selection.getcode();
    this.libelle=Selection.getlibelle();
    return Selection;
    }


    public void setSelection(Pays selection) {
    Selection = selection;
    }

    public String getCode() {
    return code;
    }

    public void setCode(String code) {
    this.code = code;
    }

    public String getLibelle() {
    return libelle;
    }

    public void setLibelle(String libelle) {
    this.libelle = libelle;
    }

    }
    Concernant ma JSP voila le source:
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://richfaces.org/a4j" prefix="a4j" %>
    <%@ taglib uri="http://richfaces.org/rich" prefix="rich" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <f:view>
    <h:form>
    <rich:dataTable onRowMouseOver="this.style.backgroundColor='#F1F1F1'" onRowMouseOut="this.style.backgroundColor='#{a4jSkin.tableBackgroundColor}'"
    id="table" rows="7" value="#{eBPays.paysDataModel}" var="P" style="width : 248px; height : 163px;">
    <f:facet name="header">
    <h:outputText value="Liste de Recherche"/>
    </f:facet>
    <rich:column>
    <f:facet name="header"><h:outputText value="Code"/></f:facet>
    <h:outputText value="#{P.code}"/>
    </rich:column>
    <rich:column>
    <f:facet name="header"><h:outputText value="Libelle"/></f:facet>
    <h:outputText value="#{P.libelle}"/>
    </rich:column>
    <rich:column>
    <f:facet name="header">
    Actions
    </f:facet>
    <a4j:commandLink ajaxSingle="true" id="editlink"
    oncomplete="#{rich:component('editPanel')}.show()">
    <h:graphicImage value="/image/edit.gif" style="border:0"/>
    <f:setPropertyActionListener value="#{P}"
    target="#{eBPays.getSelection}" />
    </a4j:commandLink>
    <rich:toolTip for="editlink" value="Edit"/>
    </rich:column>
    </rich:dataTable>
    <rich:datascroller for="table" maxPages="3" style="height : 20px; width : 248px;"></rich:datascroller>
    <rich:modalPanel id="editPanel" autosized="true" width="450">
    <f:facet name="header">
    <h:outputText value="Editer Pays" />
    </f:facet>
    <f:facet name="controls">
    <h:panelGroup>
    <h:graphicImage value="/image/close.png"
    id="hidelink" styleClass="hidelink"/>
    <rich:componentControl for="editPanel" attachTo="hidelink"
    operation="hide" event="onclick" />
    </h:panelGroup>
    </f:facet>
    <h:form>
    <rich:messages style="color:red;"></rich:messages>
    <h:panelGrid columns="1">
    <a4j:outputPanel ajaxRendered="true">
    <h:panelGrid columns="2">
    <h:outputText value="Code"/>
    <h:inputText id="PanelCode" value="#{P.code}"/>
    <h:outputText value="Libelle" />
    <h:inputText id="PanelLibelle" value="#{P.libelle}" />
    </h:panelGrid>
    </a4j:outputPanel>
    <a4j:commandButton value="Store"
    oncomplete="if (#{facesContext.maximumSeverity==null}) #{rich:component('editPanel')}.hide();" />
    </h:panelGrid>
    </h:form>
    </rich:modalPanel>
    <a4j:status onstart="#{rich:component('wait')}.show()" onstop="#{rich:component('wait')}.hide()"/>
    </h:form>
    </f:view>

    </body>
    </html>
    est ce que quelqu'un peut me corriger mon :
    setPropertyActionListener

    Je veux afficher l enregistrement sur une pop up

  5. #5
    Membre habitué
    Inscrit en
    Mars 2009
    Messages
    154
    Détails du profil
    Informations forums :
    Inscription : Mars 2009
    Messages : 154
    Points : 149
    Points
    149
    Par défaut
    Tu as un problème là :

    Pays = pa.findAll();
    PaysDataModel.setWrappedData(Pays);

    Pays c'est ton objet... il faut instancier ta variable de liste et la passer au DataModel. A partir de là, tu devrais déjà pouvoir afficher ton tableau.

    Ensuite pour ton setPropertyActionListener
    <f:setPropertyActionListener value="#{P}"
    target="#{eBPays.getSelection}" />

    ton target, c'est le nom de la variable où tu veux enregistrer l'information : target="#{eBPays.selection}". Tu dois bien évidemment avoir les accesseurs dans ton controleur.

    Après pour la pop-up, ça sera une réaction à ton action. tu peux afficher un composant pop-up dans un jQuery que tu affiches avec un renderer. Tu le met à jour avec un peu d'ajax... bref bon courage .

Discussions similaires

  1. pourquoi je n'arrive pas a me connecter?
    Par angelange dans le forum JDBC
    Réponses: 13
    Dernier message: 19/09/2007, 13h35
  2. [Erreur de syntaxe] Pourquoi je n'arrive pas a creer une table
    Par pierrot10 dans le forum SQL Procédural
    Réponses: 2
    Dernier message: 25/09/2006, 22h37
  3. [Oracle/ASP.Net] Pourquoi je n'arrive pas à charger oci.dll ?
    Par zakaria_jd dans le forum Accès aux données
    Réponses: 1
    Dernier message: 01/08/2006, 12h25
  4. [C# 2005 Express] Pourquoi je n'arrive pas à l'installer ?
    Par Pierre8r dans le forum Visual Studio
    Réponses: 2
    Dernier message: 30/07/2006, 15h49
  5. Réponses: 4
    Dernier message: 22/05/2006, 11h46

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