Creating ActionURL and RenderURL


 Render URL Creation :  
 To navigate from one page to another page in liferay we use render URL.  
 1.Create the render url:  
 2.Specify to which page you want to navigate when you click on the hyper link.  
 <portlet:renderURL var="sampleRenderURL">  
   <portlet:param name="jspPage" value="/html/library/sample.jsp"/>  
 </portlet:renderURL>  
 3.Use the render URL :  
 <aui:a href="<%=sampleRenderUR%>">this is the hyper link</aui:a>  
 Creating Action URL:  
 If we want to send some data to the server we use action URL.  
 1.Create Action URL  
 <%  
 PortletURL updateBookURL = renderResponse.createActionURL();  
 updateBookURL.setParameter(ActionRequest.ACTION_NAME, "updateBook");  
 %>  
 2. Use the Action URL (updateBookURL) in the action attribute of the form.   
 <aui:form name="fm" method="POST" action="<%= updateBookURL.toString() %>">  
   <aui:input name="bookTitle" label="Book Title" />  
   <aui:input name="author" />  
   <aui:button type="submit" value="Save" />  
 </aui:form>  
 3. In the portlet class we have to create a method with the name "updateBook".  
   public class LibraryPortlet extends MVCPortlet {  
   public void updateBook(ActionRequest req, ActionResponse res)  
   {  
     String str= req.getParameter("bookTitle");  
     System.out.println(str);  
     String st1=req.getParameter("author");  
     System.out.println(st1);  
   }  
   }  

Search This Blog

All the rights are reserved to this blog is belongs to me only.. Powered by Blogger.