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 :

CommandLink marche pas dans Datatable


Sujet :

JSF Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre éclairé Avatar de snipes
    Inscrit en
    Septembre 2004
    Messages
    547
    Détails du profil
    Informations forums :
    Inscription : Septembre 2004
    Messages : 547
    Par défaut CommandLink marche pas dans Datatable
    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;
        }
     
     
     
    }

  2. #2
    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
    Il n'y a pas de raison qu'il ne marche pas.

    Utilises-tu Firefox ? Peut-être peux-tu regarder avec Firebug (ou un équivalent pour les autres navigateurs) s'il n'y a pas une erreur JavaScript au moment du clic ?
    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

Discussions similaires

  1. Réponses: 0
    Dernier message: 08/04/2015, 13h16
  2. Outlook ne marche pas dans mon réseau sous linux
    Par Germain123 dans le forum Applications et environnements graphiques
    Réponses: 3
    Dernier message: 25/03/2006, 22h15
  3. Balise <PRE> marche pas dans un form
    Par chateau64 dans le forum Balisage (X)HTML et validation W3C
    Réponses: 4
    Dernier message: 14/11/2005, 09h20
  4. aperçu d image avec input type file marche pas dans ffx
    Par siddh dans le forum Général JavaScript
    Réponses: 4
    Dernier message: 09/11/2005, 09h11
  5. [GifDecoder] marche pas dans applet avec IE
    Par formentor dans le forum Applets
    Réponses: 2
    Dernier message: 06/05/2003, 10h43

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