« Return to Thread: VWP - dropDown bound to DB question

Re: VWP - dropDown bound to DB question

by Chris Kutler :: Rate this Message:

Reply to Author | View in Thread

Another approach is to add the extra option in the query, such as

select person.personid, person.name from person union select -1, 'Select
Something' from person...

Sergei Mutovkin wrote:

> On 2/14/07, titan <lawndale99@...> wrote:
>
>>
>> Add the extra option in your prerender method, i.e.
>>
>>         if (dropDown.getSelected() == null) {
>>
>> // add value to dataprovider
>>
>> dropDownDataProvider.setCursorRow(dropdownDataProvider.appendRow());
>>             dropDownDataProvider.setValue("VALUE", -1);
>>             dropDownDataProvider.setValue("DISPLAY_NAME", "Select
>> something
>> from list");
>>
>> // set selected row for the dropdown list
>>             dropDown.setSelected(-1);
>>         }
>>
> There are two problems with this approach it seems:
> 1. Item is added at the very end of the list (not a big issue but
> really inconsistent with the rest of the pages on the Internet).
> 2. If you hit the browser's Refresh button on just loaded page, you
> would see your item two times.. click more - more items are added to
> the data provider.
>
> I do not yet know how to resolve #1 (I'm just a few days into a whole
> JEE stuff), but for #2 it can be easily avoided by adding a property
> to the SessionBean which will indicate if it is the first time page is
> loaded during the session.
>
> --
> Sergei


--

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Chris Kutler
Sun Java Studio Creator Tutorials
http://blogs.sun.com/divas

 « Return to Thread: VWP - dropDown bound to DB question