[opencms-dev] Solved: Broken behaviour of contentload/show/info tag

Bernd Wolfsegger bw at code-create.com
Mon Oct 17 21:49:42 CEST 2005


O.k. I have attached two patches.
If the "locale" attribute is used in the contentload and contentshow tags, 
than the used locale depends on this attribute.
If it is not used, all is the same as in the 6.0.0.

No warranty at all. But perhaps alkacon can implement something like that in 
the next maintenance release...


Kind regards, Bernd

On Monday, 17. October 2005 19:10, Bernd Wolfsegger wrote:
> .... but it should be set to null via the setLocale method whilst
> initializing...
>
> Huh, but setLocale() is never called ..., but it should be, or am I wrong?
>
> On Monday, 17. October 2005 18:46, Bernd Wolfsegger wrote:
> > Well, simple.
> > In the "release()" method m_locale is set to null, but the release method
> > is not called from request to request...
> >
> > From the J2EE Javadoc:
> >
> > javax.servlet.jsp.tagext.Tag Interface:
> >
> > Lifecycle
> >
> > Lifecycle details are described by the transition diagram below, with the
> > following comments:
> >
> >     * [1] This transition is intended to be for releasing long-term data.
> > no guarantees are assumed on whether any properties have been retained or
> > not. * [2] This transition happens if and only if the tag ends normally
> > without raising an exception
> >     * [3] Note that since there are no guarantees on the state of the
> > properties, a tag handler that had some optional properties set can only
> > be reused if those properties are set to a new (known) value. This means
> > that tag handlers can only be reused within the same "AttSet" (set of
> > attributes that have been set).
> >     * Check the TryCatchFinally interface for additional details related
> > to exception handling and resource management.
> >
> > .....
> >
> > release
> >
> > public void release()
> >
> >     Called on a Tag handler to release state. The page compiler
> > guarantees that JSP page implementation objects will invoke this method
> > on all tag handlers, but there may be multiple invocations on doStartTag
> > and doEndTag in between.
> >
> > .....
> >
> > Kind regards, Bernd Wolfsegger
> >
> > On Monday, 17. October 2005 18:19, Bernd Wolfsegger wrote:
> > > O.k. A view into the source code.
> > > The locale is retrieved from the CmsRequestContext ... so it should be
> > > o.k. But this is done only if m_locale is null. But it is not null. At
> > > least not after the second request of the ressource (added some debug
> > > information to the code). So it seems, that somehow m_locale is not
> > > reset from one request to the other. The value retrieved form the
> > > CmsRequestContext is o.k..
> > >
> > > Indeed in the 6.0.0 code there was no "if (m_locale == null)...".
> > > So why is the value for m_locale kept?
> > >
> > >
> > > Kind regards, Bernd Wolfsegger
> > >
> > > On Monday, 17. October 2005 17:03, Bernd Wolfsegger wrote:
> > > > OpenCms 6.0.2 release notes:
> > > >
> > > > ....
> > > > "Added options to access XML content based on a given locale to
> > > > <cms:contentload/show/info> tags"
> > > > ....
> > > >
> > > > Well, would have been very nice if this would not break with previous
> > > > behaviour ...
> > > > But it does. When not using the new "locale" option, the first
> > > > default locale is used and not the locale retrieved by the default
> > > > locale handler class as it was before ...
> > > > Well, this means scrubbing JSPs ... but ... how can i insert a locale
> > > > value in the contentshow tag dynamically when it is not allowed to
> > > > use script inside ...?
> > > > hm, there was something ... i remember ... anybody who knows?
> > > > may be I am faster finding out myself.
> > > >
> > > > or better, is it possible to have the previous behaviour back
> > > > somehow; would be a logical behaviour also.
> > > >
> > > > Kind regards, Bernd
>
> _______________________________________________
> This mail is send to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please visit
> http://mail.opencms.org/mailman/listinfo/opencms-dev

-- 

[  Code Create
[  Web Content Management and Presentation


[  Bernd Wolfsegger
[  Sun Certified Programmer for Java(TM) 2 Platform


[  Lohmeyerstrasse 13
[  10587 Berlin
[  Germany
[  Fon +49 (0)30 26555788
[  Fax +49 (0)30 2651835
[  Mobile +49 (0)163 6505622

[  bw at code-create.com
[  http://www.code-create.com/

-------------- next part --------------
Index: CmsJspTagContentLoad.java
===================================================================
RCS file: /usr/local/cvs/opencms/src/org/opencms/jsp/CmsJspTagContentLoad.java,v
retrieving revision 1.29
diff -u -r1.29 CmsJspTagContentLoad.java
--- CmsJspTagContentLoad.java	10 Oct 2005 16:11:03 -0000	1.29
+++ CmsJspTagContentLoad.java	17 Oct 2005 19:33:27 -0000
@@ -133,6 +133,9 @@
     /** The file name to load the current content value from. */
     private String m_resourceName;
 
+    /** Does the contentload tag contain the locale attribute? */
+    private boolean m_tagSetLocale;
+
     /**
      * Returns the resource name currently processed.<p> 
      * 
@@ -344,8 +347,8 @@
         m_controller = CmsFlexController.getController(pageContext.getRequest());
         m_cms = m_controller.getCmsObject();
 
-        // store the current locale    
-        if (m_locale == null) {
+        // store the current locale
+        if (m_locale == null || !this.m_tagSetLocale) {
             m_locale = m_cms.getRequestContext().getLocale();
         }
 
@@ -437,7 +440,7 @@
                 null,
                 m_directEditCreateLink);
         }
-
+        
         return EVAL_BODY_INCLUDE;
     }
 
@@ -592,7 +595,6 @@
      * @see javax.servlet.jsp.tagext.Tag#release()
      */
     public void release() {
-
         m_resourceName = null;
         m_collector = null;
         m_collectorResult = null;
@@ -614,7 +616,6 @@
      * @param collector the collector to set
      */
     public void setCollector(String collector) {
-
         m_collector = collector;
     }
 
@@ -634,7 +635,8 @@
      * @param locale the locale to set
      */
     public void setLocale(String locale) {
-
+      m_tagSetLocale = true;
+      
         if (CmsStringUtil.isEmpty(locale)) {
             m_locale = null;
         } else {
-------------- next part --------------
Index: CmsJspTagContentShow.java
===================================================================
RCS file: /usr/local/cvs/opencms/src/org/opencms/jsp/CmsJspTagContentShow.java,v
retrieving revision 1.24
diff -u -r1.24 CmsJspTagContentShow.java
--- CmsJspTagContentShow.java	10 Oct 2005 16:11:03 -0000	1.24
+++ CmsJspTagContentShow.java	17 Oct 2005 19:33:55 -0000
@@ -76,6 +76,9 @@
     /** Locale of the content node elemen to show. */
     private Locale m_locale;
 
+    /** Does the contentload tag contain the locale attribute? */
+    private boolean m_tagSetLocale;
+
     /**
      * Internal action method to show an element from a XML content document.<p>
      * 
@@ -132,7 +135,7 @@
         // get loaded content from parent <contentload> tag
         A_CmsXmlDocument xmlContent = contentContainer.getXmlDocument();
 
-        if (m_locale == null) {
+        if (m_locale == null || !m_tagSetLocale) {
             m_locale = contentContainer.getXmlDocumentLocale();
         }
 
@@ -226,6 +229,7 @@
      * @param locale the locale to set
      */
     public void setLocale(String locale) {
+        m_tagSetLocale = true;
 
         if (CmsStringUtil.isEmpty(locale)) {
             m_locale = null;


More information about the opencms-dev mailing list