Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>Other codes also use new PortletURLImpl() directly. My portlet cannot see that class.</p> </blockquote> <p>Because this class is in <code>portal-impl.jar</code> and also it is not recommended to use classes from this jar. Starting from Liferay 6.1, you won't be able to build your portlet from plugins-sdk if you classes point to <code>portal-impl.jar</code>.</p> <p>Now to answer your question:</p> <p>Any jsp is rendered by the <code>render</code> method or <a href="http://docs.liferay.com/portal/6.1/javadocs-all/com/liferay/util/bridges/mvc/MVCPortlet.html#doView%28javax.portlet.RenderRequest,%20javax.portlet.RenderResponse%29" rel="nofollow" title="Liferay 6.1 API: MVCPortlet#doView"><code>doView</code></a> method (if using liferay's <a href="https://github.com/liferay/liferay-portal/blob/6.1.x/util-bridges/src/com/liferay/util/bridges/mvc/MVCPortlet.java" rel="nofollow" title="MVCPortlet source code on github"><code>MVCPortlet</code></a>) and this method would be called as part of the normal life-cycle of portlets.</p> <p>Here are the steps you would need to take:</p> <ol> <li><p>set a render parameter (using <a href="http://www.bluesunrise.com/portlet-api/javax/portlet/StateAwareResponse.html#setRenderParameter%28java.lang.String,%20java.lang.String%29" rel="nofollow" title="Portlet 2.0 API: ActionResponse#setRenderParameter">response.setRenderParameter()</a> method) in your `processAction' method at the last which would be available in your render method, as follows:</p> <pre><code>actionResponse.setRenderParameter("myID", 1201); </code></pre> <p><sub><strong>Just for info:</strong> After using <code>setRenderParameter</code> you cannot use <a href="http://portals.apache.org/pluto/portlet-2.0-apidocs/javax/portlet/ActionResponse.html#sendRedirect%28java.lang.String%29" rel="nofollow" title="Portlet 2.0 API: documentation explaining not to use sendRedirect"><code>sendRedirect</code></a> method</sub></p></li> <li><p>fetch this <code>"myID"</code> in your render method as you fetch any other request parameter:</p> <pre><code>//assuming your ID is a long long myUserName = ParamUtil.getLong(renderRequest, "myID"); </code></pre> <p>or</p> <pre><code>String strMyID = renderRequest.getParameter("myID"); long myID = Long.parseLong(strMyID); </code></pre></li> <li><p>After this, just use</p> <pre><code>include(renderPage, renderRequest, renderResponse); </code></pre> <p>were <code>renderPage</code> is nothing but a string containing the path to your jsp within <code>docroot</code> like <code>/html/yourportlet/view.jsp</code></p> <p><sub><strong>Just as an afterthought:</strong><br> If you are using a Liferay IDE, then you can try creating a simple portlet project with <code>MVCPortlet</code> and then look at the generated <code>portlet.xml</code>'s <code>&lt;init-param&gt;</code></sub></p></li> </ol> <p>So basically you need to pass information from action-phase to render-phase, the <a href="http://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/passing-information-from-the-action-phase-to-the-render-pha-4" rel="nofollow">development guide</a> is a good place for explaining this in detail.</p> <p>That's it.<br> Hope this helps.</p> <p>Let me know if you have any confusion regarding this.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload