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

Développement Web en Java Discussion :

Récupérer un résultat dans un textarea


Sujet :

Développement Web en Java

  1. #1
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut Récupérer un résultat dans un textarea
    Salut à tous,

    J'ai une composante "Textarea" sous laquelle j'ai mis un formulaire comme ceci:

    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
     
     
    <ui:define name="body">
         <h:body>
            <center>
                <h4>UPLOAD APPLICATION</h4>
                <br/>
                <h:form id="fichier" enctype="multipart/form-data"  >
                    <center><p:inputTextarea style="width:500px;height:110px;" effectDuration="400" disabled="true" id="output_screen" /></center>
                    <p:separator />
              <h:panelGrid columns="2" cellpadding="5">
     
     
                <h:outputLabel  value="Keyname:" />
                <p:inputText value="#{application.keyname}" id="inst_key" required="false" disabled="true"/>
               <!-- <p:commandButton value="Generate" type="button" disabled="true"/> -->
               </h:panelGrid>
     
                    <p:commandButton value="Upload application"  type="submit" />
                    <p:commandButton value="Describe instances" type="submit" action="#{applicationController.describeInstances}" />
     
                    <p:commandButton value="Check" type="submit"/>
            </h:form>
               </center>
             <br/>
             °: Applications must be stored under the ~/
        </h:body>
     
                </ui:define>
    le traitement qui va se faire lorsque l'utilisateur clique sur le bouton "Describe instances", je veut la récupérer dans le "Textarea"...

    Remarque 1: Içi j'utilise le jeu de composants PrimeFaces!

    Remarque 2: le traitement du bouton describeInstances est le suivant:

    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
    String s = null;
            try {
     
            String []cmd = { "/bin/bash", "-c","cd ~/euca2-karray-x509/;. eucarc; euca-describe-instances"};
     
                Process p = Runtime.getRuntime().exec(cmd);
     
                BufferedReader stdInput = new BufferedReader(new
                     InputStreamReader(p.getInputStream()));
     
                BufferedReader stdError = new BufferedReader(new
                     InputStreamReader(p.getErrorStream()));
     
     
                System.out.println("Here is the standard output of the command:\n");
     
                while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
                }
     
                System.out.println("Here is the standard error of the command (if any):\n");
                while ((s = stdError.readLine()) != null) {
                    System.out.println(s);
                }
     
                System.exit(0);
            }
            catch (IOException e) {
                System.out.println("exception happened - here's what I know: ");
                e.printStackTrace();
                System.exit(-1);
            }
    Avec S est le résultat de ce traitement, et ce que je veut l'afficher !

    Merci pour votre aide!

  2. #2
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    Quelqu'un m'a proposer de faire du javascript, je me suis alors hésité si c'était la bonne solution ou non

    Avez vous une idée?

  3. #3
    Membre du Club
    Homme Profil pro
    Consultant informatique
    Inscrit en
    Mars 2009
    Messages
    44
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations professionnelles :
    Activité : Consultant informatique

    Informations forums :
    Inscription : Mars 2009
    Messages : 44
    Points : 50
    Points
    50
    Par défaut
    Bonjour

    Le javascript c'est pour des évènements du client (navigateur) et traiiter certaines choses sans avoir à recourir au serveur.
    Dans ton cas je pense que tu as forcément besoin d'aller au serveur (si j'ai bien compris) pour récupérer les résultats d'exécutions. Ce que je ferais c'est faire une méthode qui retourne un String et utiliser ce String pour alimenter un message où binder le textarea à un String qui sera mis à jour lors de l'appel de ta méthode.

  4. #4
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    C'est pas bien compliqué, essaie ca :
    ==> Coté client :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    ...
    <center><p:inputTextarea style="width:500px;height:110px;" effectDuration="400" disabled="true" id="output_screen" value="#{applicationController.monResultatCommande}"/>
    ...
    <p:commandButton value="Describe instances" type="submit" action="#{applicationController.describeInstances}"  update= "fichier fichier:output_screen"/>
    Et dans la methode de ton managedbean, apres l'execution de la commande tu mets à jour le champ
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    ...
    this.setMonResultatCommande(stdInput.readLine());
    Fonctionnellement en mettant le update ,ca force primefaces au retour de l'appel serveur à mettre jour ce champ. ca fait du code propre
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  5. #5
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    Merci DevServlet pour votre réponse mais j'ai eu un problème:

    Quand j'ai ajouté la ligne de
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    this.setMonResultatCommande(stdInput.readLine());
    dans ma méthode "describeInstance" (qui se trouve dans une classe a part), j'ai eu un message d'erreur sur setMonResultatCommande

    cannot find symbol
    symbol: method setMonResultatCommande(java.lang.String)
    location: class org.controllers.ApplicationController
    Que dois je faire? Merci

  6. #6
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    Autre chose
    Que voulez vous dire par la variable monResultatCommande ?

    Merci!

  7. #7
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    J'ai déclaré une nouvelle varaible
    private String MonResultatCommande;
    et j'ai fait le getter et le setter

    J'ai exécuté mais le TextArea n'a pas pris le résultat d'exécution !

  8. #8
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Je te suggère de faire une petit passe sur les best pratice java ici, car seules les noms de classes doivent commencer par une lettre minuscule. tous les framework s'appuient scrupuleusement sur cette nomenclature pour effectuer de l'instropection, déclare plutot ainsi
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    private String monResultatCommande;
    , et regeneres ton getter/setter. ensuite redis nous ce que ca donne. Mais en passant pourquoi dis tu que "dans ma méthode "describeInstance" (qui se trouve dans une classe a part), j'ai eu un message d'erreur sur setMonResultatCommande " , tout doit se déclarer et se passer dans ta classe ApplicationController non?
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  9. #9
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    , tout doit se déclarer et se passer dans ta classe ApplicationController non?
    Enfait, le traitement de la méthode "describeInstance" se trouve dans la classe ApplicationController.java et le textArea se trouve dans une autre page (instances.xhtml qui contient du code html + les composantes du primes faces)! , une sorte du model MVC si vous m'avez bien compris.

  10. #10
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    On te comprend très bien, et c'est le principe même de MVC en général et donc de JSF. Peut on voir le code de ton ApplicationController? et la page xhtml si ca ne marche toujours pas avec la dernière modif que je t'ai proposée?
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  11. #11
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    Ca n'a pas marché !

    voiçi le code du instances.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
    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
     
    <?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:p="http://primefaces.prime.com.tr/ui"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:ui="http://java.sun.com/jsf/facelets">
     
        <ui:composition template="/templates/template.xhtml">
     
        <h:head>
            <title>Run instance</title>
            <meta content='text/html; charset=UTF-8' http-equiv='Content-Type'/>
                <link type="text/css" rel="stylesheet" href="#{request.contextPath}/themes/bluesky/skin.css" />
                <link type="text/css" rel="stylesheet" href="#{request.contextPath}/css/roller/ui-darkness/theme.css" />
                <style type="text/css">
                    .ui-widget {
                        font-size: 75%;
                    }
                    .themeMenu {
                        overflow: auto;
                        height:300px;
                        width:200px;
                    }
                    .ui-layout-north {
                        z-index:20 !important;
                        overflow:visible;
                    }
                    .ui-layout-north .ui-layout-unit-content {
                        overflow:visible;
                    }
                </style>
     
        </h:head>
     
            <ui:define name="body">
         <h:body>
            <center>
                <h4>UPLOAD APPLICATION</h4>
                <br/>
                <h:form id="fichier" enctype="multipart/form-data"  >
                    <center><p:inputTextarea style="width:500px;height:110px;" effectDuration="400" disabled="true" id="output_screen" value="#{applicationController.monResultatCommande}"/></center>
                    <p:separator />
              <h:panelGrid columns="2" cellpadding="5">
     
     
                <h:outputLabel value="Application path: °" />
                 <!--   <p:fileUpload value="{Instance.file}" mode="simple" allowTypes="*.tar.gz" /> -->
                  <input type="file" id="f1" onchange="javascript:SavePath(this.value);" />
     
     
    <script language="JavaScript" type="text/javascript">
     
    function SavePath(ppp){
        alert (ppp);
     
    document.getElementById('fichier:j_idt51').setAttribute("value", ppp);
     
      return;
    }
     
    </script>
          <!--   </h:panelGrid>
                    <h:panelGrid columns="3" cellpadding="5"> -->
     
     
                <h:outputLabel  value="Keyname:" />
     
               <!-- <p:commandButton value="Generate" type="button" disabled="true"/> -->
               </h:panelGrid>
     
                    <p:commandButton value="Upload application"  type="submit" />
                    <p:commandButton value="Describe instances" type="submit" action="#{applicationController.describeInstances}" update= "fichier fichier:output_screen" />
     
                    <p:commandButton value="Check" type="submit"/>
            </h:form>
               </center>
             <br/>
             °: Applications must be stored under the ~/
        </h:body>
     
                </ui:define>
        </ui:composition>
    </html>
    ********

    Le code de ApplicationController.java (j'ai mis juste l'implémentation de la méthode describeInstance +constructeur, vu que il y a d'autre méthodes qui ne sont pas importantes):

    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
     
    private String monResultatCommande;
     
        public ApplicationController() {
        }
    public void describeInstances(){
     
            String s = null;
            try {
     
            String []cmd = { "/bin/bash", "-c","cd ~/euca2-karray-x509/;. eucarc; euca-describe-instances"};
     
                Process p = Runtime.getRuntime().exec(cmd);
     
                BufferedReader stdInput = new BufferedReader(new
                     InputStreamReader(p.getInputStream()));
     
                BufferedReader stdError = new BufferedReader(new
                     InputStreamReader(p.getErrorStream()));
     
     
                System.out.println("Here is the standard output of the command:\n");
     
                while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
     
                    this.setMonResultatCommande(stdInput.readLine());
                }
     
                System.out.println("Here is the standard error of the command (if any):\n");
                while ((s = stdError.readLine()) != null) {
                    System.out.println(s);
                }
     
                System.exit(0);
            }
            catch (IOException e) {
                System.out.println("exception happened - here's what I know: ");
                e.printStackTrace();
                System.exit(-1);
            }
     
        }

  12. #12
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Envoi le code de la classe complete stp, je veux voir comment sont generés tes accesseurs.
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  13. #13
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    ok
    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
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    275
    276
    277
    278
    279
    280
    281
    package org.controllers;
     
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import org.entities.Application;
    import org.controllers.util.JsfUtil;
    import org.controllers.util.PaginationHelper;
    import org.beans.ApplicationFacade;
     
    import java.util.ResourceBundle;
    import javax.ejb.EJB;
    import javax.faces.bean.ManagedBean;
    import javax.faces.bean.SessionScoped;
    import javax.faces.component.UIComponent;
    import javax.faces.context.FacesContext;
    import javax.faces.convert.Converter;
    import javax.faces.convert.FacesConverter;
    import javax.faces.model.DataModel;
    import javax.faces.model.ListDataModel;
    import javax.faces.model.SelectItem;
     
    @ManagedBean (name="applicationController")
    @SessionScoped
    public class ApplicationController {
     
        private Application current;
        private DataModel items = null;
        @EJB private org.beans.ApplicationFacade ejbFacade;
        private PaginationHelper pagination;
        private int selectedItemIndex;
        private String monResultatCommande;
     
        public ApplicationController() {
        }
     
        public Application getSelected() {
            if (current == null) {
                current = new Application();
                selectedItemIndex = -1;
            }
            return current;
        }
     
        private ApplicationFacade getFacade() {
            return ejbFacade;
        }
     
        public PaginationHelper getPagination() {
            if (pagination == null) {
                pagination = new PaginationHelper(10) {
     
                    @Override
                    public int getItemsCount() {
                        return getFacade().count();
                    }
     
                    @Override
                    public DataModel createPageDataModel() {
                        return new ListDataModel(getFacade().findRange(new int[]{getPageFirstItem(), getPageFirstItem()+getPageSize()}));
                    }
                };
            }
            return pagination;
        }
     
        public String prepareList() {
            recreateModel();
            return "List";
        }
     
        public String prepareView() {
            current = (Application)getItems().getRowData();
            selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
            return "View";
        }
     
        public String prepareCreate() {
            current = new Application();
            selectedItemIndex = -1;
            return "Create";
        }
     
        public String create() {
            try {
                getFacade().create(current);
                JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("ApplicationCreated"));
                return prepareCreate();
            } catch (Exception e) {
                JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
                return null;
            }
        }
     
        public void describeInstances(){
     
            String s = null;
            try {
     
            String []cmd = { "/bin/bash", "-c","cd ~/euca2-karray-x509/;. eucarc; euca-describe-instances"};
     
                Process p = Runtime.getRuntime().exec(cmd);
     
                BufferedReader stdInput = new BufferedReader(new
                     InputStreamReader(p.getInputStream()));
     
                BufferedReader stdError = new BufferedReader(new
                     InputStreamReader(p.getErrorStream()));
     
     
                System.out.println("Here is the standard output of the command:\n");
     
                while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
     
                    this.setMonResultatCommande(stdInput.readLine());
                }
     
                System.out.println("Here is the standard error of the command (if any):\n");
                while ((s = stdError.readLine()) != null) {
                    System.out.println(s);
                }
     
                System.exit(0);
            }
            catch (IOException e) {
                System.out.println("exception happened - here's what I know: ");
                e.printStackTrace();
                System.exit(-1);
            }
     
        }
     
        public String prepareEdit() {
            current = (Application)getItems().getRowData();
            selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
            return "Edit";
        }
     
        public String update() {
            try {
                getFacade().edit(current);
                JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("ApplicationUpdated"));
                return "View";
            } catch (Exception e) {
                JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
                return null;
            }
        }
     
        public String destroy() {
            current = (Application)getItems().getRowData();
            selectedItemIndex = pagination.getPageFirstItem() + getItems().getRowIndex();
            performDestroy();
            recreateModel();
            return "List";
        }
     
        public String destroyAndView() {
            performDestroy();
            recreateModel();
            updateCurrentItem();
            if (selectedItemIndex >= 0) {
                return "View";
            } else {
                // all items were removed - go back to list
                recreateModel();
                return "List";
            }
        }
     
        private void performDestroy() {
            try {
                getFacade().remove(current);
                JsfUtil.addSuccessMessage(ResourceBundle.getBundle("/Bundle").getString("ApplicationDeleted"));
            } catch (Exception e) {
                JsfUtil.addErrorMessage(e, ResourceBundle.getBundle("/Bundle").getString("PersistenceErrorOccured"));
            }
        }
     
        private void updateCurrentItem() {
            int count = getFacade().count();
            if (selectedItemIndex >= count) {
                // selected index cannot be bigger than number of items:
                selectedItemIndex = count-1;
                // go to previous page if last page disappeared:
                if (pagination.getPageFirstItem() >= count) {
                    pagination.previousPage();
                }
            }
            if (selectedItemIndex >= 0) {
                current = getFacade().findRange(new int[]{selectedItemIndex, selectedItemIndex+1}).get(0);
            }
        }
     
        public DataModel getItems() {
            if (items == null) {
                items = getPagination().createPageDataModel();
            }
            return items;
        }
     
        private void recreateModel() {
            items = null;
        }
     
        public String next() {
            getPagination().nextPage();
            recreateModel();
            return "List";
        }
     
        public String previous() {
            getPagination().previousPage();
            recreateModel();
            return "List";
        }
     
        public SelectItem[] getItemsAvailableSelectMany() {
            return JsfUtil.getSelectItems(ejbFacade.findAll(), false);
        }
     
        public SelectItem[] getItemsAvailableSelectOne() {
            return JsfUtil.getSelectItems(ejbFacade.findAll(), true);
        }
     
        /**
         * @return the monResultatCommande
         */
        public String getMonResultatCommande() {
            return monResultatCommande;
        }
     
        /**
         * @param monResultatCommande the monResultatCommande to set
         */
        public void setMonResultatCommande(String monResultatCommande) {
            this.monResultatCommande = monResultatCommande;
        }
     
     
     
        @FacesConverter(forClass=Application.class)
        public static class ApplicationControllerConverter implements Converter {
     
            public Object getAsObject(FacesContext facesContext, UIComponent component, String value) {
                if (value == null || value.length() == 0) {
                    return null;
                }
                ApplicationController controller = (ApplicationController)facesContext.getApplication().getELResolver().
                        getValue(facesContext.getELContext(), null, "applicationController");
                return controller.ejbFacade.find(getKey(value));
            }
     
            java.lang.Integer getKey(String value) {
                java.lang.Integer key;
                key = Integer.valueOf(value);
                return key;
            }
     
            String getStringKey(java.lang.Integer value) {
                StringBuffer sb = new StringBuffer();
                sb.append(value);
                return sb.toString();
            }
     
            public String getAsString(FacesContext facesContext, UIComponent component, Object object) {
                if (object == null) {
                    return null;
                }
                if (object instanceof Application) {
                    Application o = (Application) object;
                    return getStringKey(o.getId());
                } else {
                    throw new IllegalArgumentException("object " + object + " is of type " + object.getClass().getName() + "; expected type: "+ApplicationController.class.getName());
                }
            }
     
        }
     
    }

  14. #14
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Essaie plutot ca pour le raffraichissement
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    <p:commandButton value="Describe instances" type="submit" action="#{applicationController.describeInstances}" update= "output_screen" />
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  15. #15
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    Même résultat!

  16. #16
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Enleve le type="submit" t'en as pas besoin. Normalement ca devrait marcher, qu'est ce qui marche pas au fait ? ta methode serveur est bien appelée, t'en es sur? mets un point d'arret et vas y en debug pour voir s'il rentre bien dans ta méthode, ou sinon trace un peu (system.out.println("...") dans cette methode), la syntaxe de mise à jour que tu veux faire est dans cet exemple de primefaces
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  17. #17
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    je vais le tester ...

    Le problème c'est que "System.out.println(s);" du

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     while ((s = stdInput.readLine()) != null) {
                    System.out.println(s);
     
                    this.setMonResultatCommande(stdInput.readLine());
                }
    affiche le résultat dans le console du NetBeans mais le TextArea reste toujuors vide !

  18. #18
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    this.setMonResultatCommande("Test");
    Essaie ça, on verra
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

  19. #19
    Débutant  
    Inscrit en
    Mai 2006
    Messages
    705
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 705
    Points : 117
    Points
    117
    Par défaut
    Le TextArea est toujours vide !

    J'ai, en effet,2 questions:

    1- Est ce que c'est correct de mettre le type de retour de la méthode "DescribeInstances" est void?

    2- Est ce que c'est correct de mettre la variable monResultatCommande de type private? (j'ai une suggestion, a votre avis, pk pas la mettre static)?

    Merci

  20. #20
    Membre expert
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Juin 2007
    Messages
    2 938
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels

    Informations forums :
    Inscription : Juin 2007
    Messages : 2 938
    Points : 3 938
    Points
    3 938
    Par défaut
    Citation Envoyé par L'aigle de Carthage Voir le message
    Le TextArea est toujours vide !

    J'ai, en effet,2 questions:

    1- Est ce que c'est correct de mettre le type de retour de la méthode "DescribeInstances" est void?

    2- Est ce que c'est correct de mettre la variable monResultatCommande de type private? (j'ai une suggestion, a votre avis, pk pas la mettre static)?

    Merci
    Oui pour tes 2 questions, mettre un type void de retour ca le fait bien si ta fonction n'a rien à retourner, par contre si le retour va servir à rediriger vers une autre page tu mets un type de retour dans ce cas. Bon ce qu'on va faire envoies moi un zip de ton projet ou un war vu que visiblement il n'ya pas de base de donnée derriere, je regarderai ça et te redirai.
    Vous avez peut être hâte de réussir et il n'y a rien de mal à cela...
    mais la patience est aussi une vertu; l'échec vous l'enseignera certainement..."

Discussions similaires

  1. [SAX] Parser un XML er récupérer le résultat dans une classe
    Par Invité dans le forum Format d'échange (XML, JSON...)
    Réponses: 2
    Dernier message: 23/12/2009, 16h37
  2. Réponses: 5
    Dernier message: 16/02/2006, 16h06
  3. Récupérer le résultat d'une PS dans une table temporaire ?
    Par maitrebn dans le forum MS SQL Server
    Réponses: 3
    Dernier message: 13/02/2006, 09h24
  4. récupérer le résultat d'une requête sql dans un edit
    Par bertrand_declerck dans le forum Bases de données
    Réponses: 3
    Dernier message: 28/07/2005, 14h07
  5. Réponses: 7
    Dernier message: 30/06/2005, 10h06

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