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 2 Java Discussion :

Erreur "No result defined for action jim.sums.register.actions.UpdateAction and result input"


Sujet :

Struts 2 Java

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    167
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 167
    Par défaut Erreur "No result defined for action jim.sums.register.actions.UpdateAction and result input"
    Bonjour,

    alors voila j'ai un formulaire qui met a jour des champs et qui fonctionnait tres bien jusqu'a ce que j'implemente des validations.

    Depuis que j'ai ces validations sous forme d'annotations qui marchent a leur tour tres bien, et ben lorsque je veux mettre a jour mon formulaire en cliquant sur "Update" j'obtiens cette erreur Tomcat :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    No result defined for action jim.sums.register.actions.UpdateAction and result input.
    Alors, j'ai ensuite rajouté un result input dans mon struts / action mais la, ya carement aucune mise a jour qui se fait.

    J'en suis donc arrivé a la conclusion qu'il y a quelque chose qui ne lui plait pas avec nmes validations et je ne comprends pas quoi car j'utilise les MEMES validations dans un autre formulaire (lorsque l'utilisateur s'enregistre) et la pas de probleme.

    Voici ma classe "UpdateAction" avec les validations :

    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
     
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    package jim.sums.register.actions;
     
    import com.opensymphony.xwork2.ActionSupport;
    import com.opensymphony.xwork2.validator.annotations.EmailValidator;
    import com.opensymphony.xwork2.validator.annotations.RequiredFieldValidator;
    import com.opensymphony.xwork2.validator.annotations.Validation;
    import com.opensymphony.xwork2.validator.annotations.ValidatorType;
    import java.util.HashSet;
    import java.util.Set;
    import jim.common.jimaas.struts2.User;
    import jim.common.jimaas.struts2.UserAware;
    import jim.sums.db.Cohort;
    import jim.sums.db.Person;
    import jim.sums.db.PersonStatus;
    import jim.sums.service.CommonService;
    import jim.sums.service.RegisterService;
     
    @Validation()
    public class UpdateAction extends ActionSupport implements UserAware {
     
        private User user = null;
        private String message;
        private Long id;
        private String username;
        private String forename;
        private String surname;
        private String password;
        private String hemis;
        private String orgaName;
        private String orgaAddress;
        private String orgaActivity;
        private String orgaPostcode;
        private Set<String> address = new HashSet<String>();
        private Set<String> number = new HashSet<String>();
        private Set<Integer> title = new HashSet<Integer>();
        private String result;
        private Set<Cohort> resultCohort = new HashSet<Cohort>();
        private PersonStatus status;
        private Set<String> suspendedReason = new HashSet<String>();
        private Set<String> instigaterReason = new HashSet<String>();
     
        public Set<String> getInstigaterReason() {
            return instigaterReason;
        }
     
        public void setInstigaterReason(Set<String> instigaterReason) {
            this.instigaterReason = instigaterReason;
        }
     
        public Set<String> getSuspendedReason() {
            return suspendedReason;
        }
     
        public void setSuspendedReason(Set<String> suspendedReason) {
            this.suspendedReason = suspendedReason;
        }
     
        public PersonStatus getStatus() {
            return status;
        }
     
        public void setStatus(PersonStatus status) {
            this.status = status;
        }
     
        @Override
        public void setUser(User user) {
            this.user = user;
        }
     
        public User getUser() {
            return user;
        }
     
        public String getMessage() {
            return message;
        }
     
        public void setMessage(String message) {
            this.message = message;
        }
     
        public String getHemis() {
            return hemis;
        }
     
        public void setHemis(String hemis) {
            this.hemis = hemis;
        }
     
        public String getOrgaActivity() {
            return orgaActivity;
        }
     
        public void setOrgaActivity(String orgaActivity) {
            this.orgaActivity = orgaActivity;
        }
     
        public String getOrgaAddress() {
            return orgaAddress;
        }
     
        public void setOrgaAddress(String orgaAddress) {
            this.orgaAddress = orgaAddress;
        }
     
        public String getOrgaName() {
            return orgaName;
        }
     
        public void setOrgaName(String orgaName) {
            this.orgaName = orgaName;
        }
     
        public String getOrgaPostcode() {
            return orgaPostcode;
        }
     
        public void setOrgaPostcode(String orgaPostcode) {
            this.orgaPostcode = orgaPostcode;
        }
     
        public Set<Cohort> getResultCohort() {
            return resultCohort;
        }
     
        public void setResultCohort(Set<Cohort> resultCohort) {
            this.resultCohort = resultCohort;
        }
     
        public Set<Integer> getTitle() {
            return title;
        }
     
        public void setTitle(Set<Integer> title) {
            this.title = title;
        }
     
        public Set<String> getAddress() {
            return address;
        }
     
        @EmailValidator(type = ValidatorType.FIELD, message = "You must enter a valid email address.")
        public void setAddress(Set<String> address) {
            this.address = address;
        }
     
        public Set<String> getNumber() {
            return number;
        }
     
        @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a phone number.")
        public void setNumber(Set<String> number) {
            this.number = number;
        }
     
        public String getPassword() {
            return password;
        }
     
        @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a password.")
        public void setPassword(String password) {
            this.password = password;
        }
     
        public String getForename() {
            return forename;
        }
     
        @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a forename.")
        public void setForename(String forename) {
            this.forename = forename;
        }
     
        public Long getId() {
            return id;
        }
     
        public void setId(Long id) {
            this.id = id;
        }
     
        public String getSurname() {
            return surname;
        }
     
        @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter a surname.")
        public void setSurname(String surname) {
            this.surname = surname;
        }
     
        public String getUsername() {
            return username;
        }
     
        @RequiredFieldValidator(type = ValidatorType.FIELD, message = "You must enter an username.")
        public void setUsername(String username) {
            this.username = username;
        }
     
        public String getResult() {
            return result;
        }
     
        public void setResult(String result) {
            this.result = result;
        }
     
     
     
        @Override
        public String execute() throws Exception {
            //Default login mechanism is to allow the user in
            try {
                CommonService cs = new CommonService();
                Person p = cs.getPersonById(user.getId());
                RegisterService rs = new RegisterService();
     
                this.status = p.getStatus();
     
     
                if (this.getTitle().isEmpty()) {
                    rs.updatePerson(this.getId(), this.getForename(), this.getSurname(), this.getUsername(), this.getPassword(), this.getAddress(), this.getNumber());
                } else {
                    this.setResultCohort(rs.getSelectedCohort(this.getTitle()));
                    rs.updatePerson(this.getId(), this.getForename(), this.getSurname(), this.getUsername(), this.getPassword(), this.getAddress(), this.getNumber(), this.getResultCohort());
                }
     
                if (this.getStatus().getName().equals("Student")) {
                    rs.updateStudent(this.getId(), this.getHemis());
                } else if (this.getStatus().getName().equals("External actor")) {
                    rs.updateOrganisation(this.getId(), this.getOrgaName(), this.getOrgaActivity(), this.getOrgaAddress(), this.getOrgaPostcode());
                }
     
                if (!this.getInstigaterReason().isEmpty()) {
                    rs.updateInstigaterReason(this.getId(), this.getInstigaterReason());
                }
     
                if (!this.getSuspendedReason().isEmpty()) {
                    rs.updateSuspendedReason(this.getId(), this.getSuspendedReason());
                }
     
                setMessage("Logged in as " + user.getUsername());
                return SUCCESS;
            } catch (Exception e) {
                this.setResult("EXCEPTION : " + e);
                return ERROR;
            }
     
     
        }
    }
    Donc voila si quelqu'un a une idéé ca ne serait pas de refus !

    Merci a vous !

    Andrew

  2. #2
    Membre chevronné Avatar de supermanu
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    330
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Janvier 2004
    Messages : 330
    Par défaut
    Peux-tu montrer la configuration xml de ton action ?

  3. #3
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    167
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 167
    Par défaut
    Voici la configuration xml de l'action :

    Je sais que d'apres l'erreur, on pourrait penser que c'est parce que je n'ai pas de result input dans mon xml, mais lorsque j'en met un ca ne change pas grand chose car meme si je n'obtiens plus d'erreur tomcat, ma mise a jour de mes champs ne fonctionne pas.

    Ce qui est normal vu que ce qui m'interesse est de retourner un SUCCESS

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
     
    <action name="FullUpdate" class="jim.sums.register.actions.UpdateAction">
                <result name="success" type="redirect">DisplayMembers.action</result>
                <result name="error">/WEB-INF/view/register/error.jsp</result>
            </action>

  4. #4
    Membre chevronné Avatar de supermanu
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    330
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Janvier 2004
    Messages : 330
    Par défaut
    En effet j'aurais fait comme toi : mettre un result input

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    <result name="input">/WEB-INF/view/register/error.jsp</result>
    hummmm... as-tu essayé de mettre des result en annotation du style :

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    @Results({
    @Result(name="success", value="index", type=ServletActionRedirectResult.class),
    @Result(name="input",type=ServletDispatcherResult.class, value="/WEB-INF/jsp/user/findUser-success.jsp")
    }) @Validation public class UpdateAction extends ActionSupport implements UserAware {

  5. #5
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    167
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 167
    Par défaut
    Il me dit qu'il y a des problemes d'incompatibilité lorsque j'écrit ce tag Results pourtant j'ai fais tous les imports qu'il falait.

  6. #6
    Membre confirmé
    Inscrit en
    Novembre 2006
    Messages
    167
    Détails du profil
    Informations forums :
    Inscription : Novembre 2006
    Messages : 167
    Par défaut
    J'ai finalement reussi a resoudre le probleme.

    Avec un debugage intensif j'ai pu voir que mon passage en parametre caché (s:hidden) d'un object nommé status ne lui plaisait pas du tout. En effet il rendait ce dernier nul.

    Du coup, j'ai contourné ceci pour passer un string et depuis ca fonctionne.

    Merci pour ton aide

    ++

  7. #7
    Membre chevronné Avatar de supermanu
    Profil pro
    Inscrit en
    Janvier 2004
    Messages
    330
    Détails du profil
    Informations personnelles :
    Âge : 42
    Localisation : France, Paris (Île de France)

    Informations forums :
    Inscription : Janvier 2004
    Messages : 330
    Par défaut
    Ah oui c'était subtil, bien joué

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

Discussions similaires

  1. [XSD] Message d'erreur "No element type is defined for message"
    Par berceker united dans le forum Valider
    Réponses: 3
    Dernier message: 22/12/2010, 20h11
  2. Réponses: 0
    Dernier message: 26/08/2009, 15h59
  3. Réponses: 3
    Dernier message: 19/10/2006, 21h51
  4. [C#][debutant]erreur => object reference is required for a no
    Par ChristopheOce dans le forum Windows Forms
    Réponses: 3
    Dernier message: 25/01/2006, 13h47
  5. Réponses: 3
    Dernier message: 14/01/2006, 18h09

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