Fórum

Urgent: even the most basic example of renderURL is not working.

Pablo Yuste Soto, modificado 6 Anos atrás.

Urgent: even the most basic example of renderURL is not working.

New Member Postagens: 14 Data de Entrada: 03/10/17 Postagens Recentes
Example from Liferay's tutorials:

File "init.jsp":
    <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

    <%@ taglib uri="http://liferay.com/tld/aui" prefix="aui" %>
    <%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet" %>
    <%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme" %>
    <%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

    <portlet:defineobjects />
    <liferay-theme:defineobjects />


File "view.jsp":
&lt;%@include file="init.jsp" %&gt;
    
<portlet:renderurl var="addEntryURL">
    <portlet:param name="mvcPath" value="/add_entry.jsp"></portlet:param>
</portlet:renderurl>

<aui:button-row>
    <aui:button onclick="<%= addEntryURL.toString() %>" value="Add Entry"></aui:button>
</aui:button-row>


File "add_entry.jsp":
&lt;%@ include file="init.jsp" %&gt;

Test portlet


All these files are in the same folder, yet I can't get this working. If I click the button, nothing happens. I tried everything: reinstalling the server, using a different portlet superclass, using module portlets (this one is a plugin portlet), etc. Just NOTHING works. It's completely broken and I've got no clue on what's going on.

No errors on eclipse console, though I'm getting this single error in the client (chrome) when clicking the button:

VM266 guest:2 Uncaught SyntaxError: Unexpected token }


I really need to get this fixed. I also can't get any actionURL working: if I put a decorator stating that a method is enabled to perform an action, Liferay just doesn't find it. I could do both things just a few days ago, WHY can't I do them now? This is stressing me out a lot, I just don't understand how a widely used tool like Liferay can bug itself this hard.

Anybody knows why this happens?

Thank you...
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Kiko,

Can you also show us your Portlet class? Maybe attach your project to this message so I can try it out on my local?
Kiko López, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

New Member Postagens: 14 Data de Entrada: 03/10/17 Postagens Recentes
Sure, this is my portlet class. It's tottally untouched:

package com.test;

import java.io.IOException;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;

/**
 * Portlet implementation class PortletPrueba
 */
public class PortletPrueba extends GenericPortlet {

    public void init() {
        viewTemplate = getInitParameter("view-template");
    }

    public void doView(
            RenderRequest renderRequest, RenderResponse renderResponse)
        throws IOException, PortletException {

        include(viewTemplate, renderRequest, renderResponse);
    }

    protected void include(
            String path, RenderRequest renderRequest,
            RenderResponse renderResponse)
        throws IOException, PortletException {

        PortletRequestDispatcher portletRequestDispatcher =
            getPortletContext().getRequestDispatcher(path);

        if (portletRequestDispatcher == null) {
            _log.error(path + " is not a valid include");
        }
        else {
            portletRequestDispatcher.include(renderRequest, renderResponse);
        }
    }
 
    protected String viewTemplate;

    private static Log _log = LogFactoryUtil.getLog(PortletPrueba.class);

}


Thank you!
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
I am assuming from your portlet that this is a 6.2 project? If possible, can you wrap up the project and attach it here so that I can try it locally? That might be the shortest path to a solution here.
thumbnail
Savvas Yiannopoulos, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

New Member Postagens: 18 Data de Entrada: 16/11/17 Postagens Recentes
Hey Andrew,

I have the same problem as the first post here, stated 7 years ago.

I followed the steps on the tutorial and as it says I should be able on that point to see this form when I click the addEntry button, but nothing happens.

Here are my classes:
view.jsp
&lt;%@ include file="/init.jsp" %&gt;

<!-- System-generated URLs -->
<portlet:renderurl var="addEntryURL">
    <portlet:param name="mvcPath" value="/edit_entry.jsp"></portlet:param>
</portlet:renderurl>

<aui:button-row>
    <aui:button onclick="<%=addEntryURL.toString()%>" value="Add Entry"></aui:button>
</aui:button-row>


edit_entry.jsp
&lt;%@ include file="/init.jsp" %&gt;

<portlet:renderurl var="viewURL">
    <portlet:param name="mvcPath" value="/view.jsp"></portlet:param>
</portlet:renderurl>

<portlet:actionurl name="addEntry" var="addEntryURL"></portlet:actionurl>

<aui:form action="<%=addEntryURL%>" name="<portlet:namespace />fm">
        <aui:fieldset>
            <aui:input name="name"></aui:input>
            <aui:input name="message"></aui:input>
        </aui:fieldset>

        <aui:button-row>
            <aui:button type="submit"></aui:button>
            <aui:button type="cancel" onclick="<%= viewURL.toString() %>"></aui:button>
        </aui:button-row>
</aui:form>


init.jsp
&lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;

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

&lt;%@ taglib uri="http://liferay.com/tld/aui" prefix="aui"%&gt;
&lt;%@ taglib uri="http://liferay.com/tld/portlet" prefix="liferay-portlet"%&gt;
&lt;%@ taglib uri="http://liferay.com/tld/theme" prefix="liferay-theme"%&gt;
&lt;%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui"%&gt;

<liferay-theme:defineobjects />

<portlet:defineobjects />


Can you please help me?

Thank you in advance,
Savvas
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hi Savvas,

First thing that I would suggest is adjusting your var values on your portlet urls. It might not make any difference, but for semantics I would still consider it. The convention I use is to to post fix the var with the url type... so addEntryRenderURL for the render url and addEntryActionURL for the other one.

Outside of that, not sure. Can you share your java class that is backing this portlet as well?
thumbnail
Savvas Yiannopoulos, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

New Member Postagens: 18 Data de Entrada: 16/11/17 Postagens Recentes
Hey Andrew,

thank you for your response.
First thing that I would suggest is adjusting your var values on your portlet urls.

I am not sure if I understand what you mean by adjusting the values on my portlet urls. :/
... so addEntryRenderURL for the render url and addEntryActionURL for the other one

So something like this:
view.jsp
&lt;%@include file="/init.jsp"%&gt;

<!-- System-generated URLs -->
<portlet:renderurl var="addEntryRenderURL">
	<portlet:param name="mvcPath" value="/edit_entry.jsp" />
</portlet:renderurl>

<aui:button-row>
    <aui:button onclick="<%=addEntryRenderURL.toString()%>" value="Add Entry"></aui:button>
</aui:button-row>


edit_entry.jsp
&lt;%@ include file="/init.jsp" %&gt;

<portlet:renderurl var="viewRenderURL">
	<portlet:param name="mvcPath" value="/view.jsp"></portlet:param>
</portlet:renderurl>

<portlet:actionurl name="addEntry" var="addEntryActionURL"></portlet:actionurl>
 
<aui:form action="<%=addEntryURL%>" name="<portlet:namespace />fm">
	<aui:fieldset>
		<aui:input name="name"></aui:input>
		<aui:input name="message"></aui:input>
	</aui:fieldset>

	<aui:button-row>
		<aui:button type="submit"></aui:button>
		<aui:button type="cancel" onclick="<%= viewURL.toString() %>"></aui:button>
	</aui:button-row>
</aui:form>


Can you share your java class that is backing this portlet as well?

You can find the whole project here

Some more information on the problem:
OS: Linux Mint 18.2 Sonya
Eclipse: Eclipse Java EE IDE for Web Developers. Version: Luna Service Release 2 (4.4.2)
Liferay: Liferay IDE 3.1.2.201709011126-ga3, Liferay GA4 (I also tried GA5)

I know for sure, that on other machines with the same OS/programs/versions it worked just fine. I do not understand why it won't work on my laptop.

Thank you in advance.
thumbnail
Andrew Jardine, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Hey Savvas,

Sorry -- I haven't had a chance to look at this yet, but I have just downloaded your project and will have a look this morning.
thumbnail
Savvas Yiannopoulos, modificado 6 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

New Member Postagens: 18 Data de Entrada: 16/11/17 Postagens Recentes
Hey Andrew,

thank you so much! That will be amazing emoticon
John Andaya, modificado 5 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

New Member Postagens: 6 Data de Entrada: 15/03/19 Postagens Recentes
RE: Urgent: even the most basic example of renderURL is not working.
thumbnail
Andrew Jardine, modificado 5 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
I've never had any problems with render, action or resource URLs and I have, literally, builtn100s in 7.1.

​​​​​​​What is your system config? Are you able to share your project for me to try?
John Andaya, modificado 5 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

New Member Postagens: 6 Data de Entrada: 15/03/19 Postagens Recentes
Thanks Andrew, I figured it out.
thumbnail
Andrew Jardine, modificado 5 Anos atrás.

RE: Urgent: even the most basic example of renderURL is not working.

Liferay Legend Postagens: 2416 Data de Entrada: 22/12/10 Postagens Recentes
Glad to hear it! What was the issue (in case someone else comes along and sees this thread and has the same issue...)