1

I'm trying to develop a simple Liferay portlet with the Icefaces framework and cannot get jQuery to work.

The main problem is, that I can't load the jQuery library properly. Whenever I add script tags to my xhtml header like this

<h:head>
    <script></script>
</h:head>

the page shows an error message:

failed to append text[ ] into #document

So I tried loading the jQuery libray with the h:outputScript tag instead, but in Icefaces, the target="head" option doesn't work - see http://jira.icesoft.org/browse/ICE-8313.

<h:outputScript library="scripts" name="jquery-1.9.1.js" target="head" />

So, at this point I'm clueless who to include the jQuery (or any javascript) library.

Please don't suggest using another framework. Icefaces is demanded in future projects, so I have to get used to it.

All I'm trying to do is something like this: http://jqueryui.com/sortable/

Thanks in advance, Fabi.

4

2 回答 2

3

I hope you know that this <h:head> tag would ultimately generate an HTML <head> tag.

And since portlets are just fragments they should not contain any type of <head> tag, so in liferay you can specify your javascript either in <header-portlet-javascript> or <header-portal-javascript> element in liferay-portlet.xml.

Or else include your javscript library in the theme you would create inside the portal_normal.vm.

于 2013-02-21T14:19:11.800 回答
0

You can import a JS-Library with the <header-portlet-javascript> in the liferay-portlet.xml file. Maybe this (older) example can help you.

于 2013-02-21T14:21:27.927 回答