Skip to content
This repository has been archived by the owner on Apr 8, 2019. It is now read-only.

Commit

Permalink
Make gatein-jquery example portlet work with requirejs
Browse files Browse the repository at this point in the history
  • Loading branch information
phuong_vu authored and trongtt committed Aug 23, 2012
1 parent a6286e1 commit 1789ff2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
Expand Up @@ -34,10 +34,6 @@ public class JQueryPortlet extends GenericPortlet
@Override
public void render(RenderRequest request, RenderResponse response) throws PortletException, IOException
{
//Two lines of code below ensure that ON-LOAD resources jquery is available in the rendering phase
//We need this as the JQueryPortlet resource does not declare dependency on jquery resource
response.addProperty("org.gatein.javascript.dependency", "jquery");

String view = request.getParameter("view");
if(view == null || !view.endsWith(".jsp"))
{
Expand Down
Expand Up @@ -26,25 +26,28 @@
xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_2_1">


<module>
<scripts>
<name>jquery-1.6.4</name>
<script>
<name>jquery-1.6.4</name>
<path>/javascript/jquery-1.6.4.js</path>
</script>
</module>
</scripts>

<portlet>
<name>JQueryPortlet</name>
<module>
<scripts>
<script>
<name>version</name>
<path>/javascript/version.js</path>
</script>
<depends>
<module>jquery-1.6.4</module>
<scripts>jquery-1.6.4</scripts>
</depends>
</module>
<depends>
<scripts>bootstrap</scripts>
</depends>
</scripts>
</portlet>

</gatein-resources>
Expand Down
24 changes: 12 additions & 12 deletions examples/portlets/jquery/src/main/webapp/javascript/version.js
@@ -1,15 +1,15 @@
$(".version").remove();

$("#portletJQuery").click(function()
{
var target = $(this);
$('#result').append("<p>The JQuery's version: " + $().jquery + "</p>");
$('#result').children('p').fadeOut(3200);
$(function() {
$("#portletJQuery").click(function() {
$('#result').append("<p>The JQuery's version: " + $().jquery + "</p>");
$('#result').children('p').fadeOut(3200);
});
});

$("#gateinJQuery").click(function()
require(["SHARED/jquery"], function($)
{
var target = $(this);
gj('#result').append("<p>The JQuery's version: " + gj().jquery + "</p>");
gj('#result').children('p').fadeOut(3200);
});
$("#gateinJQuery").click(function()
{
$('#result').append("<p>The JQuery's version: " + $().jquery + "</p>");
$('#result').children('p').fadeOut(3200);
});
});
8 changes: 5 additions & 3 deletions examples/portlets/jquery/src/main/webapp/jsp/views/index.jsp
@@ -1,4 +1,4 @@
<div style=" width: 98,5%; height: 210px; overflow: hidden;">
<div style=" width: 98,5%; height: 253px; overflow: hidden;">
<div style="float: left; width: 70%">
<ul>
<li>
Expand All @@ -9,8 +9,10 @@
</li>
<li>
<p style="color: blue">Get information on GateIn 's own JQuery use:</p>
<pre>gj('#result').append("&lt;p&gt;The JQuery's version: " + gj().jquery + "&lt;/p&gt;");</pre>
<pre>gj('#result').children('p').fadeOut(3200);</pre>
<pre>require(["SHARED/jquery"], function($) {</pre>
<pre> $('#result').append("&lt;p&gt;The JQuery's version: " + $().jquery + "&lt;/p&gt;");</pre>
<pre> $('#result').children('p').fadeOut(3200);</pre>
<pre>});</pre>
<div id="gateinJQuery"><span style="color:green">Click here</span></div>
</li>
</ul>
Expand Down

0 comments on commit 1789ff2

Please sign in to comment.