Curious issue with dropdown control?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Curious issue with dropdown control?

Ted Byers
In the output from Apache Tomcat 6.0.16, I see the following:

"com.sun.webui.jsf.component.DropDown::The current value of component form1:dropDown2 does not match any of the selections.
"Did you forget to reset the value after changing the options? "

Why would this happen?  I NEVER change the options.  I programmatically set the selected value in only one place, as follows:

        com.sun.webui.jsf.model.Option[] tpOptions = (com.sun.webui.jsf.model.Option[])getDropDown2().getItems();
        getDropDown2().setSelected(tpOptions[0]);

This happens in the change event handler for the other dropdown control.  The idea is that dropdown2 should default to the first option it holds whenever a new item is selected using dropdown1.

Or is it the case that getItems+setSelected doesn't work the way I would intuitively expect?

Thanks

Ted
Reply | Threaded
Open this post in threaded view
|

Re: Curious issue with dropdown control?

Rick Fincher
Hi Ted,

This can happen when the dropdown is not static but populated from a
data source.  If the previously selected item is not in the dropdown on
a redraw, this can happen.

It doesn't really hurt anything.  It just lets you know.  It evidently
happens very early in the page rendering cycle because I've had trouble
getting rid of it too.

If you create your own options there may also be a default options left
defined in the page that is unused.  That can also create the mismatch.

Rick

Ted Byers wrote:

> In the output from Apache Tomcat 6.0.16, I see the following:
>
> "com.sun.webui.jsf.component.DropDown::The current value of component
> form1:dropDown2 does not match any of the selections.
> "Did you forget to reset the value after changing the options? "
>
> Why would this happen?  I NEVER change the options.  I programmatically set
> the selected value in only one place, as follows:
>
>         com.sun.webui.jsf.model.Option[] tpOptions =
> (com.sun.webui.jsf.model.Option[])getDropDown2().getItems();
>         getDropDown2().setSelected(tpOptions[0]);
>
> This happens in the change event handler for the other dropdown control.
> The idea is that dropdown2 should default to the first option it holds
> whenever a new item is selected using dropdown1.
>
> Or is it the case that getItems+setSelected doesn't work the way I would
> intuitively expect?
>
> Thanks
>
> Ted
>  


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Curious issue with dropdown control?

voodark
In reply to this post by Ted Byers
I have seen this issue, finally I found out that it is due to mismatch in what I am setting into dropDown in Java and what I am using in JSP.

I have dropDown1.setSelected(iserId); -- this I gave in Java in prerender

But JSP (which is generated) was referring to contactId column in the table

items="#{PortletPage1.contact_DataProvider.options['contact_.contactId,contact_.userId']}"

I changed this to

items="#{PortletPage1.contact_DataProvider.options['contact_.userId,contact_.userId']}" in JSP and then it worked fine