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 :

Primefaces 3.2 - datatable bug ?


Sujet :

JSF Java

  1. #1
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut Primefaces 3.2 - datatable bug ?
    C'est une impression ou ce composant est bourré de bugs

    je fais des tests avec la version 3.2 de primefaces et j'ai des comportements complètement aberrants.

    j'affiche une première fois la page, je peux utiliser le paginator, mais les liens ou les boutons ne fonctionnent plus après.

    ou alors j'affiche une première fois la page, je fais une opération sur la liste, et il n'y a plus que les indexes qui changent, la liste ne bouge pas ou alors je me choppe des erreurs NumberFormatException

    Mais d'où ça vient ?

    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
     
    14:12:52,476 Avertissement [javax.enterprise.resource.webcontainer.jsf.lifecycle] (http--127.0.0.1-8080-1) null: java.lang.NumberFormatException: null
        at java.lang.Integer.parseInt(Integer.java:454) [:1.7.0_01]
        at java.lang.Integer.valueOf(Integer.java:582) [:1.7.0_01]
        at org.primefaces.component.datatable.DataHelper.decodePageRequest(DataHelper.java:49) [primefaces-3.2.jar:]
        at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:73) [primefaces-3.2.jar:]
        at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:795) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at javax.faces.component.UIData.processDecodes(UIData.java:984) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.primefaces.component.datatable.DataTable.processDecodes(DataTable.java:571) [primefaces-3.2.jar:]
        at javax.faces.component.UIForm.processDecodes(UIForm.java:216) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.primefaces.component.layout.Layout.processDecodes(Layout.java:238) [primefaces-3.2.jar:]
        at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:926) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
        at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
        at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.0.4-b09-jbossorg-4.jar:2.0.4-b09-jbossorg-4]
        at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312) [jboss-jsf-api_2.0_spec-1.0.0.Final.jar:1.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57) [jboss-as-web-7.0.0.Final.jar:7.0.0.Final]
        at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951) [jbossweb-7.0.0.CR4.jar:7.0.0.Final]
        at java.lang.Thread.run(Thread.java:722) [:1.7.0_01]
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1) javax.faces.FacesException: null
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:86)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.jboss.as.web.NamingValve.invoke(NamingValve.java:57)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:154)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:362)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:667)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:951)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at java.lang.Thread.run(Thread.java:722)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1) Caused by: java.lang.NumberFormatException: null
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at java.lang.Integer.parseInt(Integer.java:454)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at java.lang.Integer.valueOf(Integer.java:582)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.primefaces.component.datatable.DataHelper.decodePageRequest(DataHelper.java:49)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.primefaces.component.datatable.DataTableRenderer.decode(DataTableRenderer.java:73)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIComponentBase.decode(UIComponentBase.java:795)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIData.processDecodes(UIData.java:984)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.primefaces.component.datatable.DataTable.processDecodes(DataTable.java:571)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIForm.processDecodes(UIForm.java:216)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at org.primefaces.component.layout.Layout.processDecodes(Layout.java:238)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIComponentBase.processDecodes(UIComponentBase.java:1047)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:926)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78)
     
    14:12:52,476 ERROR [stderr] (http--127.0.0.1-8080-1)     ... 16 more
    Contexte :
    Eclipse indigo
    java 1.7
    primefaces 3.2

    La page n'a pas grand chose de spécial (je trouve)
    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
     
    <?xml version='1.0' encoding='UTF-8' ?>
    <!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:h="http://java.sun.com/jsf/html"
        xmlns:f="http://java.sun.com/jsf/core"
        xmlns:ui="http://java.sun.com/jsf/facelets"
        xmlns:p="http://primefaces.org/ui">
     
    <ui:composition template="/template.xhtml">
     
        <ui:define name="content">
            <h:form id="jsfform1">
     
            <p:commandButton onclick="panel1.show()" value="Nouveau" type="button"/>
            <p:commandButton action="#{personManager.delete}" value="Supprimer" immediate="true" update="persons"/>
            <p:commandButton action="#{personManager.reinit}" value="Recréer les données" immediate="true" update="persons"/>
     
            <p:growl id="messages" autoUpdate="true" showDetail="true" showSummary="false" sticky="false" />
     
     
            <p:dataTable value="#{personManager.cacheList}" var="item" id="persons" binding="#{personManager.uiDataTable}"
                selectionMode="multiple" selection="#{personManager.selectedPersons}" 
                rowKey="#{item.identity}" style="padding-top:10;width:850px" editable="true"
                emptyMessage="Aucune donnée" paginator="true" rowsPerPageTemplate="5,10,15" rows="#{personManager.currentRows}" widgetVar="personsTable" >
     
                <f:facet name="header">  
                    <p:outputPanel>  
                        <h:outputText value="Recherche dans toutes les colonnes :" />  
                        <p:inputText id="globalFilter" onkeyup="personsTable.filter()" style="width:150px" />  
                    </p:outputPanel>  
                </f:facet>  
     
                <p:column headerText="#{msg.form_list_identity}" style="width:100px" filterBy="#{item.identity}" filterMatchMode="contains">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{item.identity}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText id="identity" value="#{item.identity}" style="width:90%" validator="#{personManager.validateForm}" />
                        </f:facet>
                    </p:cellEditor>
                </p:column>
     
                <p:column headerText="#{msg.form_list_name}" style="width:450px" filterBy="#{item.name}" filterMatchMode="contains">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{item.name}" />
                        </f:facet>
                        <f:facet name="input">
                            <p:inputText id="name" value="#{item.name}" style="width:90%" validator="#{personManager.validateForm}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
     
                <p:column headerText="#{msg.form_list_birthdate}" style="width:100px;text-align:center" filterBy="#{item.birthdate}" filterMatchMode="contains">
                    <p:cellEditor>
                        <f:facet name="output">
                            <h:outputText value="#{item.birthdate}">
                                <f:convertDateTime pattern="dd/MM/yyyy" timeZone="#{personManager.serverTimeZone}"/>
                            </h:outputText>
                        </f:facet>
                        <f:facet name="input">
                            <p:calendar id="birthdate2" value="#{item.birthdate}" style="width:90%" mode="popup" pattern="dd/MM/yyyy" validator="#{personManager.validateForm}"/>
                        </f:facet>
                    </p:cellEditor>
                </p:column>
     
                <p:column headerText="#{msg.form_list_age}" style="width:100px;text-align:right" filterBy="#{item.age}" filterMatchMode="contains">
                    <h:outputText value="#{item.age}" />
                </p:column>
     
                <p:column style="width:100px">
                    <p:rowEditor />
                    <p:commandLink action="#{personManager.clear}" update="@form" immediate="true">
                        <p:graphicImage url="./images/delete.gif" style="border:0"/>
                        <f:param name="identity" value="#{item.identity}"/>
                    </p:commandLink>
                    <p:commandLink action="#{personManager.loadDetail}" immediate="true">
                        <p:graphicImage url="./images/detail.gif" style="border:0"/>
                        <f:param name="identity" value="#{item.identity}"/>
                    </p:commandLink>
                </p:column>
            </p:dataTable>
        </h:form>
     
     
        <h:form id="jsfform2">
     
            <p:dialog id="editDialog" header="Nouvelle personne" widgetVar="panel1"  showEffect="drop" hideEffect="explode" modal="false" appendToBody="false">
                <p:panelGrid columns="2">
                    <h:outputText for="identity" value="#{msg.form_label_identity}" />
                    <p:inputText id="identity" value="#{personManager.identity}" validator="#{personManager.validateForm}"/>
     
                    <h:outputLabel for="name" value="#{msg.form_label_name}" />
                    <p:inputText id="name" value="#{personManager.name}" validator="#{personManager.validateForm}" />
     
                    <h:outputLabel for="birthdate" value="#{msg.form_label_birthdate}" />
                    <p:calendar id="birthdate" value="#{personManager.birthdate}" mode="popup" pattern="dd/MM/yyyy" required="false" requiredMessage="Date obligatoire" validator="#{personManager.validateForm}"/>
     
                    <f:facet name="footer">
                        <p:commandButton action="#{personManager.save}"
                            value="#{msg.form_action_save}"
                            icon="ui-icon-check" style="margin-left:0" />
                    </f:facet>
                </p:panelGrid>
            </p:dialog>
     
        </h:form>
        </ui:define>
    </ui:composition>
     
    </html>

  2. #2
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    Si vous avez besoin d'autres informations, je peux les rajouter...

  3. #3
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    J'avance un peu.
    L'erreur est liée au binding du composant datatable dans le backing bean.

    Voici donc le bean incriminé
    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
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
     
    package com.sample.bean;
     
    import java.util.Date;
    import java.util.List;
    import java.util.TimeZone;
    import javax.ejb.EJB;
    import javax.faces.application.FacesMessage;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.validator.ValidatorException;
    import org.primefaces.component.datatable.DataTable;
    import com.sample.ejb.PersonSingletonBean;
    import com.sample.model.Person;
     
    @ManagedBean(name = "personManager")
    @SessionScoped
    public class PersonManager
    {
        private DataTable uiDataTable;
        private int currentRows = 5;
     
        @EJB
        PersonSingletonBean ejb;
     
        private Person selectedPerson;
        private Person[] selectedPersons = new Person[0];
     
        private String identity;
        private String name;
        private Date birthdate;
     
        public PersonManager()
        {
            super();
        }
     
        public DataTable getUiDataTable()
        {
            if (uiDataTable == null)
            {
                uiDataTable = new DataTable();
            }
            return uiDataTable;
        }
     
        public void setUiDataTable(DataTable uiDataTable)
        {
            this.uiDataTable = uiDataTable;
            if (this.uiDataTable != null)
            {
                currentRows = this.uiDataTable.getRows();
            }
        }
     
        public int getCurrentRows()
        {
            return currentRows;
        }
     
        public void setCurrentRows(int currentRows)
        {
            this.currentRows = currentRows;
        }
     
        public Person getSelectedPerson()
        {
            return selectedPerson;
        }
     
        public void setSelectedPerson(Person selectedPerson)
        {
            this.selectedPerson = selectedPerson;
        }
     
        public Person[] getSelectedPersons()
        {
            return selectedPersons;
        }
     
        public void setSelectedPersons(Person[] selectedPersons)
        {
            this.selectedPersons = selectedPersons;
        }
     
        public String getIdentity()
        {
            return identity;
        }
     
        public void setIdentity(String identity)
        {
            this.identity = identity;
        }
     
        public String getName()
        {
            return name;
        }
     
        public void setName(String name)
        {
            this.name = name;
        }
     
        public Date getBirthdate()
        {
            return birthdate;
        }
     
        public void setBirthdate(Date birthdate)
        {
            this.birthdate = birthdate;
        }
     
        /**
         * Initialisation des propriétés du formualaire
         */
        public void init()
        {
            identity = null;
            name = null;
            birthdate = null;
        }
     
        /**
         * Ajout à la liste
         */
        public String save()
        {
            if (identity == null || identity.trim().length() == 0 || name == null || name.trim().length() == 0)
            {
                return null;
            }
     
            Person person = ejb.get(identity);
            if (person == null)
            {
                ejb.put(identity, name, birthdate);
                FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Clé ajoutée", "La clé " + identity + " a été ajoutée à la liste");
                FacesContext.getCurrentInstance().addMessage(null, msg);
            }
            else
            {
                person.setIdentity(getIdentity());
                person.setName(getName());
                person.setBirthdate(getBirthdate());
                FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Clé modifiée", "La clé " + identity + " a été modifiée");
                FacesContext.getCurrentInstance().addMessage(null, msg);
            }
     
            init();
            return "liste";
        }
     
        /**
         * Demande du détail
         */
        public String loadDetail()
        {
            String identity = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("identity");
            if (identity == null)
            {
                return null;
            }
     
            Person person = ejb.get(identity);
            setIdentity(person.getIdentity());
            setName(person.getName());
            setBirthdate(person.getBirthdate());
            return "detail";
        }
     
        /**
         * Retrait de la liste
         */
        public void clear()
        {
            String identity = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("identity");
            if (identity == null)
            {
                return;
            }
     
            ejb.delete(identity);
            FacesContext.getCurrentInstance().addMessage(null,
                    new FacesMessage(FacesMessage.SEVERITY_INFO, "Clé retirée", "La clé " + identity + " a été retirée de la liste"));
            selectedPerson = null;
        }
        /**
         * Suppression multiple
         */
        public String delete()
        {
            for (Person person : (Person[])uiDataTable.getSelection())
            {
                ejb.delete(person);
            }
            return "liste";
        }
     
        /**
         * Recréation des données de la liste
         */
        public void reinit()
        {
            ejb.initCache();
        }
     
        /**
         * Liste des clés/valeurs
         */
        public List<Person> getCacheList()
        {
            return ejb.getCache();
        }
     
        /**
         * Routine de validation
         */
        public void validateForm(FacesContext context, UIComponent validate, Object value)
        {
            if ("identity".equals(validate.getId()))
            {
                String v = (String) value;
                if (v == null || v.trim().length() == 0)
                {
                    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "identity", "Champ identité obligatoire"));
                }
            }
     
            if ("name".equals(validate.getId()))
            {
                String v = (String) value;
                if (v == null || v.trim().length() == 0)
                {
                    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "name", "Champ nom obligatoire"));
                }
            }
     
            if ("birthdate".equals(validate.getId()) || "birthdate2".equals(validate.getId()))
            {
                Date v = (Date) value;
                if (v == null)
                {
                    throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR, "birthdate",
                            "Champ date de naissance obligatoire"));
                }
            }
        }
     
        /**
         * Récupération du timezone serveur pour le formattage des dates dans la vue
         */
        public String getServerTimeZone()
        {
            return TimeZone.getDefault().getID();
        }
     
    }

  4. #4
    Modérateur
    Avatar de OButterlin
    Homme Profil pro
    Inscrit en
    Novembre 2006
    Messages
    7 313
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations forums :
    Inscription : Novembre 2006
    Messages : 7 313
    Points : 9 529
    Points
    9 529
    Billets dans le blog
    1
    Par défaut
    Bon, pour information à ceux qui tomberont sur ce problème, ce n'est pas un bug de primefaces mais de jsf.
    c'est lié au scope session, en utilisant le scope request, ça passe...

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

Discussions similaires

  1. Réponses: 3
    Dernier message: 31/03/2014, 17h10
  2. Réponses: 7
    Dernier message: 24/02/2014, 11h50
  3. primefaces :filtre de datatable
    Par MlleL dans le forum JSF
    Réponses: 0
    Dernier message: 10/04/2013, 02h46
  4. Réponses: 1
    Dernier message: 27/10/2011, 19h24
  5. [RichFaces] Bug avec SuggestionBox dans dataTable
    Par albaille dans le forum JSF
    Réponses: 31
    Dernier message: 10/12/2007, 08h46

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