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

Struts 1 Java Discussion :

[Struts-Layout] aide sur select


Sujet :

Struts 1 Java

  1. #1
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2002
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 59
    Localisation : Tunisie

    Informations forums :
    Inscription : Août 2002
    Messages : 141
    Par défaut [Struts-Layout] aide sur select
    Bonjour,
    voici mon code JSP
    qu'est ce que je doit mettre a la place des ??? dans mon code
    Merci...
    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
     
    <%@ page contentType="text/html;charset=UTF-8"%>
    <%@ taglib prefix="layout" uri="/WEB-INF/struts-layout.tld"  %>
    <%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld"%>
    <%@ taglib prefix="tiles" uri="/WEB-INF/struts-tiles.tld"%>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
    <jsp:useBean id="LIST_TYPEPRESTATION" scope="session" class="java.util.Vector"/>
    <layout:html>
    <tiles:insert template="/TEMPLATES/template.jsp">
    <tiles:put name="Header" content="/TEMPLATES/Header.jsp" />
    <tiles:put name="Banner" content="/TEMPLATES/Banner.jsp" />
    </tiles:insert>
     
    <body lang="ar" dir="rtl">
    <layout:form action="/PecDdeService" styleClass="FORM">
     
    <layout:select property="codeTypePrestation" name="????????">
    <layout:optionsCollection name="????????" value="????????">
    </layout:optionsCollection>
    </layout:select>

  2. #2
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Il faudrait préciser ce que contient le Vector LIST_TYPEPRESTATION, car je suppose que c'est à partir de celui-ci que tu veux constituer la liste déroulante ?
    Est-ce un Vector de String ou un Vector de beans ?

  3. #3
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2002
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 59
    Localisation : Tunisie

    Informations forums :
    Inscription : Août 2002
    Messages : 141
    Par défaut
    bonjour,
    voisi mon code java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
            List<Typeprestation> listTypePrestation=new ArrayList<Typeprestation>();
            GetListTypePrestationCmd  getListTypePrestationCmd=new  GetListTypePrestationCmd();
            getListTypePrestationCmd.setListTypePrestation(listTypePrestation);
            getListTypePrestationCmd.execute();
            listTypePrestation=getListTypePrestationCmd.getListTypePrestation();
            request.getSession().setAttribute("LIST_TYPEPRESTATION",listTypePrestation);

  4. #4
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    Donc, LIST_TYPEPRESTATION est une List de beans Typeprestation.

    Je ne connais pas les propriétés de Typeprestation mais supposons qu'il y ait une propriété id et une propriété libelle, il faut coder :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <layout:select property="codeTypePrestation">
       <layout:optionsCollection name="LIST_TYPEPRESTATION" value="id" label="libelle"/>
    </layout:select>
    Pour que ceci fonctionne, il faut avoir défini une propriété codeTypePrestation avec getter et setter dans l'ActionForm.

    Afin de respecter les conventions de nommage Java, je te conseille d'appeler la liste que tu mets dans le scope session listTypePrestation et non LIST_TYPEPRESTATION et donc de coder :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
     request.getSession().setAttribute("listTypePrestation",listTypePrestation);
    et
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <layout:select property="codeTypePrestation">
       <layout:optionsCollection name="listTypePrestation" value="id" label="libelle"/>
    </layout:select>
    et dans la jsp, supprime le tag jsp:useBean.

  5. #5
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2002
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 59
    Localisation : Tunisie

    Informations forums :
    Inscription : Août 2002
    Messages : 141
    Par défaut
    bonjour,
    je vien d'appliquer ton code mais voici le message d'erreur
    java.lang.NullPointerException at fr.improve.struts.taglib.layout.LabelledTag.getLabel(LabelledTag.java:63) at fr.improve.struts.taglib.layout.field.AbstractLayoutFieldTag.getLabel(AbstractLayoutFieldTag.java:363) at fr.improve.struts.taglib.layout.field.AbstractLayoutFieldTag.beginFieldLayout(AbstractLayoutFieldTag.java:99) at fr.improve.struts.taglib.layout.field.SelectTag.doStartEditMode(SelectTag.java:182) at fr.improve.struts.taglib.layout.field.AbstractModeFieldTag.doStartLayoutTag(AbstractModeFieldTag.java:253) at fr.improve.struts.taglib.layout.LayoutTagSupport.doStartTag(LayoutTagSupport.java:34) at _jsp._demande._DemandeService._jspService(_DemandeService.java:119) [/JSP/demande/DemandeService.jsp]

  6. #6
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut Autre façon de coder le layout:select
    Apparemment, il y a un problème sur l'attribut label.

    Peux-tu montrer le code de ta jsp avec la modification ?

    Sinon, essaie comme ceci :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <layout:select property="codeTypePrestation">
       <layout:options collection="listTypePrestation" property="id" labelProperty="libelle"/>
    </layout:select>

  7. #7
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2002
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 59
    Localisation : Tunisie

    Informations forums :
    Inscription : Août 2002
    Messages : 141
    Par défaut
    je vien d'appliquer ton code mais ca ne marche pas. voila mon code de 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
     
    <%@ page contentType="text/html;charset=UTF-8"%>
    <%@ taglib prefix="layout" uri="/WEB-INF/struts-layout.tld"  %>
    <%@ taglib prefix="html" uri="/WEB-INF/struts-html.tld"%>
    <%@ taglib prefix="tiles" uri="/WEB-INF/struts-tiles.tld"%>
    <%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
    <%String ur = request.getContextPath();%>
    <%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
     
     
    <script type="text/javascript" language="JavaScript1.2" src="/JS/apopwin.js"></script>
    <layout:html>
    <tiles:insert template="/TEMPLATES/template.jsp">
    <tiles:put name="Header" content="/TEMPLATES/Header.jsp" />
    <tiles:put name="Banner" content="/TEMPLATES/Banner.jsp" />
    </tiles:insert>
     
    <body lang="ar" dir="rtl">
    <layout:form action="/PecDdeService" styleClass="FORM">
     
    <layout:select property="codeTypePrestation">
       <layout:optionsCollection name="listTypePrestation" value="codetypeprestation" label="libelletypeprestation"/>
    </layout:select>
     
     
    </layout:form> 
    </body>
    <jsp:include page="/JSP/popUpError.jsp" />
    </layout:html>
    et celui de la classe dce la liste
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
            List<Typeprestation> listTypePrestation=new ArrayList<Typeprestation>();
            GetListTypePrestationCmd  getListTypePrestationCmd=new  GetListTypePrestationCmd();
            getListTypePrestationCmd.setListTypePrestation(listTypePrestation);
            getListTypePrestationCmd.execute();
            listTypePrestation=getListTypePrestationCmd.getListTypePrestation();
            request.getSession().setAttribute("listTypePrestation",listTypePrestation);

  8. #8
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    As-tu essayé l'autre façon de coder le layout:select ?
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <layout:select property="codeTypePrestation">
       <layout:options collection="listTypePrestation" property="codetypeprestation" labelProperty="libelletypeprestation"/>
    </layout:select>
    Et sinon, le bean Typeprestation a bien des propriétés codetypeprestation et libelletypeprestation ?

    Ce ne serait pas plutôt codeTypePrestation et libelleTypePrestation ?

  9. #9
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    J'ai fait un test sur un de mes projets et j'ai dû ajouter un attribut key au tag html:select :
    Code xml : Sélectionner tout - Visualiser dans une fenêtre à part
    <layout:select key="" property="codeTypePrestation">

  10. #10
    Membre confirmé
    Profil pro
    Inscrit en
    Août 2002
    Messages
    141
    Détails du profil
    Informations personnelles :
    Âge : 59
    Localisation : Tunisie

    Informations forums :
    Inscription : Août 2002
    Messages : 141
    Par défaut
    voila mon entity
    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
     
    package tn.com.parametreLocal;
     
    import java.io.Serializable;
     
    import java.util.List;
     
    import javax.persistence.Column;
    import javax.persistence.Entity;
    import javax.persistence.Id;
    import javax.persistence.NamedQuery;
    import javax.persistence.OneToMany;
     
    import tn.com.courrier.Courrierprestation;
    import tn.com.pret.demande.commission.Commission;
    import tn.com.pret.pret.pret.Pret;
     
     
    @Entity
    @NamedQuery(name = "Typeprestation.findAll", 
        query = "select o from Typeprestation o")
    public class Typeprestation implements Serializable {
        @Id
        @Column(nullable = false)
        private String codetypeprestation;
        private String libelletypeprestation;
        @OneToMany(mappedBy = "typeprestation")
        private List<Typedemande> typedemandeList;
        @OneToMany(mappedBy = "typeprestation")
        private List<Commission> commissionList;
        @OneToMany(mappedBy = "typeprestation")
        private List<Pret> pretList;
        @OneToMany(mappedBy = "typeprestation")
        private List<Courrierprestation> courrierprestationList;
     
        public Typeprestation() {
        }
     
        public String getCodetypeprestation() {
            return codetypeprestation;
        }
     
        public void setCodetypeprestation(String codetypeprestation) {
            this.codetypeprestation = codetypeprestation;
        }
     
        public String getLibelletypeprestation() {
            return libelletypeprestation;
        }
     
        public void setLibelletypeprestation(String libelletypeprestation) {
            this.libelletypeprestation = libelletypeprestation;
        }
     
        public List<Typedemande> getTypedemandeList() {
            return typedemandeList;
        }
     
        public void setTypedemandeList(List<Typedemande> typedemandeList) {
            this.typedemandeList = typedemandeList;
        }
     
        public List<Commission> getCommissionList() {
            return commissionList;
        }
     
        public void setCommissionList(List<Commission> commissionList) {
            this.commissionList = commissionList;
        }
     
        public List<Pret> getPretList() {
            return pretList;
        }
     
        public void setPretList(List<Pret> pretList) {
            this.pretList = pretList;
        }
     
        public List<Courrierprestation> getCourrierprestationList() {
            return courrierprestationList;
        }
     
        public void setCourrierprestationList(List<Courrierprestation> courrierprestationList) {
            this.courrierprestationList = courrierprestationList;
        }
     
    }

  11. #11
    Expert confirmé

    Femme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    5 793
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : France

    Informations forums :
    Inscription : Juillet 2005
    Messages : 5 793
    Par défaut
    As-tu testé la deuxième façon de coder le layout:select et as-tu essayé également d'ajouter l'attribut key comme ceci :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    <layout:select key="" property="codeTypePrestation">
       <layout:options collection="listTypePrestation" property="codetypeprestation" labelProperty="libelletypeprestation"/>
    </layout:select>

Discussions similaires

  1. Aide sur Select
    Par no_me_entero dans le forum Requêtes
    Réponses: 4
    Dernier message: 19/04/2011, 10h21
  2. Réponses: 2
    Dernier message: 31/05/2006, 09h47
  3. [Struts-layout] question sur la validation
    Par romdelf dans le forum Struts 1
    Réponses: 2
    Dernier message: 11/05/2006, 16h30
  4. Réponses: 6
    Dernier message: 27/03/2006, 19h11
  5. [struts] aide sur les boutons ...
    Par fabricew59 dans le forum Struts 1
    Réponses: 4
    Dernier message: 23/03/2006, 17h15

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