1 2 Previous Next 16 Replies Latest reply on Feb 16, 2007 11:59 AM by theute

    programmatically disabling caching

      Hello,

      Has anybody experienced any problems trying to programmatically disable caching? We have a set of portlets that are configured to normally perform caching. However, for a certain class of user we need to disable caching. I have tried the following without any luck:

      public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException, UnavailableException
      {
      
       response.setProperty( RenderResponse.EXPIRATION_CACHE, "0" );
       ?
       }


      The statement seems to have no effect on the portlet behavior.

      (using v2.4 final (source download bundle), JBoss AS 4.0.4GA, JDK1.5.0, Windows XP)

      Thanks in advance,

      Jerry


        • 1. Re: programmatically disabling caching
          bmcgovern

          Were you able to figure this out? Im having the same problem.

          • 2. Re: programmatically disabling caching

            Yes, as a matter of fact I got back to this issue a few days ago and hadn?t got around to posting my findings.

            Unless I am missing something, it doesn?t appear that this was implemented anywhere (as of the 2.4 final release). I believe the problem is on line 65 of
            org.jboss.portal.portlet.aspects.portlet.ProducerCacheInterceptor.invoke(). The cache expiration value is being updated on each request using the configured EXPIRATION_CACHE value regardless of whether an EXPIRATION_CACHE property was set on the response. I added the following test which seems to work based on what little testing I have done so far.

            // Update the fragment cache info only if the value has not been overridden during render processing
            if ( fragmentResult.getProperties().getProperty(RenderResponse.EXPIRATION_CACHE) == null ) {
             fragmentResult.setExpirationSecs(cacheInfo.getExpirationSecs());
            }





            • 3. Re: programmatically disabling caching
              bmcgovern

              I agree. I've tried setting the expiration-cache value to 0 explicitly in portlet.xml and programatically in doView, each time it doesnt set.

              I'm stuck on this cause i need a work around for my situation..

              first time a form submits - processAction is called then doView. doView checks for existance of params set by processAction.

              Subsequent page loads invoke only doView which reads params already set by processAction and its screwing things up.

              Any ideas?

              • 4. Re: programmatically disabling caching

                I think the code snippet I posted above will fix this bug. Did you try it or are you saying that it doesn't fix it for your particular situation?

                • 5. Re: programmatically disabling caching
                  bmcgovern

                  Can you supply more code, specifically what your importing. It looks like fragmentCache is specific to jboss and that may work but i was hoping for a non platform specific fix. I was hoping it was something in the 168 spec that i was messing up? Does anyone have any idea?

                  • 6. Re: programmatically disabling caching

                    Just to clarify...the 168 spec only says that you should be able to do the following:

                    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException, UnavailableException
                    {
                     ...
                     response.setProperty( RenderResponse.EXPIRATION_CACHE, "0" );
                     ...
                     }


                    So if you are doing this, then you aren't "messing anything up".

                    The problem is that this doesn't seem to be properly implemented in JBoss Portal (as of v2.4). The workaround that I posted is a fix to the JBoss Portal source. You would have to download the source, make the change, and rebuild that jboss-portal.sar.

                    Hope that helps.

                    • 7. Re: programmatically disabling caching
                      theute

                      Please open a JIRA issue

                      • 8. Re: programmatically disabling caching
                        portal_man

                        Where is the "fragment cache info" that your are talking about ?
                        Why the JBoss' team haven't fix this problem in the 2.6alpha version ?

                         // Update the fragment cache info only if the value has not been
                         // overridden during render processing
                        
                         if ( fragmentResult.getProperties().getProperty(RenderResponse.EXPIRATION_CACHE) == null ) {
                         fragmentResult.setExpirationSecs(cacheInfo.getExpirationSecs());
                         }
                        


                        Is anyone on this forum knew a answer to this ?

                        I'm programming a inter-portlet communication with the help of this website :
                        http://www.doc.ic.ac.uk/~mo197/portlets/portlet_messaging/
                        and I can make work the first exemple (portlet1 send hello to portlet 2).

                        Regards

                        • 9. Re: programmatically disabling caching
                          theute

                           

                          "mylas" wrote:
                          Why the JBoss' team haven't fix this problem in the 2.6alpha version ?


                          Because ASAIK it is not in Jira. It's hard to keep everything if nobody even dare to file a bug report.

                          I'm looking at it.

                          • 10. Re: programmatically disabling caching
                            theute

                             

                            "bmcgovern" wrote:
                            I agree. I've tried setting the expiration-cache value to 0 explicitly in portlet.xml and programatically in doView, each time it doesnt set.

                            I'm stuck on this cause i need a work around for my situation..

                            first time a form submits - processAction is called then doView. doView checks for existance of params set by processAction.

                            Subsequent page loads invoke only doView which reads params already set by processAction and its screwing things up.

                            Any ideas?


                            That's the expected behavior that you are defining. The portal must be able to call the render method without invoking the action method again. The render method will always get the render parameters, that's per the spec.

                            • 11. Re: programmatically disabling caching
                              portal_man

                              It is in the JRA, I think.
                              I found this forum thanks to a link in this jra page :
                              http://jira.jboss.com/jira/browse/JBPORTAL-1104;jsessionid=BD4B2865E2711BAD3A9442763E0DB0D7?page=com.atlassian.jira.plugin.ext.subversion:subversion-commits-tabpanel

                              The reason I came to this forum is that I've don't understand the way to fix jboss portal (without downloading the sources and re-build it again).

                              Regards

                              • 12. Re: programmatically disabling caching
                                portal_man

                                It's not what I want to do.
                                Have you look to the tutorial page I try to folow ?
                                http://www.doc.ic.ac.uk/~mo197/portlets/portlet_messaging/

                                The portlet 1 put a String in an APPLICATION_SCOPE named b_var.
                                Then, the porlet 2 read it and show it.

                                But, because I can set the expiration-cache to 0, the portlet 2 don't notice that b_var has changed. And this second portlet dont display the String.

                                How can I do this stuff ?

                                • 13. Re: programmatically disabling caching
                                  theute

                                  It's marked as resolved.

                                  Are you sure it doesn't work ?

                                  • 14. Re: programmatically disabling caching
                                    portal_man

                                    The way to resolve it, is to download and change the source code.
                                    Is there any other way to resolve the problem ?

                                    Is there a simple way to make two portlet communicate ?

                                    Regards

                                    1 2 Previous Next