Foren

actionURL and renderURL

thumbnail
Adi florescu, geändert vor 12 Jahren.

actionURL and renderURL

New Member Beiträge: 19 Beitrittsdatum: 23.09.11 Neueste Beiträge
Hello Liferay community!

I have a question witch seems simple enough, but I can figure out how to do solve it.

So, in a simple Hello World portlet I define an renderURL witch takes me to another page. Then I click on an actionURL, and boom, I'm back to the Hello World portlet, but I wanted to stay on the page with the action URL. How can I do that?

Here is the code for view.jsp:
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineobjects />

<h3>Working with actionURL and renderURL</h3>
<portlet:renderurl var="somePage">
  <portlet:param name="jspPage" value="/afl/urls/action.jsp"></portlet:param>
</portlet:renderurl>
<a href="<%= somePage %>">Click here for action.jsp page created with renderURL.</a>

And this is action.jsp:
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;
<portlet:defineobjects />
<a href="<portlet:actionURL />">Click for an action that does nothing!</a>


Here is how everything looks like:
fred herrmann, geändert vor 12 Jahren.

RE: actionURL and renderURL

New Member Beiträge: 11 Beitrittsdatum: 04.03.11 Neueste Beiträge
I'm pretty new to this, but I'll give it a shot...

I think you just need to add the param for jspPage as you did in the render URL if you don't want to implement a method to handle the action request. The way you have it defined, the flow will fall through to the default render method, which will direct you to the view-jsp defined in the portlet.xml. In this case, that's the view.jsp which is why you keep ending up there.

You could define a method to handle the action request (you'll have to give the action URL a name that matches the method name) and in it set a render parameter of jspPage with the value of the action.jsp you are trying to stay on, which should also work.
thumbnail
Adi florescu, geändert vor 12 Jahren.

RE: actionURL and renderURL

New Member Beiträge: 19 Beitrittsdatum: 23.09.11 Neueste Beiträge
Thank you! It worked as a combination of the two advices.

So yes, I did modify my portlet.xml file so it looks like this (only a fragment displayed):
  <portlet>
    <portlet-name>afl-urls</portlet-name>
    <display-name></display-name>
     <portlet-class>afl.URLs</portlet-class>
    <init-param>
      <name>view-jsp</name>
      <value>/afl/urls/view.jsp</value>
    </init-param>
    <init-param>
      <name>copy-request-parameters</name>
      <value>true</value>
    </init-param>   ...</portlet>

And then I also modified action.jsp so it looks like this:
&lt;%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %&gt;
<portlet:defineobjects />
<portlet:actionurl var="goAndDoSth">
  <portlet:param name="jspPage" value="/afl/urls/action.jsp"></portlet:param>
</portlet:actionurl>
<a href="<%= goAndDoSth %>">Click for an action that does nothing!</a>

And here is my class is:
public class URLs extends MVCPortlet
{ 
  @Override
  public void processAction(ActionRequest request, ActionResponse response) 
  throws PortletException, IOException
  {
    System.out.println("Well I'm doing sth...");
    super.processAction(request, response); //very important to have this here
  }
}

Now, if I may, I'd like to ask where can I get the reference documentation for let's say portlet:param in the jsp files, and for the init-param in the portlet.xml file. I really need more description, and the one found at http://docs.liferay.com/portal/6.0/ doesn't help that much.
thumbnail
jelmer kuperus, geändert vor 12 Jahren.

RE: actionURL and renderURL

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
the portlet:param is part of the portlet spec So you could download the spec

http://jcp.org/aboutJava/communityprocess/final/jsr286/index.html

Or get a book http://www.manning.com/sarin/

There's a lot of information on the web about portlets. Liferay's internal api's however are a different matter all together and you are mostly on your own with that
thumbnail
Adi florescu, geändert vor 12 Jahren.

RE: actionURL and renderURL

New Member Beiträge: 19 Beitrittsdatum: 23.09.11 Neueste Beiträge
Thank you Jelmer!

I have the portal specification but perhaps I'm not looking in the right place for the taglib description. The documentation there is the same posted on the liferay website at: http://docs.liferay.com/portlet-api/2.0/javadocs/ but it has only the classes description.For the portlet:param thing all I could find is this.

There's also something in the pdf document, but I'm not sure if it has everything, and it's structured differently.
thumbnail
jelmer kuperus, geändert vor 12 Jahren.

RE: actionURL and renderURL

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
Well the pdf document is what what people building jsr286 portals (like liferay) base their implementation on. Absolutely everything there is to know about portlets should be in there. Section PLT.26.6 param Tag describes the param tag
thumbnail
jelmer kuperus, geändert vor 12 Jahren.

RE: actionURL and renderURL

Liferay Legend Beiträge: 1191 Beitrittsdatum: 10.03.10 Neueste Beiträge
Try setting

        <init-param>
            <name>copy-request-parameters</name>
            <value>true</value>
        </init-param>


in your portlet.xml, if you extend from MvcPortlet that is