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: Wed, 26 Mar 2008 09:20:40 -0500

Istvan Soos wrote:
> Hi Dan,
>
> Sorry for the late response, I was a bit overwhelmed with my hard
> drive crash, really appreciate your fast answers...
>
>> I don't understand why the span id cannot have an extra '_' char?
>
> I don't know either, and I'm a bit unsure about this, you are possibly
> right about this span thing. I'll investigate a bit more later...
>
>>>
>>>> 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.
>
> At the moment I'd say the include entry in the page cannot be ensured,
> nor one-time-include enforced. This is because of the way the portlets
> are designed: they are unaware of each other's content, so they must
> include he bootstrap.js somewhere. As they cannot access the portal
> page's head content, they are forced to put that reference inside
> their body, and if there are more portlet on the page (which is normal
> I suppose), they will include it more times...

I was only asking if this could be done as a test? For example, add your
themeLinks tag to only the first portlet and see what happens.

>
> I think the generated include code is done at this point, and this
> little part is included in every JSF page in every portlet, so if we
> put more portlets on the same page, we will encounter repeated includes:
> <webuijsf:themeLinks binding="#{SampleIPCMain.themeLinks1}"
> id="themeLinks1"/>
>
> Is it possible to include a little conditional jump in the beginning
> of the bootstrap.js? E.g. if an environment variable is null, then do
> the bootstrap but set the environment variable to some value. If the
> variable is not null, do not run the bootstrap. This way we could
> safely include that line of code in every portlet without much hacky
> solution.
>
> What do you think about such workaround?

This is exactly what bootstrap.js does for the latest 4.2 release. If
the name space has already been defined, resources are not re-initialized.

Dan