Sandra,

Probably if you have static data, then the approach that you are using will be a very 
efficient one.
However, if you are using constantly changing data and you are having to deal with 
huge data and 
require selective data, then you may have to think of other ways also.
Here is one way in which I worked on this issue.  This works great for me.
I have collections that constantly change based on user's selection.   To 
resolve the issue, I am doing a submit on every change so that the second 
combo box can actually get the latest collection.
To do this
------------First combo box------------
<html:select property=[property] onchange='document.forms[0].submit()'>
<html:options collection=[collection] property=[property to get] 
labelProperty=[display value] />
</html:select>
This will do a submit and the second combo box gets updated with the most current 
values.  The servlet
will be responsible for getting the data based on the first combo box.
The disadvantage is a call to the server on every change.  The advantage is 1) data 
stays current.
2) collection data can be minimal only pertaining to criterion of selection in the 
first combo box.

Thanks,
Vid

>>> [EMAIL PROTECTED] 01/31/03 02:21AM >>>
Thanks a lot for your help, I have a last small question 

To not have to call the server when the user select an new entry*in the
first
combo-box I have to add JavaScript code as indicated in your preceding mails

but I must also place the collections in the HttpSession or Servlet Context
(if
the collection is the same for all clients) and not in the request. 
Is it true ?

Sandra

-----Original Message-----
From: Eric C. Hein [mailto:[EMAIL PROTECTED]] 
Sent: 30 January 2003 19:08
To: Struts Users Mailing List
Subject: Re: how to use two combo-box which depend one on the other ?


Sandra,

This works with the javascript code Chris pointed you to.  The
communityIssue is the parent field and there are two dependent fields
(targetAudience & activityType).

- Eric


<td>
<html:select property="communityIssue" styleClass="select" size="10"
multiple="true" tabindex="11"
         onchange="fillSelectFromArray(this.form.communityIssue,
this.form.targetAudience, ((this.selectedIndex == -1) ? null : audiences));
                        fillSelectFromArray(this.form.communityIssue,
this.form.activityType, ((this.selectedIndex == -1) ? null : activities));">
      <html:options collection="communityIssueList" property="value"
labelProperty="label"/>
   </html:select>
</td>


Here is the javascript and STRUTS code to write the array into the page:

<script language="javascript">
audiences = new Array(
   <bean:write name="targetAudienceJSArray" filter="false"/>
);
activities = new Array(
   <bean:write name="activityTypesJSArray" filter="false"/>
);
</script>


----- Original Message -----
From: "Heligon Sandra" <[EMAIL PROTECTED]>
To: "'Struts Users Mailing List'" <[EMAIL PROTECTED]>
Sent: Thursday, January 30, 2003 8:41 AM
Subject: RE: how to use two combo-box which depend one on the other ?


> Do you have an example of this with the struts tags
> that allows to display combo-box from a collection of JavaBeans
> <html:select ...>
>   <html:option >  </html:option>
>
> Sandra
>
> -----Original Message-----
> From: Chris Halverson [mailto:[EMAIL PROTECTED]] 
> Sent: 30 January 2003 17:29
> To: Struts Users Mailing List
> Subject: Re: how to use two combo-box which depend one on the other ?
>
>
> Heligon Sandra <[EMAIL PROTECTED]> writes:
>
> > Do I have to ask the web server each time the user select a new
> > function, or is it possible to do this logic on the client side
> > (with JavaScript probably ???).
>
> Yep, w/ JavaScript. I just did this and used the basic functions found
> at:
>
> http://javascript.internet.com/forms/auto-drop-down.html 
>
> You have to populate the arrays from your servlet code, but it's
> pretty straightforward.
>
> cdh
>
> --
> Chris D. Halverson                         http://www.halverson.org/ 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED] 
> For additional commands, e-mail: [EMAIL PROTECTED] 
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED] 
For additional commands, e-mail: [EMAIL PROTECTED] 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to