Forums de discussion

Problem with liferay-tabs and pagination

thumbnail
AKASH PATIL, modifié il y a 13 années.

Problem with liferay-tabs and pagination

Junior Member Publications: 75 Date d'inscription: 13/12/10 Publications récentes
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, modifié il y a 13 années.

RE: Problem with liferay-tabs and pagination

Regular Member Publications: 205 Date d'inscription: 01/12/09 Publications récentes
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, modifié il y a 12 années.

RE: Problem with liferay-tabs and pagination

Regular Member Publications: 159 Date d'inscription: 06/11/09 Publications récentes
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, modifié il y a 12 années.

RE: Problem with liferay-tabs and pagination

New Member Publications: 16 Date d'inscription: 15/02/12 Publications récentes
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, modifié il y a 11 années.

RE: Problem with liferay-tabs and pagination

New Member Publications: 5 Date d'inscription: 02/03/12 Publications récentes
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, modifié il y a 11 années.

RE: Problem with liferay-tabs and pagination

Liferay Master Publications: 875 Date d'inscription: 07/01/11 Publications récentes
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, modifié il y a 11 années.

RE: Problem with liferay-tabs and pagination

New Member Publications: 14 Date d'inscription: 24/02/12 Publications récentes
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, modifié il y a 11 années.

RE: Problem with liferay-tabs and pagination

Liferay Master Publications: 875 Date d'inscription: 07/01/11 Publications récentes
Try by debugging your tabs parameter.
String tabs1 = ParamUtil.getString(request, "tabs1", "sample1");
thumbnail
Aneesha Rao, modifié il y a 11 années.

RE: Problem with liferay-tabs and pagination

New Member Publications: 14 Date d'inscription: 24/02/12 Publications récentes
Hi,

It worked by writing the whole code inside <liferay-ui:search-container> emoticon
--Thanks,
Aneesha
thumbnail
Amit Doshi, modifié il y a 11 années.

RE: Problem with liferay-tabs and pagination

Liferay Master Publications: 550 Date d'inscription: 29/12/10 Publications récentes
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, modifié il y a 10 années.

RE: Problem with liferay-tabs and pagination

Junior Member Publications: 28 Date d'inscription: 21/09/12 Publications récentes
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, modifié il y a 10 années.

RE: Problem with liferay-tabs and pagination

Liferay Master Publications: 550 Date d'inscription: 29/12/10 Publications récentes
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, modifié il y a 10 années.

RE: Problem with liferay-tabs and pagination

Junior Member Publications: 28 Date d'inscription: 21/09/12 Publications récentes
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, modifié il y a 10 années.

RE: Problem with liferay-tabs and pagination

New Member Publications: 4 Date d'inscription: 02/12/11 Publications récentes
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, modifié il y a 11 années.

RE: Problem with liferay-tabs and pagination

Regular Member Publications: 109 Date d'inscription: 24/11/12 Publications récentes
can you put down the code..

Thanks Jay.