Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Struts question

Reply
Thread Tools

Struts question

 
 
Java_Forum
Guest
Posts: n/a
 
      09-20-2003
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_K EY);
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.getAttri bute(),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.


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it safe to point to Internet for locating struts DTD files in struts TLDs and XML files? Katie Wright Java 8 01-07-2005 03:37 PM
[Struts] Newbie - For ActionForm population, must I use Struts taglib? Pratap Das Java 2 04-05-2004 07:42 PM
[Struts]output javascript in struts perform() sin Java 3 02-22-2004 08:27 AM
Integrate a Struts app with a non-struts app jc1771 Java 0 12-28-2003 06:36 PM
Struts Installation - missing struts.tld??? Jason Us Java 0 10-03-2003 11:36 PM



Advertisments
 



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