Struts question

Discussion in 'Java' started by Java_Forum, Sep 20, 2003.

  1. Java_Forum

    Java_Forum Guest

    hi,
    i am trying to do a simple thing without success!!!
    in my web application (designed under the struts framework), i have a logon
    action which check the username and password of a user, if it's ok i create
    and store an object User with a session scope.
    i have a another item at my menu wich enable a user to display his
    information (stored in the user object), here is the code. theres is 3 files
    EditmonCompteAction wich display the user information.
    User bean wich store information about the user.
    MoncompteForm is the bean form used in the mapping-action.
    and finally of course the struts-config.xml


    EDITMONCOMPTEACTION********************public class EditMonCompteAction
    extends Action { public ActionForward execute(ActionMapping
    mapping,ActionForm form,HttpServletRequest request,HttpServletResponse
    response)throws Exception { //Recupere l'utilisateur 'user' en cours
    User user = (User) (request.getSession()).getAttribute(Globals.USER_KEY);
    if (user == null) return mapping.findForward("logon"); //Creation du
    form bean "moncompteForm" s'il n'existe pas if (form==null) { //Creation
    du from-bean form = new MoncompteForm(); //Ajout a la requets ou session
    selon l'attribut "scope" de <action-mapping> if
    ("request".equals(mapping.getScope()))
    request.setAttribute(mapping.getAttribute(),form); else
    request.getSession().setAttribute(mapping.getAttribute(),form); }
    //Copie de user vers form MoncompteForm moncompteForm = (MoncompteForm)
    form; PropertyUtils.copyProperties(moncompteForm, user); //Attache un
    synchroniser token pour eviter le double posting saveToken(request);
    //Renvoie vers moncompte return mapping.findForward("moncompte"); } }
    STRUTS-CONFIG.XML
    *****************

    .....<!-- ========== Global Forward Definitions
    ============================== --> <global-forwards> <forward name="index"
    path="/index.jsp"/> <forward name="logon" path="/logon.jsp"/> <forward
    name="acceuilUser" path="/acceuilUser.jsp"/> <forward name="moncompte"
    path="/moncompte.jsp"/> </global-forwards>......<!-- process an edit
    moncompte --> <action path="/editMonCompte"
    type="eshop.actions.EditMonCompteAction" attribute="moncompteForm"
    scope="request" validate="false"/> ......
    MONCOMPTEFORM
    *************

    public class MoncompteForm extends ValidatorForm{.... private String nom;
    private String prenom; private String password;.... public void
    setNom(String nom) {this.nom=nom;} public void setPassword(String password)
    {this.password = password;} public void setPrenom(String prenom)
    {this.prenom=prenom;}.... public String getNom() {System.out.println("entr?e
    dans MonCOmpteForm.getNom");return nom;} public String getPassword(){return
    password;} public String getPrenom() {return prenom;}}

    USER
    ****

    public class User {... private String nom; private String prenom; private
    String password;... public void setNom(String nom) {this.nom=nom; public
    void setPassword(String password) {this.password = password;} public void
    setPrenom(String prenom) {this.prenom=prenom;}....ublic String getNom()
    {return nom;} public String getPassword(){return password;} public String
    getPrenom() {return prenom;}}
    when the editMonCompte.execute() methode is performed, i have display the
    content of the form, and its property reflected those of the object USER,
    but nothing is displayed in the moncompte.jsp, which use ofcourse the struts
    html taglib (html:text, html:submit....)

    i don't understand what's wrong with my code
    thanks for your help.
    Java_Forum, Sep 20, 2003
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Katie Wright
    Replies:
    8
    Views:
    4,203
    Andrea Desole
    Jan 7, 2005
  2. Jason Us
    Replies:
    0
    Views:
    968
    Jason Us
    Oct 4, 2003
  3. jc1771
    Replies:
    0
    Views:
    387
    jc1771
    Dec 28, 2003
  4. sin
    Replies:
    3
    Views:
    711
    Sudsy
    Feb 22, 2004
  5. Pratap Das
    Replies:
    2
    Views:
    2,016
    Pratap Das
    Apr 5, 2004
Loading...

Share This Page