Laliwala IT Services

Laliwala IT Services
Website Development

Wednesday, February 23, 2011

Remember Current Tab , string, portlet url, create render url, liferay process, liferay action, liferay name, search browse, action



Pascal Wasem : Hi!








I have some tabs in my jsp-file!








Like this:








As you can see the first tab contains a form with an input box

the second one a link!

Both create an actionUrl!








The Problem:

If I click the link in the second tab (->actionUrl), the second tab becomes unselected!








How to remember which tab was selected before the request?








By the way there ANY (detailed) documentation about how to use the liferay taglibs?








Thank you!








Best regards,

Pascal






Mazhar Anwar : You can get last selected tab in you jsp from request parameter as follows,








<% String tabs1 = ParamUtil.getString(request, "tabs1", "Search");%>








And You need to create instance of PortletURL,








PortletURL portletURL = renderResponse.createRenderURL();

portletURL.setWindowState(WindowState.MAXIMIZED);

portletURL.setParameter("tabs1", tabs1);








AND








<liferay-ui:tabs

names="names="Search,Browse"

url="<%= portletURL.toString() %>"

/>





OR








<portlet:actionURL name="SelectProcess">

<portlet:param name="process" value="<%= someValue %>"/>

<portlet:param name="tabs1" value="<%=tabs1 %>" />;

</portlet:actionURL>"








For more details about Tabs taglibs you can explore the enterprise admin porlet in portal source. You will find it in portal/portal-web/docroot/html/portlet/enterprise_admin.











HTH...



Regards,

Mazhar






Pascal Wasem : Hi Mazhar,








Thank you for your response!

But this only helped me partially.

Althoug I think I am on the right way.








I'am using this now in my jsp:
















The problem is that even if I forward the tabs1-param in the action url it ALWAYS remains "Search".





It seems like the current selected tab is not stored in tabs1?








Although setting it to "Browse" in my Portlet-Class works fine!













What am I missing!

Has it sth to do with param, url or refresh in <liferay-ui:tabs> ?








Thanks!








Best,

Pascal






Sandeep Nair : Hi,








Use this along with the above changes





<liferay-ui:tabs names="Search,Browse" param="tabs1" refresh="<%= false %>">








And in both the action pass the following parameter








<portlet:param name="tabs1" value="Search" /> in the first








and <portlet:param name="tabs1" value="Browse" /> in second








Regards

Sandeep






Pascal Wasem : Thanks Sandeep, that did it!






Gourab Kar : ok everybody out there... hi and greetings.








At last I solved the problem. I had to get inside liferay-UI:tabs tld's init jsp.








what we all did was

<liferay-ui:tabs

names="tabs1, tabs2" //"Skills,Notification" in my case

param="tab"

url="<someURL>"

/>








but we are missing a very highly critical info in tabs tag- that is 'value' or 'values'.

the param passes the tab string that we get as a string along with default value, but the value attribute is the main variable that defines the desired tab.








if we don't pass anything as value, then for every inner rendering/ request will make the default tab active.








so try this:

<liferay-ui:tabs

names="tabs1, tabs2" //"Skills,Notification" in my case

param="tab"

url="<someURL>"

value="tab1" //this will always keep tab1 active

/>








and this one:

<liferay-ui:tabs

names="tabs1, tabs2" //"Skills,Notification" in my case

param="tab"

url="<someURL>"

value="tab2" //this will always keep tabs2 active

/>








and finally this one:

<liferay-ui:tabs

names="tabs1, tabs2" //"Skills,Notification" in my case

param="tab"

url="<someURL>"

value="<%=currentTab%>"

/> //this will always keep the current value you are getting on tab








My sincere thanks to sandeep nair who worked with me on this and my senior Tarun who guided me.






Anders Olme : How do you set the





<liferay-ui:tabs

names="tabs1, tabs2" //"Skills,Notification" in my case

param="tab"

url="<someURL>"

value="<%=currentTab%>"

/>








currentTab variable to to the correct value (or is it some kind of liferay system variable)?








Brg Anders Olme






Gourab Kar : Yes values is a liferay's system parameter(variable) and <%=currentTab%> is the jsp scriptlet.








So for the first time when this portlet is loaded currentTab at the beginning will be null so the param will pass the initial value.





For every next iteration the currentTab will be what is set from the respective jsps as setAttribute








Eg: request.setAttribute("tab", <value of the tab that you want to pass>)








And this is received in another jsp, especially the init jsp as





currentTab = getAttribute("tab");








<liferay-ui:tabs value=<%currentTab%>...>






Anders Olme : Oki, thanks for the answer!








BRG Anders Olme

No comments:

Post a Comment