users@woodstock.java.net

Re: Unable to disable components with JavaScript

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Wed, 04 Jun 2008 15:00:26 -0400

The refresh request is performed asynchronously, so you're setProps call
may have been executed before the response was returned. You could have
subscribed to the refresh end event in order to invoke the setProps call
after the refresh.

Regarding focus, "dropDown2.focus()" is not a valid call. (This focus
function is on the DOM node associated with the underlying HTML select
element.) However, you can call dropDown2.getSelectElement().focus().

Dan

Ryan de Laplante wrote:
> Moving the setProps to after the refresh didn't help. I ended up
> removing the setProps and doing it server-side in the value change
> listeners. I also had to add the correct IDs to the refresh(). It
> now works the way I want, except the focus().
> function dropDown1Changed() {
> var dropDown2 =
> document.getElementById('form1:dropDown2');
>
> dropDown2.refresh('form1:dropDown1,form1:dropDown2,form1:dropDown3');
> var dropDown3 =
> document.getElementById('form1:dropDown3');
>
> dropDown3.refresh('form1:dropDown1,form1:dropDown2,form1:dropDown3');
> dropDown2.focus();
> }
> function
> dropDown2Changed() {
> var dropDown3 =
> document.getElementById('form1:dropDown3');
>
> dropDown3.refresh('form1:dropDown1,form1:dropDown2,form1:dropDown3');
> dropDown3.focus();
> }
>
> After I make a selection in dropDown1, I expect dropDown2 to have
> focus but it does not. After I make a selection in dropDown2 I expect
> dropDown3 to have focus but it does not. I don't see a server side
> property or method to set focus, so it probably has to be client side.
> Thanks for the link to the TLD documentation. I was going nuts trying
> to figure out how to use these components using only tutorials and
> examples. I thought the TLD javadoc was for programmers coding the
> components.
>
>
> Thanks,
> Ryan
>
>
> Dan Labrecque wrote:
>> Take a look at how the refresh feature works in the TLD for dropDown
>> below.
>>
>> http://webdev2.sun.com/woodstock-tlddocs
>>
>> Example #6 states:
>>
>> "Note that the refresh function can optionally take a list of
>> elements to execute. Thus, a comma-separated list of ids can be
>> provided to update components server-side:
>> refresh("form1:id1,form2:id2,..."). When no parameter is given, the
>> refresh function acts as a reset. That is, the component will be
>> redrawn using values set server-side, but not updated."
>>
>> If you want to maintain the current selection, you must provide the
>> ID of the dropDown being refreshed. However, this works more like a
>> form submit. That is, the disabled state is not an HTML input value
>> like a user selection. Calling refresh like this will override the
>> client-side disabled state.
>>
>> That said, consider calling refresh first, then set the dropDown
>> disabled. Alternatively, you can use a hidden field to maintain the
>> disabled state.
>>
>> Dan
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_woodstock.dev.java.net
> For additional commands, e-mail: users-help_at_woodstock.dev.java.net
>