0

I'm trying to retrieve a post value from a hook on the same page so when i value is right, content will appear.

I added this code in the hook to have it on the specified page.

<portlet:actionURL secure="<%= PropsValues.COMPANY_SECURITY_AUTH_REQUIRES_HTTPS || request.isSecure() %>" var="SecondloginURL">
     <portlet:param name="saveLastPath" value="0" />
     <portlet:param name="struts_action" value="/journal_content/view" />
</portlet:actionURL>
<aui:form action="" name="auth" method="POST">
     <aui:input label="Second Password" type="password" name="password" />
     <aui:button type="submit" value="authenticate" />
</aui:form>

I managed to retrieve the value but when it's validated session started but it doesn't move cross-pages.

Here is the code:

<% String pass = request.getParameter("password"); %>
<c:if test="<%= pass.equals(\"1234\") %>">
   <% 
       HttpSession session1 = request.getSession();
       session1.setAttribute("pass","authenticated");
       String foo = (String) session1.getAttribute("pass");
       out.println(foo);
   %>
<h2>this is the second password and it's working</h2>
   <div class="journal-content-article" id="article_<%= articleDisplay.getCompanyId() %>_<%= articleDisplay.getGroupId() %>_<%= articleDisplay.getArticleId() %>_<%= articleDisplay.getVersion() %>">
   <%= RuntimePortletUtil.processXML(application, request, response, renderRequest, renderResponse, articleDisplay.getContent()) %>
</div>
</c:if>
Haider Ghaleb
  • 83
  • 2
  • 12

1 Answers1

1

In a Liferay hook you can override stock Liferay jsps, thus also add forms.

You can also override Liferay Actions and other Liferay classes. You don't make clear where you put the above code and what else you have in your hook, neither what you are trying to achieve.

First: You should direct your form to some <portlet:actionURL/> and then, depending on the portlet this jsp is invoked from, you'll have to implement or override the action handler for that portlet. In there you'll be able to get the parameter value from the ActionRequest

Olaf Kock
  • 46,930
  • 8
  • 59
  • 90
  • Thanks @Olaf, i'm working in the portlet->journal_content->view.jsp i'm adding new condition to the rendering of the page, first when i open the specific page, i will see this form and i need to validate it with a constant value let's say "1234" when the input value is the same it will display the content. – Haider Ghaleb Sep 12 '12 at 12:23
  • @HaiderGhaleb why not put the additional information inside the question itself, so that it will have more visibility for others who wish to help you. Thanks – Prakash K Sep 12 '12 at 13:56
  • @prakash-k i will edit my post now as i already solved part of the issue so it will contain more concrete info with code example – Haider Ghaleb Sep 12 '12 at 14:35