File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Struts and the fly likes How to solve this Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to solve this" Watch "How to solve this" New topic
Author

How to solve this

kavitha vasu
Ranch Hand

Joined: Feb 22, 2007
Posts: 70
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

Joined: Nov 29, 2005
Posts: 23
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

Joined: Mar 22, 2008
Posts: 265

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).


There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
kavitha vasu
Ranch Hand

Joined: Feb 22, 2007
Posts: 70
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to solve this