users@woodstock.java.net

Re: change in span id generation [was Re: multiple JSF portlet error: javascript init problem?]

From: Dan Labrecque <Dan.Labrecque_at_Sun.COM>
Date: Fri, 21 Mar 2008 10:54:18 -0500

Istvan Soos wrote:
>>>
>
> Hi Dan,
>
> I've built the latest CVS repository code, but it didn't work. I
> modified the RendererBase.java the following way:
> from:
> String id = "_"+component.getClientId(context);
> to
> String id = component.getClientId(context);

This probably will not work well. If the span uses the component id
(without modification), the page will contain two HTML elements with the
same id (i.e., after the widget adds its own HTML to the page).

My intention with the code above is to ensure that the span and widget
ids are unique. That is, the span id is always prefixed with a 'char',
but the widget id is not. This guarantees the ids of the span and widget
will not collide.

>
> This was because the HTML source contained references for both
> __someid (with 2 '_' chars) and _someid (with 1 '_') but with the
> modification it contians only with one '_' in the beginning.

I don't understand why the span id cannot have an extra '_' char?

>
> Still, it does not work. Even it is a bit worse, as not even the
> 'last' portlet is working.

If a '_' char does not work for you, try adding this to the end of the
id, instead. The span just has to be unique (i.e., different than the
widget).

>
>
>> Well, the only reason JavaScript would be overridden is if the code
>> above were included more than once.
>
> But it is included more than once, as each portlet contains this code.
> Check the HTML source I've included.

I see that now, but I don't understand why the bootstrap.js file is
included in each portlet? I'm not familiar with your portal server, but
these resources are typically included only once (by the portal) in the
head tag. In fact, if you include the same JavaScript file more than
once, I believe some browsers (IE?) will throw an exception.

Is there any way you can ensure the bootstrap.js file is included once?
(For example, just include it in the first portal as a quick test?)
Although, my 4.2 fix should ensure the JavaScript code is not
re-initialize, at least we would know if there is an issue with
including the bootstrap file more than once.

Thanks,
Dan