Fórum

Liferay : Using Jquery code inside Liferay 6 .

Ravi Kiran, modificado 11 Anos atrás.

Liferay : Using Jquery code inside Liferay 6 .

Junior Member Postagens: 98 Data de Entrada: 12/12/11 Postagens Recentes
I am using Liferay 6 for the Application . I wanted to use , Jquery for the User Interface Part instead of default Alloy . For this i have integrated JQuery with Liferay by editing liferay-portlet.xml this way

<portlet>
<portlet-name>First</portlet-name>
<icon>/icon.png</icon>
<instanceable>true</instanceable>
<header-portlet-css>/css/main.css</header-portlet-css>
<header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js</header-portlet-javascript>
<header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.15/jquery-ui.min.js</header-portlet-javascript>
<footer-portlet-javascript>/js/main.js</footer-portlet-javascript>
<css-class-wrapper>First-portlet</css-class-wrapper>
</portlet>
This is my view.jsp

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

This is the <b>Sai Nath</b> portlet.

Now please tell me how can i put the below Jquery Hello World Alert inside the view.jsp

This is my Jquery Hello World alert program

<html>
<head>
<title>jQuery Hello World Alert box</title>

<script type="text/javascript" src="jquery-1.4.2.js"></script>

</head>
<script type="text/javascript">
$(document).ready(function(){
$("#cl").click(function(){
alert("HELLO WORLD!");
});
});
</script>
<body>
<font color="red">CLICK BELOW BUTTON TO SEE ALERT BOX</font>
<br>
<br>
<button id="cl">Click Me</button>
</body>
</html>

Please let me know , thanks for reading .
thumbnail
Tejas Kanani, modificado 11 Anos atrás.

RE: Liferay : Using Jquery code inside Liferay 6 .

Liferay Master Postagens: 654 Data de Entrada: 06/01/09 Postagens Recentes
Try this,

View.jsp

&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;

<portlet:defineobjects />

<script type="text/javascript">

$(document).ready(function(){
	$("#cl").click(function(){
		alert("HELLO WORLD!");
	});
});

</script>

<font color="red">CLICK BELOW BUTTON TO SEE ALERT BOX</font>
<br>
<br>
<button id="cl">Click Me</button>



Thanks,
TK
Ravi Kiran, modificado 11 Anos atrás.

RE: Liferay : Using Jquery code inside Liferay 6 .

Junior Member Postagens: 98 Data de Entrada: 12/12/11 Postagens Recentes
Thanks a lot , i was strugling for this . beause even a minor typo results in error of the Portlet , thanks once again .
thumbnail
Hitoshi Ozawa, modificado 11 Anos atrás.

RE: Liferay : Using Jquery code inside Liferay 6 .

Liferay Legend Postagens: 7942 Data de Entrada: 24/03/10 Postagens Recentes
Kind of wondering why you're loading jquery 1.6.2 in liferay-portal.xml
<header-portlet-javascript>https://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js</header-portlet-javascript>


while you're loading jquery 1.4.2 in your jsp.
<script type="text/javascript" src="jquery-1.4.2.js"></script>