• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to solve this

 
kavitha vasu
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
  • 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
 
Laxmikant Ruikar
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • 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
 
Stevi Deter
Ranch Hand
Posts: 265
Hibernate Java Spring
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic