File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "How to solve this" Watch "How to solve this" New topic

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">
<bean:message key="label.login" />

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

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


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

Related form bean is as LoginForm , in validate method

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.

Laxmikant Ruikar

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.

Stevi Deter
Ranch Hand

Joined: Mar 22, 2008
Posts: 265


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

I agree. Here's the link:
subject: How to solve this
jQuery in Action, 3rd edition