Win a copy of Rust Web Development this week in the Other Languages forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

How to solve this

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Friends,

I developed login form in struts.

In this form i have 2 fields.

<tr class="table_row">
<td>
<bean:message key="label.login" />
</td>

<td>
<html:select property="district" styleId="dist" >
<option value="0"> --Select District--</option>
</html:select>

</td>
</tr>
<tr class="table_row">
<td>
<bean:message key="label.password" />
</td>
<td>
<html:text property="password">
</html:text>

</td>
</tr>

the Login values are dynamically loaded using ajax in district select box.



Related form bean is as LoginForm , in validate method

if(getPassword().equals(""))
{
errors.add(null,new ActionError("error.password.missing"));
//System.out.println("am h ere"+getMonth());
}

Its giving the error message properly.

But my old value in select box does not retained.

How to retain my old value in select box.


thanks
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Verify that in validate method are you getting value of district? if yes then you are resetting your form values back or your ajax code might resetting the value of district in your form.

LDR
 
Ranch Hand
Posts: 265
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kavitha,

What scope are you setting for your action?

If it's request, Struts will create a new form bean when you're forwarded to the input page, and your values will be lost (since you only asked for them to be kept in the request).
 
kavitha vasu
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for your reply.


Can you explain how can i populate values into select box from database while

form loading itself.


Currently am using ajax , I want to know how can i do this without using ajax


Thanks
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic