• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Form Beans and retaining values

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
[code]

<action path="/fetchNext"
type="com.zerodegrees.struts.actions.auth.FetchNextAction"
name="sregisterForm"
scope="session"
validate="false"
redisplay="true">
<forward name="success" path="/views/auth/registration.jsp"/>
</action>

<action path="/register"
type="com.zerodegrees.struts.actions.auth.RegisterAction"
name="registerForm"
scope="session"
validate="true"
redisplay="true"
input="/views/auth/registration.jsp">
<forward name="success" path="/views/auth/registerConfirm.jsp" />
<forward name="failure" path="/views/auth/registration.jsp" /> </action>
/[code]

the above is from my struts config file. obviously i am trying ot register a user. i hae 4 drop downs in my page which i display one after the other depending on selection of the previous drop down. There is one problem here, the form gets refreshed for every request and the various input fields are flushed of their values. Is there somewhere i have done something wrong?
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by charu latha:
obviously i am trying ot register a user. i hae 4 drop downs in my page which i display one after the other depending on selection of the previous drop down. There is one problem here, the form gets refreshed for every request and the various input fields are flushed of their values. Is there somewhere i have done something wrong?



As far as I see your requirement, I think it's better to load all of the values from DB to your page and generate the dropdown list by using Java Script would be better... And also you don't need to refresh in this approach...

Hope it helps...
 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I cant do that because the values to be fetched are huge. So i have to manipulate it one at a time. In this instance i have to manipulate only 3 drop downs. One of which is already populated at form load. I only need to know how to retain the values when i sent the request for the next drop down values.
 
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi charu

See u r using the same form bean with scope session so that shuldnt be a problem teh data should be persisted i think there might be two places where something might go wrong

1.U should nt use the reset method i dont think so u r using this
2.Ur form bean should have 4 set and get methods to populate the values...........

if still u r facing this probs bettee u post one action formbeam and ur jsp too
 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

You mean i should not have a reset method at all in my form bean?

public String getCountry() {
return this.country;
}
public void setCountry(String country) {
this.country = country;
System.out.println("the country is " + this.country);
}

public String getState() {
return this.state;
}
public void setState(String state) {
this.state = state;
}

public String getCity() {
return this.city;
}
public void setCity(String city) {
this.city = city;

if my form bean also it contains a validate and reset method.
 
sreenath reddy
Ranch Hand
Posts: 415
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
remove the rest method validate wont affect ........

please try to post with proper english so that we can understand (dont mind bcoz i am not able to understand things properly in ur earlier post)

get back if u still face the same problem
 
charu latha
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am sorry. i was in a hurry to try it out and wanted to reply before i did. Thats why my english is bad. apologies. thanks for the input.
 
reply
    Bookmark Topic Watch Topic
  • New Topic