Foros de discusión

use jquery in jsp portlet

hadi mohammadi, modificado hace 10 años.

use jquery in jsp portlet

Junior Member Mensajes: 48 Fecha de incorporación: 3/06/13 Mensajes recientes
Hi friends.
i want use from jquery file in jsp portlet.
i use below code:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<%@ page contentType="text/html; charset=UTF-8"%>

<link rel="stylesheet" href="<%=request.getContextPath()%>/css/rightel-global.css">
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/rightel-home.css">
   
<portlet:defineobjects />


	<script src="<%=renderRequest.getContextPath()%>/js/jquery.unobtrusive-ajax.js"></script>
	<script src="<%=renderRequest.getContextPath()%>/js/jquery.validate.js"></script>
	<script src="<%=renderRequest.getContextPath()%>/js/rightel-global.js"></script>
	<script src="<%=renderRequest.getContextPath()%>/js/captcha.js"></script>
	<script src="<%=renderRequest.getContextPath()%>/js/jquery.blockUI.js"></script>

when i want use from jquery that don't run.
thumbnail
Antoine Comble, modificado hace 10 años.

RE: use jquery in jsp portlet

Regular Member Mensajes: 232 Fecha de incorporación: 7/09/12 Mensajes recientes
Hi,

if you want include javascript in your portlet, you must edit liferay-portlet.xml and adding <header-portlet-javascript></header-portlet-javascript> into the <portlet> node fo your portlet.
You can add <header-portlet-javascript></header-portlet-javascript> many times.

Regards,

Antoine
thumbnail
Serdar Ayalp, modificado hace 10 años.

RE: use jquery in jsp portlet

Junior Member Mensajes: 45 Fecha de incorporación: 2/09/11 Mensajes recientes
I make it so. in the file liferay-portlet you need to write the following in the portlet tag

<portlet>
<portlet-name>kasdataeingabe</portlet-name>
<icon>/icon.png</icon>
<indexer-class>..........</indexer-class>
<instanceable>false</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-css>/css/jquery-ui.css</header-portlet-css>
<header-portlet-javascript>/js/jquery-1.9.1.min.js</header-portlet-javascript>
<header-portlet-javascript>/js/jquery-ui.js</header-portlet-javascript>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>...</css-class-wrapper>
</portlet>

then you can use jQuery in yout jsp file


Sincerely yours
thumbnail
subhash lamba, modificado hace 10 años.

RE: use jquery in jsp portlet

Regular Member Mensajes: 136 Fecha de incorporación: 7/07/13 Mensajes recientes
Are you using spring-mvc ?
and share your log.. it's gave warning in your consol?
hadi mohammadi, modificado hace 10 años.

RE: use jquery in jsp portlet

Junior Member Mensajes: 48 Fecha de incorporación: 3/06/13 Mensajes recientes
hi.
thanks all.emoticon
below code work good
 <header-portlet-javascript>/js/jquery-1.9.1.min.js</header-portlet-javascript>
Asterios Vounotrypidis, modificado hace 9 años.

RE: use jquery in jsp portlet

New Member Mensajes: 3 Fecha de incorporación: 23/09/14 Mensajes recientes
what if I would like to do this for example:

<% if (counter == 5) { %>
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/rightel-global.css" />
<% } %>
thumbnail
Vilmos Papp, modificado hace 9 años.

RE: use jquery in jsp portlet

Liferay Master Mensajes: 529 Fecha de incorporación: 21/10/10 Mensajes recientes
Hi Asterios,

Welcome on the forum!
I have some thoughts with your comment :

1) Please do not reopen old threads with new questions. You can open new threads for your own question and it will be shown on top of the recent posts.
2) I don't see why that JSP code part is related to jQuery, please provide more details about your problem (possibly in the new thread)
3) If you want the others to take a look at a code part, try to use the code block to emphasize it like this:

&lt;% if (counter == 5) { %&gt;
<link rel="stylesheet" href="<%=request.getContextPath()%>/css/rightel-global.css">
&lt;% } %&gt;


Cheers,
Vilmos