Laliwala IT Services

Laliwala IT Services
Website Development

Tuesday, February 22, 2011

navigating between the tabs in a portlet, portle url, page import, java sun, string tabs, google liferay, liferay seo, portal deploy, liferay web

Guduri Venu Gopal : I created a portlet using liferay plugins sdk 5.2.3 and I am using the liferay version 5.2.3.










In my portlet I am able to display 3 tabs for that I created 3 jsp's in parallel to my view .jsp those are








sample_tab_1.jsp

sample_tab_2.jsp

sample_tab_3.jsp








view.jsp


---------------------------------








<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@ page import="javax.portlet.PortletURL" %>

<%@ page import="javax.portlet.ResourceURL" %>

<%@ page import="javax.portlet.WindowState" %>

<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<%








String tabs1 = ParamUtil.getString(request, "tabs1", "Sample Tab 1");

PortletURL portletURL = renderResponse.createRenderURL();

portletURL.setWindowState(WindowState.NORMAL);

portletURL.setParameter("tabs1", tabs1);

String tabNames = "Sample Tab 1,Sample Tab 2,Sample Tab 3";

%>





<liferay-ui:tabs names="<%= tabNames %>" url="<%= portletURL.toString() %>" refresh="<%= false %>"

/>

<c:if test='<%= tabs1.equals("Sample Tab 1") %>'>

<liferay-util:include page="/sample_tab_1.jsp" > //This jsp is created in parallel to view.jsp,is this the right way to access the jsp

</c:if>

<c:if test='<%= tabs1.equals("Sample Tab 2") %>'>

<liferay-util:include page="/sample_tab_2.jsp" > //This jsp is created in parallel to view.jsp,is this the right way to access the jsp

</c:if>

<c:if test='<%= tabs1.equals("Sample Tab 3") %>'>

<liferay-util:include page="/sample_tab_3.jsp" > //This jsp is created in parallel to view.jsp,is this the right way to access the jsp

</c:if>



sample_tab_1.jsp

----------------------------------------------------

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>



<portlet:defineObjects />





<H6>Tab1................</H6>



sample_tab_2.jsp

----------------------------------------------------

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>



<portlet:defineObjects />





<H6>Tab2................</H6>



sample_tab_3.jsp

----------------------------------------------------

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>



<portlet:defineObjects />





<H6>Tab3................</H6>





can any one plz help me on this..






Attachments:






Sam w : have you searched for liferay tabs wiki?








http://www.google.com.au/search?client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&channel=s&hl=en&source=hp&q=liferay+tabs+wiki&meta=&btnG=Google+Search






Guduri Venu Gopal : Thanks Sam for ur reply,

I had followed that but I am facing this problem because I am using liferay sdk plugin for developing portlets and I am also not using any framework just simple jsp's.








can u pls help me in solving the issue of navigation.






Mazhar Anwar : Can you directly include the jsp as follow?








<%@ include file="/blog.jsp" %>








since its working for me. It might be the problem with spaces in your jsp names. Can you remove it and give a try emoticon









Regards,

Mazhar






Guduri Venu Gopal : Hi Mazhar thanks once again,





Now I am able to display the jsp pages.





but the problem is it is displaying all the jsp's irrespective of the tab in my case if i click on








sample tab1

-----------

tab1 //should be displayed











but now it is showing if i click any tab it is showing








tab1

tab2

tab3








In order to use c: any imports are required?






Mazhar Anwar : might be emoticon








you can try with adding <%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>in your jsp and

<taglib>

<taglib-uri>http://java.sun.com/jstl/core_rt</taglib-uri>

<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>

</taglib>








in web.xml. and add c-rt.tld in tld folder of your portlet.






Guduri Venu Gopal : Hi Mazhar,

In my view.jsp I included the line





<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>








I added the following in web.xml file of my portlet








<taglib>

<taglib-uri>http://java.sun.com/jstl/core_rt</taglib-uri>

<taglib-location>/WEB-INF/tld/c-rt.tld</taglib-location>

</taglib>

and I added the c-rt.tld file which is 11kb in my tld folder.








In the console Iam getting an error:

java.lang.ClassNotFoundException:org.apache.taglibs.standard.tlv.JstlCoreTLV






Pascal Wasem : Maybe this helps you:








Remember current tab






Mazhar Anwar : Please copy and paste jstl.jar and jstl-impl.jar from ext or portal source to WEB-INF/lib folder and deploy the portlet again.








emoticon

Regards,

Mazhar






Guduri Venu Gopal : Thanks Mazhar,





Finally I am able to navigate between the tabs correctly.Thanks a lot for ur help.






Guduri Venu Gopal : Hi Mazhar,

If I want to use <liferay-util:include page="/sample_tab_1.jsp" >

then I should include the below line right?

<%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %>








and any other changes because it is working when iam using








<%@ include file="/blog.jsp" %>








If I am using <liferay-util:include page="/sample_tab_1.jsp" > it's cretaing some problem any changes in web.xml and some other files I have to do?






Mazhar Anwar :
Do you get any exception when adding <%@ taglib uri="http://liferay.com/tld/util" prefix="liferay-util" %> ?






Guduri Venu Gopal : I am using Liferay Plugins SDK 5.2.3 and liferay 5.2.3





I had developed a simple jsp portlet with tabs. I am facing some issues in submitting different forms in different tabs.








view.jsp

-------------------------------------------





<%@ taglib uri="http://liferay.com/tld/ui" prefix="liferay-ui" %>

<%@ page import="javax.portlet.PortletURL" %>

<%@ page import="javax.portlet.ResourceURL" %>

<%@ page import="javax.portlet.WindowState" %>

<%@ page import="com.liferay.portal.kernel.util.ParamUtil" %>

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>

<portlet:defineObjects />

<%

String tabs1 = ParamUtil.getString(request, "tabs1", "Sample Tab 1");

PortletURL portletURL = renderResponse.createRenderURL();

System.out.println("*******************@@@@@@@@@@@@@@@@" + tabs1 + "**************@@@@@@@@@@@@@");

portletURL.setWindowState(WindowState.NORMAL);

portletURL.setParameter("tabs1", tabs1);

String tabNames = "Sample Tab 1,Sample Tab 2,Sample Tab 3";

%>

<liferay-ui:tabs names="<%= tabNames %>" url="<%= portletURL.toString() %>" >

<c:if test='<%= tabs1.equals("Sample Tab 1") %>'>

<%@ include file="/sample_tab_1.jsp" %>

</c:if>

<c:if test='<%= tabs1.equals("Sample Tab 2") %>'>

<%@ include file="/sample_tab_2.jsp" %>

</c:if>

<c:if test='<%= tabs1.equals("Sample Tab 3") %>'>

<%@ include file="/sample_tab_3.jsp" %>

</c:if>

</liferay-ui:tabs>



sample_tab_1.jsp

----------------------------

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%@ page import="javax.portlet.*"%>

<%@ page import="com.example.customer.service.*"%>

<%@ page import="com.example.customer.model.*"%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>





<portlet:defineObjects />











<table>

<form method="POST" action="<portlet:actionURL/>">



<tr>

<td>Customer ID:</td>

<td><Input type="text" name="id"/></td>

</tr>

<tr>

<td>Name:</td>

<td><Input type="text" name="name"/></td>

</tr>

<tr>

<td>Age:</td>

<td><Input type="text" name="age"/></td>

</tr>

<tr>

<td><Input type="submit"/></td>

</tr>

</form>

</table>

<H3> No of Customers in Database :

<%

out.println(CustomerDtlsLocalServiceUtil.getCustomerDtlsesCount());

%>

</H3>





sample_tab_2.jsp

------------------------------------

<%@page contentType="text/html"%>

<%@page pageEncoding="UTF-8"%>

<%@ page import="javax.portlet.*"%>

<%@ page import="com.example.customer.service.*"%>

<%@ page import="com.example.customer.model.*"%>

<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>





<portlet:defineObjects />





<table>

<form method="POST" action="<portlet:actionURL/>">



<tr>

<td>User ID:</td>

<td><Input type="text" name="id"/></td>

</tr>

<tr>

<td>User Name:</td>

<td><Input type="text" name="name"/></td>

</tr>

<tr>

<td>Age:</td>

<td><Input type="text" name="age"/></td>

</tr>

<tr>

<td><Input type="submit"/></td>

</tr>

</form>

</table>

<H3> No of Customers in Database :

<%

out.println(CustomerDtlsLocalServiceUtil.getCustomerDtlsesCount());

%>

</H3>





JSPPortlet.java(I modified only the ProcessAction()

--------------------------------------------

public void processAction(ActionRequest request, ActionResponse response) throws PortletException,IOException {



try {

long id = Long.parseLong(request.getParameter("id"));

String name = request.getParameter("name");

int age = Integer.parseInt(request.getParameter("age"));

CustomerDtls customer = CustomerDtlsLocalServiceUtil.createCustomerDtls(id);

customer.setId(id);

customer.setName(name);

customer.setAge(age);

CustomerDtlsLocalServiceUtil.addCustomerDtls(customer);

System.out.println("Added");

} catch (Exception ex) {

ex.printStackTrace();



}








My Issue is how to differentiate the two forms and accroding to it the values should be stored in respective tablescolor]

No comments:

Post a Comment