• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to clear portlet cache?

 
Ranch Hand
Posts: 147
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I load portlets with a menu. When i push on a menu item one portlet loads. When i push on other menu item, other portlet loads.

The problem is the next one:
I load a portlet and navigate through it, so i load diferent pages inside that portlet. When i push on the menu (the same item) the portlet keeps in cache last url loaded, but i need the initial page. How is it possible to implement that?
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Even I have facing the same problem.
In my jboss portal I have different Tabs like Home,Reports and apps. I clicked on Home tab first, all the portlets in Home tab got loaded and did some operations in all the portlets. So resultant portlets displayed in the Home page. After that I moved to reports tab and did some operations on all the report portlets. So resultant portlets displayed in the Reports page. I navigated between all the tabs but the last resultant portlets are still getting displayed.
So my question is: Is there any configuaration like Expiration-Cache tag to display the default pages when the tab is clicked?
 
jayabharatha reddy sadanagiri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bharath sadanagiri wrote:Even I am facing the same problem.
In my jboss portal I have different Tabs like Home,Reports and apps. I clicked on Home tab first, all the portlets in Home tab got loaded and did some operations in all the portlets. So resultant portlets displayed in the Home page. After that I moved to reports tab and did some operations on all the report portlets. So resultant portlets displayed in the Reports page. I navigated between all the tabs but the last resultant portlets are still getting displayed.
So my question is: Is there any configuaration like Expiration-Cache tag to display the default pages when the tab is clicked?

 
Ranch Hand
Posts: 820
IntelliJ IDE VI Editor Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What do you have expiration-cache set to now?

in each portlet.xml should make them show initial state
 
jayabharatha reddy sadanagiri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Already, for all the portlets it is mentioned like
<expiration-cache>0</expiration-cache>

but still no use
 
jayabharatha reddy sadanagiri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I got the answer from the following site.

Once ActionResponse.setRenderParameter () is called, parameter will be available between all sub sequent requests.
http://portals.apache.org/pluto/portlet-1.0-apidocs/javax/portlet/ActionResponse.html

This link https://www.ibm.com/developerworks/mydeveloperworks/blogs/Joey_Bernal/entry/refreshing_a_portlet_on_the?lang=en
provides a solution. It says instead of setting parameters in renderRequest object in processAction (), set it in session, once used in JSP, remove from session. In this way, you can solve this problem. Move all parameters to session and remove it as soon as you have used in page.

In my case, I moved the navagation key like actionCommand to session and removed in the doView method itself. Please find the piece of code.
in doView() method
============
PortletSession ps = req.getPortletSession();
String actionCommand= (String)ps.getAttribute("actionCommand");
if( ( actionCommand!=null && actionCommand.length()>0 )&& actionCommand.equals("displayCompanyUserReport")){
LOG.debug("Forwarding the request to DisplayCompanyUserReport.jsp for the default functionality");
prd = getPortletContext().getRequestDispatcher("/view/DisplayCompanyUserReport.jsp");
ps.removeAttribute("actionCommand");
LOG.debug("Removed actionCommand from the session");
}
in processAction() method
=================
String actionCommand= req.getParameter("actionCommand");
if( ( actionCommand!=null && actionCommand.length()>0 )&& actionCommand.equals("displayCompanyUserReport")){
res.setRenderParameter("companyId", req.getParameter("companyId"));
res.setRenderParameter("actionCommand", "dummy");
session.setAttribute("actionCommand", "displayCompanyUserReport");
}

Regards,
Jayabharath
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bharath sadanagiri wrote:Hi,
I got the answer from the following site.

Once ActionResponse.setRenderParameter () is called, parameter will be available between all sub sequent requests.
http://portals.apache.org/pluto/portlet-1.0-apidocs/javax/portlet/ActionResponse.html

This link https://www.ibm.com/developerworks/mydeveloperworks/blogs/Joey_Bernal/entry/refreshing_a_portlet_on_the?lang=en
provides a solution. It says instead of setting parameters in renderRequest object in processAction (), set it in session, once used in JSP, remove from session. In this way, you can solve this problem. Move all parameters to session and remove it as soon as you have used in page.

In my case, I moved the navagation key like actionCommand to session and removed in the doView method itself. Please find the piece of code.
in doView() method
============
PortletSession ps = req.getPortletSession();
String actionCommand= (String)ps.getAttribute("actionCommand");
if( ( actionCommand!=null && actionCommand.length()>0 )&& actionCommand.equals("displayCompanyUserReport")){
LOG.debug("Forwarding the request to DisplayCompanyUserReport.jsp for the default functionality");
prd = getPortletContext().getRequestDispatcher("/view/DisplayCompanyUserReport.jsp");
ps.removeAttribute("actionCommand");
LOG.debug("Removed actionCommand from the session");
}
in processAction() method
=================
String actionCommand= req.getParameter("actionCommand");
if( ( actionCommand!=null && actionCommand.length()>0 )&& actionCommand.equals("displayCompanyUserReport")){
res.setRenderParameter("companyId", req.getParameter("companyId"));
res.setRenderParameter("actionCommand", "dummy");
session.setAttribute("actionCommand", "displayCompanyUserReport");
}

Regards,
Jayabharath



I have the same problem, I tried your solution but is not working.

I have some tabs into the portal page (manage.jspx) and for each tab I have a portlet (every portlet has some pages). When I change the tab I want to show the first portlet page for each portlet, but it shows the last page visited.

How can I fix this problem?

Thanks in advance.
 
jayabharatha reddy sadanagiri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do like the following in the PortletAction class
 
Fabio Bernardo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bharath sadanagiri wrote:Do like the following in the PortletAction class



It seems like the removeAttribute is not working.

This is my processAction method:

PortletSession portletSession = request.getPortletSession();

String nextPage = request.getParameter("nextPageParam");
portletSession.setAttribute("nextPage", nextPage);

//For doView to get this parameter
try {
if (nextPage != null && nextPage.equals("second")) {
String codicericarica = request.getParameter("codicericarica");
//Store in Session
portletSession.setAttribute("codicericarica", codicericarica);
} else if (nextPage != null && nextPage.equals("third")) {
String smartcard = request.getParameter("smartcard");
//Store in Session
portletSession.setAttribute("smartcard", smartcard);
} else if(nextPage != null && nextPage.equals("stampa")){
}
} catch (Exception e) {
portletSession.setAttribute("error", "Y");
}


and this is my doView method:

response.setContentType("text/html");
PortletSession portletSession = request.getPortletSession();

String nextPage = (String)portletSession.getAttribute("nextPage");
//To conditionally display the view and modify pages.
PortletRequestDispatcher dispatcher = null;
String error = (String)portletSession.getAttribute("error");
if (error != null && error.equals("Y")) {
dispatcher = getPortletContext().getRequestDispatcher("/Attiva_Ricarica_Portlet/html/viewError.jsp");
portletSession.removeAttribute("error");
} else {
if ((nextPage != null && nextPage.equals("second"))) {
String codicericarica = (String)portletSession.getAttribute("codicericarica");
request.setAttribute("codicericarica", codicericarica);
dispatcher = getPortletContext().getRequestDispatcher("/Attiva_Ricarica_Portlet/html/viewSmartCard.jsp");
portletSession.removeAttribute("nextPage");
} else if ((nextPage != null && nextPage.equals("third")) || (nextPage!=null && nextPage.equals("stampa"))) {
String codicericarica = (String)portletSession.getAttribute("codicericarica");
String smartcard = (String)portletSession.getAttribute("smartcard");
//It is not possible to retrieve Portletsession in jsp, so set the values in request attribute
request.setAttribute("codicericarica", codicericarica);
request.setAttribute("smartcard", smartcard);
portletSession.setAttribute("firstpage", "Y");
dispatcher = getPortletContext().getRequestDispatcher("/Attiva_Ricarica_Portlet/html/viewConferma.jsp");
portletSession.removeAttribute("nextPage");
} else if ((nextPage == null)){
dispatcher =
getPortletContext().getRequestDispatcher("/Attiva_Ricarica_Portlet/html/view.jsp");
}
}
dispatcher.include(request, response);
}
 
jayabharatha reddy sadanagiri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If removeAttribute is not working then over write the attribute value to any dummy/NULL value.



in doView method, change the default view page condition like the following

 
Fabio Bernardo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bharath sadanagiri wrote:If removeAttribute is not working then over write the attribute value to any dummy/NULL value.



in doView method, change the default view page condition like the following



Yeah, but the navigation should be:

I'm in Tab1: page1->click->page2->click->final page ... into this page i have a print button and the portlet should show this page if i click, as many times as I want, on the button. Then I change tab going to tab2

When I come back to tab1 the portlet should show the first page.

How can I do this?
 
jayabharatha reddy sadanagiri
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Navigation process is same for every thing. To PRINT web page data, you can use the following javascript fuction in JSP



following is the CSS method
@media print {
body {visibility:hidden;}
.print { visibility:visible;
}
}
 
Fabio Bernardo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bharath sadanagiri wrote:Navigation process is same for every thing. To PRINT web page data, you can use the following javascript fuction in JSP



following is the CSS method
@media print {
body {visibility:hidden;}
.print { visibility:visible;
}
}



Thanks for the code but my problem isn't to print something...the problem is how can I refresh the portlet and showing the first page when I click on the different tabs and than come back?
(the tabs are into the portal jspx page not into the portlet page)
 
Fabio Bernardo
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
???
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic