1
votes

To begin, I am very new to Liferay, and may not have a clue what I'm doing even after reading the docs.

I'm trying to set up a custom jsp page inside of a Liferay portlet. The structure of my jsp is as follows:

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

<portlet:defineObjects />

<html>
       <head>
          <title>Credit Overview</title>
          <link rel="stylesheet" type="text/css" href="../Client/css/creditview.css" />
          <link rel="stylesheet" type="text/css" href="../Client/css/ecrisPortal_styles.css" />
           //rest of css links and javascript files...
       </head>
       <body>
          //lists, divs, etc.
       </body>

</html>

This is all placed into my portlets view.jsp file, however, I cannot see anything being displayed in my portlet. All of my sources and mapping are correct but it seems I can't display anything but regular text in my portlet.

I'm using the most-current versions of Liferay plugins SDK and Eclipse.

Any ideas?

Cheers!

2
Portlet HTML should not contain <html>, <body> and <head> elements. These elements are placed by Liferay portal. It's sufficient to start with <div> element in yout portlet HTML.milos.zikmund
Can you share the code of the doView method of your portlet?Nick Roth
doView? I don't have any of the sortKurai Bankusu
Would you mind pasting your mappings in liferay-portlet.xml and portlet.xml. Thanks.Prakash K
Have you modified the portlet-class in portlet.xml? If so, you may need to call super.render(renderRequest, renderResponse); in your class's render method.Graham P Heath

2 Answers

0
votes

First of all you do not need to use html, body and head tags.

To include title, have it under portlet.xml file. Like this:

<portlet>
    <portlet-name>yourportletname</portlet-name>
    <portlet-class>org.springframework.web.portlet.DispatcherPortlet</portlet-class>
    <supports>
        <mime-type>text/html</mime-type>
    </supports>
    <portlet-info>
        <title>Your Fancy Portlet Title</title>
    </portlet-info>
</portlet>

To include CSS or script files, have them under liferay-portal.xml file. Like this:

<portlet>
    <portlet-name>yourportletname</portlet-name>
    <header-portlet-css>/css/cssfilename.css</header-portlet-css>
    <header-portlet-javascript>/js/yourfancyscript.js</header-portlet-javascript>
    <header-portlet-javascript>/js/libs/jquery.min.js</header-portlet-javascript>
</portlet>

Also, we do not have enough information. Is your basic text shown, this means no 404 error page?

0
votes

hi you should place only content inside body tag in your portlet , , should not be place because when rendered by the portal your portlet is wrapped inside a of the portal pages before displaying.

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
//lists, divs, etc.

include css using <header-portlet-css> and include script using <footer-portlet-javascript> after <icon> in liferay-portlet.xml deployment descriptor. here is an example

<portlet>
        <portlet-name>ipc-session-a</portlet-name>
        <icon>/icon.png</icon>
        <header-portlet-css>/css/main.css</header-portlet-css>
        <footer-portlet-javascript>
            /js/main.js
        </footer-portlet-javascript>
        <css-class-wrapper>your-css-class-wrapper</css-class-wrapper>
    </portlet>