Hi all,
this is all within struts framework:
I am reading customer information from a database as a value object that CustomerForm uses for setting and getting form properties. I know for sure that all of this working fine. the problem is that the jsp that uses the CustomerForm doesn't display the information in fields that could be editable by customers. I have succeeded in displaying the information by storing the value object in the session and using the<form:bean write>. but that doesn't solve my problem. I hope I am making sence
thank you in advance
A
-
help: populating a form (6 messages)
- Posted by: ahmed tantan
- Posted on: February 13 2003 14:24 EST
Threaded Messages (6)
- help: populating a form by Chuck Cavaness on February 13 2003 23:10 EST
- help: populating a form by ahmed tantan on February 14 2003 11:00 EST
-
help: populating a form by Chuck Cavaness on February 14 2003 01:07 EST
-
help: populating a form by ahmed tantan on February 14 2003 02:37 EST
- help: populating a form by ahmed tantan on February 17 2003 10:11 EST
-
help: populating a form by ahmed tantan on February 14 2003 02:37 EST
-
help: populating a form by Chuck Cavaness on February 14 2003 01:07 EST
- help: <html:options> tag is very confusing by ahmed tantan on February 20 2003 18:57 EST
- help: populating a form by ahmed tantan on February 14 2003 11:00 EST
-
help: populating a form[ Go to top ]
- Posted by: Chuck Cavaness
- Posted on: February 13 2003 23:10 EST
- in response to ahmed tantan
If I'm understanding your question right, you need to use the HTML tag library that comes with struts. This JSP custom tag library includes components like text fields that know how to pull data out of the form beans and put it into editable fields. Check the Struts documentation for more info.
Chuck -
help: populating a form[ Go to top ]
- Posted by: ahmed tantan
- Posted on: February 14 2003 11:00 EST
- in response to Chuck Cavaness
Thanks for your reply,
I am using the tags correctly<html:text property=name> inside the jsp. Infact I have identified the problem, I just don't know how to fix it. it's something like this:
the senario of this application:
1)Customer Enter his Name
2)PreRegisterAction gets the name
3)uses this value to lookup customer info in DB
4)puts info in object(cvo)
5)passing cvo to RegisterForm to set all the properties
6)Request is forwarded to Register.jsp
7)Request.jsp displays Info via <html:text>
PreRegister.jsp{
Name = <html:text property=name>
submit
}
PreRegisterForm{
getName;
setName;
}
preRegisterAction{
public CustomerVo findCustomer(name){
return cvo
}
execute(.....){
PreRegisterForm prg = (PreRegisterForm)form;
String name = prf.getName();
CustomerVo cvo = findCustomer(name);
RegisterForm rf = new RegisterForm();
rf.setCustomerVo();
System.out.println("rf.City = "+rf.getCity());
forward to (Register.jsp)
}
}
======
Register.jsp{
Name = <html:text property=name>
Address = <html:text property=address>
City = <html:textporperty=city>
submit
}
RegisterFrom {
getName(), getAddress(), getCity()
setName(), setAddress(), setCity()
*public CustomerVo getCustomerVo() {
return new CustomerVo(this.name,...);
}
*public void setCustomerVo(CustomerVo cvo) {
this.name=(cvo.getName());
....
}
}//RegisterForm
when the customer hit submit from PreRegister.jsp, Request.jsp apperas with all the fields blank. However the command line shows rf.getCity = Orlando. it seems like there are two diffrent RegisterForms. -
help: populating a form[ Go to top ]
- Posted by: Chuck Cavaness
- Posted on: February 14 2003 13:07 EST
- in response to ahmed tantan
Are you doing redirects or forwards? Also, which version of Struts are you using?
chuck -
help: populating a form[ Go to top ]
- Posted by: ahmed tantan
- Posted on: February 14 2003 14:37 EST
- in response to Chuck Cavaness
Chuck,
sorry i didn't see your message until now,I am usting forwards and struts1.1-b3. -
help: populating a form[ Go to top ]
- Posted by: ahmed tantan
- Posted on: February 17 2003 10:11 EST
- in response to ahmed tantan
Chuck,
I just wanted to let you know that I have fixed the problem. I guess I needed to pay more attention to struts-conig.xml, I was associating the wrong form with the Action Element. It was all my fault, thank you for your help.
A -
help: <html:options> tag is very confusing[ Go to top ]
- Posted by: ahmed tantan
- Posted on: February 20 2003 18:57 EST
- in response to Chuck Cavaness
I got a situatation where I have an arraylist of elements that i get from the db.
I would like to be able to display these element via the <html:select options> tag, the documentation on struts web-site is very confusing.
basically I am dispalying an empty form to the user where one of the fields is a drop down menu. I am also using a Value Object that sets/gets all the fields in the form bean to transfer Data between presentation and business tier.
I have no idea how to do write the setters and getters for this Collection property. thus, I was thinking about storing the collection in the session then use the <bean:iterate> tag in the jsp, while keeping the rest of the form the unchanged.
I would like some clarification in this subject. thank you in advance
A+