Interaction between two dropdown boxes

View: New views
3 Messages — Rating Filter:   Alert me  

Interaction between two dropdown boxes

by Ted Byers :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am a bit confused.

On one page, I refresh the contents of a table when a new item is selected from a dropdown combobox.  I'd created a data provider, with a load function that took an integer as an argument, and this argument was supplied by the dropdown.  I didn't need to do anything further, and it works flawlessly.

On my new page, I created an analogous dataprovider for use with a second dropdown.  When the integer value is obtained from the first dropdown, it is used as an argument for the load function for the second.  I CAN step through this load function and see the correct data loaded into the data provider, but the second dropdown seems to know nothing of the new data.

You could envision the first dropdown as representing food groups (meat, vegetables, fruit, &c.) and the second representing specific foods (beef, pork, chicken, fish, apples, oranges, broccoli, carrots, beans ...).  Obviously, when meat is selected in the first, you want beef, pork, chicken, &c. (ONLY the meas) displayed in the second dropdown, and when the user selects some other food group, such as vegetables, you want only the vegetables displayed in the second dropdown.  You get the idea.  I CAN'T have this hardcoded, as the data must come from my RDBMS: hence my use of a data provider.  The second dropdown will, in my case, typically have up to a few dozen items out of a space of many thousands of items.

Why is it sufficient to call the load function of the data provider in order to have a table connected to the data provider refreshed with NEW data corresponding to the item selected from the controlling dropdown, but it isn't enough when you want to replace the options in a second dropdown based on what is selected in the first?

Do I have to resort to manually creating, say a map, or a set containing a class with two data members, to create the options in the second dropdown?

Thanks

Ted

Re: Interaction between two dropdown boxes

by Futaleufu_John :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I am assuming your dropdown data providers are linked to row sets. In most cases, I put my row sets in session beans. Things just seem to work better for me that way.

For the first data provider, your row set query would look like this:

    SELECT group_id, group_name FROM food_group

For the second data provider, your row set query would look like:

    SELECT food_id, food_name FROM foods WHERE group_id = ?

In prerender, you would get the selected group_id from the first drop down list and use that to set the parameter for the second row set query.
Ted Byers wrote:
You could envision the first dropdown as representing food groups (meat, vegetables, fruit, &c.) and the second representing specific foods (beef, pork, chicken, fish, apples, oranges, broccoli, carrots, beans ...).  Obviously, when meat is selected in the first, you want beef, pork, chicken, &c. (ONLY the meas) displayed in the second dropdown, and when the user selects some other food group, such as vegetables, you want only the vegetables displayed in the second dropdown.  You get the idea.  I CAN'T have this hardcoded, as the data must come from my RDBMS: hence my use of a data provider.  The second dropdown will, in my case, typically have up to a few dozen items out of a space of many thousands of items.
Any ads or links to ads that appear in this post are not endorsed nor recommended by this poster.

Parent Message unknown Re: Interaction between two dropdown boxes

by HandyGeek :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

The coordinated drop-downs tutorial is very helpful in this case:  http://blogs.sun.com/divas/entry/coordinated_drop_down_lists

 -------------- Original message ----------------------
From: Futaleufu_John <jhalupka@...>

>
> I am assuming your dropdown data providers are linked to row sets. In most
> cases, I put my row sets in session beans. Things just seem to work better
> for me that way.
>
> For the first data provider, your row set query would look like this:
>
>     SELECT group_id, group_name FROM food_group
>
> For the second data provider, your row set query would look like:
>
>     SELECT food_id, food_name FROM foods WHERE group_id = ?
>
> In prerender, you would get the selected group_id from the first drop down
> list and use that to set the parameter for the second row set query.
>
> Ted Byers wrote:
> >
> > You could envision the first dropdown as representing food groups (meat,
> > vegetables, fruit, &c.) and the second representing specific foods (beef,
> > pork, chicken, fish, apples, oranges, broccoli, carrots, beans ...).
> > Obviously, when meat is selected in the first, you want beef, pork,
> > chicken, &c. (ONLY the meas) displayed in the second dropdown, and when
> > the user selects some other food group, such as vegetables, you want only
> > the vegetables displayed in the second dropdown.  You get the idea.  I
> > CAN'T have this hardcoded, as the data must come from my RDBMS: hence my
> > use of a data provider.  The second dropdown will, in my case, typically
> > have up to a few dozen items out of a space of many thousands of items.
> >
>
> --
> View this message in context:
> http://www.nabble.com/Interaction-between-two-dropdown-boxes-tp19149908p19160564
> .html
> Sent from the Visual Web - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...