Note that there are some explanatory texts on larger screens.

plurals
  1. POName attribute does not get rendered in Liferay Portlet
    primarykey
    data
    text
    <p>I am creating a simple Liferay Portlet and I cannot manage to get a name given in an input Box to get rendered. The main Portlet class is:</p> <pre><code>public class MyHelloWorldPortlet extends GenericPortlet { public void init() { editJSP = "/html/myhelloworldportlet/edit.jsp"; viewJSP = "/html/myhelloworldportlet/view.jsp"; } public void processAction( ActionRequest actionRequest, ActionResponse actionResponse) throws IOException, PortletException { String name = actionRequest.getParameter("name"); PortletPreferences prefs = actionRequest.getPreferences(); prefs.setValue("Name", name); prefs.store(); actionResponse.setPortletMode(PortletMode.VIEW); } public void doEdit( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { include(editJSP, renderRequest, renderResponse); } public void doView( RenderRequest renderRequest, RenderResponse renderResponse) throws IOException, PortletException { PortletPreferences prefs = renderRequest.getPreferences(); String defaultValue = ""; String name = prefs.getValue("NAME", defaultValue); renderRequest.setAttribute("ATTRIBUTE_NAME", name); include(viewJSP, 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 editJSP; protected String viewJSP; private static Log _log = LogFactoryUtil.getLog(MyHelloWorldPortlet.class); </code></pre> <p>}</p> <p>The edit.jsp file is:</p> <pre><code>&lt;form action="&lt;portlet:actionURL/&gt;" method="post" name="&lt;portlet:namespace/&gt;fm"&gt; &lt;label for="&lt;portlet:namespace/&gt;name"&gt;Name:&lt;/label&gt; &lt;input name="&lt;portlet:namespace/&gt;name" type="text"&gt; &lt;br/&gt;&lt;br/&gt; &lt;input type="submit" value="Add Name"&gt; &lt;/form&gt; </code></pre> <p>The view.jsp file is:</p> <pre><code>&lt;% String name = (String)request.getAttribute("ATTRIBUTE_NAME"); %&gt; &lt;p&gt;Hello &lt;%= name %&gt;!&lt;/p&gt; </code></pre> <p>The problem is that the output on the view is always Hello!. Not any name is passed to the output although the user enters one in the input Box. Why? </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.
 

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