From 1789ff275b122befcb786c13b32d9bbd66c3be56 Mon Sep 17 00:00:00 2001 From: phuong_vu Date: Mon, 30 Jul 2012 14:36:10 +0700 Subject: [PATCH] Make gatein-jquery example portlet work with requirejs --- .../portal/samples/jquery/JQueryPortlet.java | 4 ---- .../main/webapp/WEB-INF/gatein-resources.xml | 13 ++++++---- .../src/main/webapp/javascript/version.js | 24 +++++++++---------- .../src/main/webapp/jsp/views/index.jsp | 8 ++++--- 4 files changed, 25 insertions(+), 24 deletions(-) diff --git a/examples/portlets/jquery/src/main/java/org/gatein/portal/samples/jquery/JQueryPortlet.java b/examples/portlets/jquery/src/main/java/org/gatein/portal/samples/jquery/JQueryPortlet.java index b14de6f5a..f72b24506 100644 --- a/examples/portlets/jquery/src/main/java/org/gatein/portal/samples/jquery/JQueryPortlet.java +++ b/examples/portlets/jquery/src/main/java/org/gatein/portal/samples/jquery/JQueryPortlet.java @@ -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")) { diff --git a/examples/portlets/jquery/src/main/webapp/WEB-INF/gatein-resources.xml b/examples/portlets/jquery/src/main/webapp/WEB-INF/gatein-resources.xml index 3e582ada7..9d28a8252 100644 --- a/examples/portlets/jquery/src/main/webapp/WEB-INF/gatein-resources.xml +++ b/examples/portlets/jquery/src/main/webapp/WEB-INF/gatein-resources.xml @@ -26,25 +26,28 @@ xmlns="http://www.gatein.org/xml/ns/gatein_resources_1_2_1"> - + jquery-1.6.4 - + JQueryPortlet - + - jquery-1.6.4 + jquery-1.6.4 - + + bootstrap + + diff --git a/examples/portlets/jquery/src/main/webapp/javascript/version.js b/examples/portlets/jquery/src/main/webapp/javascript/version.js index 35ec0b0b9..8e4731a30 100644 --- a/examples/portlets/jquery/src/main/webapp/javascript/version.js +++ b/examples/portlets/jquery/src/main/webapp/javascript/version.js @@ -1,15 +1,15 @@ -$(".version").remove(); - -$("#portletJQuery").click(function() -{ - var target = $(this); - $('#result').append("

The JQuery's version: " + $().jquery + "

"); - $('#result').children('p').fadeOut(3200); +$(function() { + $("#portletJQuery").click(function() { + $('#result').append("

The JQuery's version: " + $().jquery + "

"); + $('#result').children('p').fadeOut(3200); + }); }); -$("#gateinJQuery").click(function() +require(["SHARED/jquery"], function($) { - var target = $(this); - gj('#result').append("

The JQuery's version: " + gj().jquery + "

"); - gj('#result').children('p').fadeOut(3200); -}); + $("#gateinJQuery").click(function() + { + $('#result').append("

The JQuery's version: " + $().jquery + "

"); + $('#result').children('p').fadeOut(3200); + }); +}); \ No newline at end of file diff --git a/examples/portlets/jquery/src/main/webapp/jsp/views/index.jsp b/examples/portlets/jquery/src/main/webapp/jsp/views/index.jsp index 9a426d733..9f54c1ac1 100644 --- a/examples/portlets/jquery/src/main/webapp/jsp/views/index.jsp +++ b/examples/portlets/jquery/src/main/webapp/jsp/views/index.jsp @@ -1,4 +1,4 @@ -
+
  • @@ -9,8 +9,10 @@
  • Get information on GateIn 's own JQuery use:

    -
    gj('#result').append("<p>The JQuery's version: " + gj().jquery + "</p>");
    -
    gj('#result').children('p').fadeOut(3200);
    +
    require(["SHARED/jquery"], function($) {
    +
      $('#result').append("<p>The JQuery's version: " + $().jquery + "</p>");
    +
      $('#result').children('p').fadeOut(3200);
    +
    });
    Click here