Foros de discusión

Problem with liferay-tabs and pagination

thumbnail
AKASH PATIL, modificado hace 12 años.

Problem with liferay-tabs and pagination

Junior Member Mensajes: 75 Fecha de incorporación: 13/12/10 Mensajes recientes
Hi Friends,

I am facing problem in liferay tabs & liferay search container,
Basically I am having two tabs, under which I am having liferay Search pagination code.

This is my code for displaying tabs: -


<%PortletURL portletURL = renderResponse.createRenderURL();	%>

	<liferay-ui:tabs names="sample1,sample2," refresh="true" param="tabs1" url="<%=portletURL.toString() %>">
</liferay-ui:tabs>


And the sections are as follows. And in both the sections, I have used liferay search container for two different lists by implementing pagination using search container.


<liferay-ui:section>
<liferay-ui:search-container delta="5" emptyresultsmessage="there-are-no-data">
		     
		     <liferay-ui:search-container-results results="someList" total="<%= someList.size() %>" />
		  
		     <liferay-ui:search-container-row classname="com.model.someModel" keyproperty="someId" modelvar="someModel">
		    <liferay-ui:search-container-column-jsp path="/html/common//some.jsp" />            
		    </liferay-ui:search-container-row>
		    <liferay-ui:search-iterator />
		</liferay-ui:search-container>

</liferay-ui:section>
<liferay-ui:section>
<liferay-ui:search-container delta="5" emptyresultsmessage="there-are-no-data">
		     
		     <liferay-ui:search-container-results results="someOtherList" total="<%= someOtherList.size() %>" />
		  
		     <liferay-ui:search-container-row classname="com.model.someModel" keyproperty="someId" modelvar="someModel">
		    <liferay-ui:search-container-column-jsp path="/html/common//some.jsp" />            
		    </liferay-ui:search-container-row>
		    <liferay-ui:search-iterator />
		</liferay-ui:search-container>

</liferay-ui:section>


And here is the end tag for tabs -





The problem I am facing is in remembering the current tab. When I am on my second tab, and the paginated list under it is long enough and I click next(on pagination board) to see the paginated items, the entire portlets seems to be getting reloaded, which takes me to my first tab (instead of keeping the focus on second tab).

How can we persist the selectedTab value even after the reloading of the page. Or is there any way where I can switch it off the reloading of page when clicking on the "Next" button of paginator.

Please help me to solve this problem. Struggling on this since long time.


Thank you all,
Akash Patil.
thumbnail
Nilesh Nemichand Gundecha, modificado hace 12 años.

RE: Problem with liferay-tabs and pagination

Regular Member Mensajes: 205 Fecha de incorporación: 1/12/09 Mensajes recientes
Hello Friends,

Please let us know whether its possible to switch it off the reloading of page in liefray search paginator.. Because of reloading of page, we are not able to use Liferay tabs and liferay paginator in combination.

Please point us to right direction if we are going wrong anywhere.

Thanks and Regards,
Nilesh.
thumbnail
Mohammed Azam, modificado hace 12 años.

RE: Problem with liferay-tabs and pagination

Regular Member Mensajes: 159 Fecha de incorporación: 6/11/09 Mensajes recientes
Hi Akash,
The tabs value have to be set or unset in the action file whenever its rendering.

then you can get the value of the tabs by using this code which ever tab user had selected.

String tabs1 = ParamUtil.getString(request, "tabs1", "default-tab");


set the value of the tabs1 in the portletURL


		portletURL.setParameter("tabs1","second tab");


hope this helps...
Stephan H, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

New Member Mensajes: 16 Fecha de incorporación: 15/02/12 Mensajes recientes
Hi,

i have implemented the tabs and it works. But in addition with the search container there is the same problem as mentioned above. Using the pagination board on "tab-2" affects in an redirect to "default-tab".

Hope somebody can help...
Victor E, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

New Member Mensajes: 5 Fecha de incorporación: 2/03/12 Mensajes recientes
Hi,

I've encountered similar problem as well.
Moving between tabs remembers the current tab selected after implementing the PortletURL solution above.
But, moving between searchcontainer pages does not remember the current tab you are.
Hope someone can advise on this. Thanks
thumbnail
Jitendra Rajput, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
try with below approach .
1) Get the current tab from request . if the tabs1 parameter will be null it will show Sample1 tab other wise it will display current tab.

String tabs1 = ParamUtil.getString(request, "tabs1", "sample1");

PortletURL iteratorURL = renderResponse.createRenderURL();
iteratorURL.setWindowState(WindowState.NORMAL);
iteratorURL.setParameter("tabs1", tabs1); 

Use the above portlet URL in liferay-ui tab

 <liferay-ui:tabs names="sample1,sample2," refresh="true" param="tabs1" url="<%=iteratorURL.toString() %>">
</liferay-ui:tabs>


Hope this helps.
Jitendra
thumbnail
Aneesha Rao, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

New Member Mensajes: 14 Fecha de incorporación: 24/02/12 Mensajes recientes
Hi,

I still face a problem with this..

I have 2 tabs: tab1 and tab2
and when I am on tab 2 and click on next (i.e. show 2nd page) in pagination, it navigates to tab1 and its 2nd page values.. not in tab2 and its 2nd page values..

Could anyone help me on this who have got a solution on the same? i tried with portletUrl setting but in vain..
---Thanks,
Aneesha
thumbnail
Jitendra Rajput, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

Liferay Master Mensajes: 875 Fecha de incorporación: 7/01/11 Mensajes recientes
Try by debugging your tabs parameter.
String tabs1 = ParamUtil.getString(request, "tabs1", "sample1");
thumbnail
Aneesha Rao, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

New Member Mensajes: 14 Fecha de incorporación: 24/02/12 Mensajes recientes
Hi,

It worked by writing the whole code inside <liferay-ui:search-container> emoticon
--Thanks,
Aneesha
thumbnail
Amit Doshi, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

Liferay Master Mensajes: 550 Fecha de incorporación: 29/12/10 Mensajes recientes
Hi Aneesha,

Rather than writing all the code in the JSP page. Better is to write in the Class and put conditions only in the JSP Page.

I am using 5 tabs with 5 different Search containers and it is working fine for me.

Here is the code that I am sharing.

In the JSP Page write code as below :-




<liferay-portlet:renderurl var="portletURL">
	<liferay-portlet:param name="tabs" value="${tabs}"></liferay-portlet:param>
</liferay-portlet:renderurl>
<c:set var="tab1" value="A" />
<c:set var="tab2" value="B" />
<c:set var="tab3" value="C" />
<c:set var="tab4" value="D" />
<c:set var="tab5" value="E" />
<liferay-ui:tabs names="A,B,C,D,E" param="tabs" refresh="<%= true %>" url="<%=portletURL %>">
		<liferay-ui:section>
			<c:if test="${tabs eq tab1 }">
			        &lt;%@include file="/html/portlet/A/a.jsp"%&gt;
			</c:if>
		</liferay-ui:section>
		<liferay-ui:section>
			<c:if test="${tabs eq tab2}">
			       &lt;%@include file="/html/portlet/B/b.jsp"%&gt;
			</c:if>
		</liferay-ui:section>
		<liferay-ui:section>
			<c:if test="${tabs eq tab3}">
			          &lt;%@include file="/html/portlet/C/c.jsp"%&gt;
			</c:if>
		</liferay-ui:section>
                 <liferay-ui:section>
			<c:if test="${tabs eq tab4}">
			          &lt;%@include file="/html/portlet/D/d.jsp"%&gt;
			</c:if>
		</liferay-ui:section>
                <liferay-ui:section>
			<c:if test="${tabs eq tab5}">
			          &lt;%@include file="/html/portlet/E/e.jsp"%&gt;
			</c:if>
		</liferay-ui:section>

</liferay-ui:tabs> 


In the Controller end.



String tabName= ParamUtil.getString(renderRequest,tabs);
		
		
		
		renderRequest.setAttribute(tabs, tabName);



Hope it will help.

Thanks & Regards,
Amit Doshi
Shashant Panwar, modificado hace 10 años.

RE: Problem with liferay-tabs and pagination

Junior Member Mensajes: 28 Fecha de incorporación: 21/09/12 Mensajes recientes
Hi Amit,
I tried implementing your code but I am unable to achieve the original functionality raised here.
Was wondering how you are setting tabs value in your tabs(A,B,C,D) jsp.
How you are passing tab name to doView method? Is it possible for you to put your tab jsp codes?

Regards,
Shashant
thumbnail
Amit Doshi, modificado hace 10 años.

RE: Problem with liferay-tabs and pagination

Liferay Master Mensajes: 550 Fecha de incorporación: 29/12/10 Mensajes recientes
Hi Shashant,

I already written a complete blog on this.

http://liferaytrends.blogspot.in/2013/01/tabs-with-search-container-in-liferay.html

You can also find complete source code at the end of the blog.

Let me know if you have any questions.

Thanks & Regards,
Amit Doshi
Shashant Panwar, modificado hace 10 años.

RE: Problem with liferay-tabs and pagination

Junior Member Mensajes: 28 Fecha de incorporación: 21/09/12 Mensajes recientes
Thanks Mate for the link.
I resolved the issue and got lot of help from your post. Keep up the good work emoticon

Regards,
Shashant
Sandeep Singh, modificado hace 10 años.

RE: Problem with liferay-tabs and pagination

New Member Mensajes: 4 Fecha de incorporación: 2/12/11 Mensajes recientes
In the JSP Page write this code........

<%
PortletURL portletURL = renderResponse.createRenderURL();

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

Object ob = request.getAttribute("selectedTab");
String value ="Job 1";
if (ob != null) {
value = (String) ob;
tabs1 = value;
}
%>

<liferay-ui:tabs
names="Job 1,Job 2"
refresh="true"
param="tabs1"
url="<%=portletURL.toString() %>"
value="<%=tabs1 %>"
>

<liferay-ui:section>
<c:if test='<%= tabs1.equalsIgnoreCase("Job 1")%>'>
<%@include file="/html/admin/job1.jsp"%>
</c:if>
</liferay-ui:section>
<liferay-ui:section>
<c:if test='<%= tabs1.equalsIgnoreCase("Job 2")%>'>
<%@include file="/html/admin/job2.jsp"%>
</c:if>
</liferay-ui:section>
</liferay-ui:tabs>

=================================

In the Java doView write this code........

public void doView(RenderRequest request,RenderResponse response) throws IOException,PortletException{

String selectedTab= ParamUtil.getString(request,"tabs1");

if(selectedTab!=null && !("".equalsIgnoreCase(selectedTab))){
request.getPortletSession().setAttribute("selectedTab", selectedTab);
request.setAttribute("selectedTab", selectedTab);
}else{
selectedTab = (String)request.getPortletSession().getAttribute("selectedTab");
request.setAttribute("selectedTab", selectedTab);
}

PortletRequestDispatcher dispatcher = null;
dispatcher = getPortletContext().getRequestDispatcher(
"/html/admin/jobAdmin.jsp");

dispatcher.include(request, response);
}
thumbnail
Jay Trivedi, modificado hace 11 años.

RE: Problem with liferay-tabs and pagination

Regular Member Mensajes: 109 Fecha de incorporación: 24/11/12 Mensajes recientes
can you put down the code..

Thanks Jay.