You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Eric C. Hein" <gr...@mindspring.com> on 2002/12/20 21:29:15 UTC

javascript and STRUTS

Background:
In my form I have a field "city" that the user selects from a drop down list.  The city dropdown is initially setup to have one option that cues the user to select a county first (-1, select county first).  After the user selects a county the options list for city is then set to a javascript array of cities that are in the selected county. 

Problem:
After registering the user can edit his/her profile.  I'm having no trouble getting the county from the db to the <html:select> tag, but the city tag is not working.  When I call the javascript function that loads the cities I do get the correct cities (those corresponding to the county that came from the db).  I cannot however, set the correct value of the city field because the bean property "city" has already been overwritten by "-1".  

Is there anyway to capture the value of the bean before it is overwritten?

Thanks
- Eric

Re: javascript and STRUTS

Posted by "Eric C. Hein" <gr...@mindspring.com>.
Rick,
Thanks.  The problem with setting a hidden field was that after the form is
created the bean property was already overwritten.  What I needed to do was
set a javascript variable:
    theCity = new String(<bean:write name="beanName" property="city">);
This gets done before the form is created.

Rgds,
Eric


----- Original Message -----
From: "Rick Reumann" <ma...@reumann.net>
To: "Struts Users Mailing List" <st...@jakarta.apache.org>
Sent: Friday, December 20, 2002 12:46 PM
Subject: Re: javascript and STRUTS


>
>
> On Friday, December 20, 2002, 3:29:15 PM, Eric wrote:
>
> ECH> Is there anyway to capture the value of the bean before it is
overwritten?
>
> Since your using javascript coulnd't you set a hidden field
> "oldValue" that you can set before you do any overwriting? Then you
> would have access to the old value in whatever 'new' stuff you are
> doing.
>
>
> --
>
> Rick
> mailto:maillist@reumann.net
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: javascript and STRUTS

Posted by Rick Reumann <ma...@reumann.net>.

On Friday, December 20, 2002, 3:29:15 PM, Eric wrote:

ECH> Is there anyway to capture the value of the bean before it is overwritten?

Since your using javascript coulnd't you set a hidden field
"oldValue" that you can set before you do any overwriting? Then you
would have access to the old value in whatever 'new' stuff you are
doing.


-- 

Rick
mailto:maillist@reumann.net


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>