users@woodstock.java.net

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

From: Istvan Soos <syntern_at_sch.bme.hu>
Date: Wed, 26 Mar 2008 23:21:19 +0100

>> 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've done the test, created a p1 with the themeLinks included, p2
without it.

1 p1 - was ok
1 p1 + 1 p2 was ok (if the p1 one was before the p2)
1 p1 + more p2 was ok (if the p1 one was before the p2s, as the p2s
before the p1 were blank)
more p1 with any compination was wrong, all were blank

>> 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.

I'm using the latest trunk build, I've checked it out today. However
the case is if that bootstrap.js is included more than once, all
portlet blocks. If it is included only once, it is fine, but it is
essential that the first portlet does the include, as only the later
ones are affected. As portlets can be reordered at any time, there is
no way we can leave the themeLinks tag form any portlet. The only
option is to detect somehow the first include and do not run the init
codes at the later includes. At the moment I can see this only from
JavaScript, as the portlets are isolated, there is no way how I could
detect the previously referenced bootstrap.

Could you please suggest any workaround?

Thanks,
    Istvan