I just reviewed the code and this looks good. It is consistent with the how the screen decorator works, and as with any good stack management the best way to keep it safe is to do the push and pop in the same scope.

I didn't test the problem or fix, but to clarify it looks like the original code sample was an example of something that should NOT work, but did because of this bug.

-David


On Nov 26, 2007, at 6:30 PM, BJ Freeman wrote:

Per david, I i would like to test this.
could you send the files you used as an attachment?
or open a jira and put then there.
thanks.


Jonathon -- Improov sent the following on 11/26/2007 9:47 AM:
Oh. Sorry.

${component:widget}/src

package org.ofbiz.widget.screen;

Jonathon

BJ Freeman wrote:
can you give a reference to where the code is.
can't seem to find it.


Jonathon -- Improov sent the following on 11/26/2007 8:09 AM:
Hmm. Another quirk that sent me off the cliff. :)

HtmlWidget.render(Writer, Map, ScreenStringRenderer) seems to be missing
a MapStack pop.

To see the bug, do the 2 screen widgets below, "SomeScreen" and
"SomeDecorator".

What happens is that section "section2" is gone after processing
"section1" in "SomeDecorator".

Here's why.

See "SomeDecorator". The SectionsRenderer stored in variable "sections"
is created with one section at the line of
<html-template-decorator-section name="section1">. This SectionsRenderer is created in a private context, with the context of "SomeScreen" pushed
into a MapStack.

Before that, the SectionsRenderer stored in variable "sections" in the
previous context (that of "SomeScreen") was created with 2 sections
"section1" and "section2".

During processing, because the first SectionsRenderer (with only 1
section "section1") was never popped from the MapStack, it is used to do the next section include <decorator-section-include name="section2"/>.
Obviously, the section "section2" does not exist.

<screen name="SomeScreen">
 <section>
 <widgets>
   <decorator-screen name="SomeDecorator">

     <decorator-section name="section1">
       <label text="Section One content"/>
     </decorator-section>

     <decorator-section name="section2">
       <label text="Section Two content"/>
     </decorator-section>

   </decorator-screen>
 </widgets>
 </section>
</screen>

<screen name="SomeDecorator">
 <section>
 <widgets>

   <platform-specific><html>
     <html-template-decorator location="SomeTemplate.ftl">
       <html-template-decorator-section name="section1">
         <decorator-section-include name="section1"/>
       </html-template-decorator-section>
     </html-template-decorator>
   </html></platform-specific>

   <decorator-section-include name="section2"/>

 </widgets>
 </section>
</screen>

Jonathon










Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to