Skip to content

Instantly share code, notes, and snippets.

@psvehla
Created October 4, 2012 00:04
Show Gist options
  • Select an option

  • Save psvehla/3830682 to your computer and use it in GitHub Desktop.

Select an option

Save psvehla/3830682 to your computer and use it in GitHub Desktop.

Revisions

  1. psvehla created this gist Oct 4, 2012.
    60 changes: 60 additions & 0 deletions liferayContent.jsp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,60 @@
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

    <script type="text/javascript" src="/html/js/liferay/service.js"> </script>

    <script type="text/javascript">
    function unEscapeHTML(html) {
    return html.replace(/\&amp;/g, '&').replace(/\&lt;/g, '<').replace(/\&gt;/g, '>');
    }
    function getJournalArticle(articleId, target) {
    $.ajax({
    type: 'GET',
    url: "/api/jsonws/journalarticle/get-article?groupId=10180&articleId=" + articleId,
    dataType: "json",
    success: function(data, textStatus, jqXHR) {
    $(target).html(unEscapeHTML(data.content));
    },
    error: function(jqXHR, textStatus, errorThrown) {
    alert("Error calling count service: " + textStatus + " : " + errorThrown);
    }
    });
    }
    // we will add our javascript code here
    $(document).ready(function() {
    // do stuff when DOM is ready
    getJournalArticle(12601, 'div.dynamic-content');
    getJournalArticle(12611, "#on-demand-content");
    $("#on-demand-content").hide();
    $("#details").click(function() {
    if($("#details").text() == 'More Details') {
    $("#details").text('Less Details');
    $("#on-demand-content").show();
    }
    else {
    $("#details").text('More Details');
    $("#on-demand-content").hide();
    }
    });
    });
    </script>

    <p>
    <h1>Liferay Content</h1>

    <h2>Server Gets Content</h2>
    <liferay-ui:journal-article groupId="10180" articleId="11001" />

    <h2>Client Gets Content</h2>
    <div class='dynamic-content'></div>

    <h2>Client Gets Content When Needed</h2>
    <a id='details'>More Details</a>
    <div id='on-demand-content'></div>
    </p>

    <p>The time on the server is ${serverTime}.</p>