[OFBiz] Users - Screen Widget Idea

Adrian Crum adrianc at hlmksw.com
Tue Mar 15 20:01:56 EST 2005


I'm working on my idea of OFBiz components sharing a common template. I 
need help with a problem getting my idea implemented. Any help would be 
appreciated!

Let's say a component references a main decorator in common/widget. The 
main decorator would look something like:

<screen name="main-decorator">
   <section>
     <actions>
       <property-map resource="CommonUiLabels" map-name="uiLabelMap" 
global="true"/>
       <!-- <set field="layoutSettings.headerMiddleBackgroundUrl" 
value="" global="true"/> -->
       <!-- <set field="layoutSettings.headerRightBackgroundUrl" 
value="" global="true"/> -->
     </actions>
     <widgets>
       <!-- OFBiz customization hook - decorator sections named 
"pre-template" are included here -->
       <decorator-section-include name="pre-template"/>

       <!-- render header -->
       <platform-specific><html><html-template 
location="component://common/webcommon/includes/header.ftl"/></html></platform-specific>

       <!-- render appbar -->
       <platform-specific><html><html-template 
location="component://common/webcommon/includes/appbar.ftl"/></html></platform-specific>

       <container style="centerarea">
         <!-- render appheader -->
         <platform-specific><html><html-template 
location="component://example/webapp/example/includes/appheader.ftl"/></html></platform-specific>

         <container style="contentarea">
           <container style="column-main">
             <!-- render messages -->
             <platform-specific><html><html-template 
location="component://common/webcommon/includes/messages.ftl"/></html></platform-specific>
             <decorator-section-include name="body"/>
           </container>
         </container>
       </container>

       <!-- render footer -->
       <platform-specific><html><html-template 
location="component://common/webcommon/includes/footer.ftl"/></html></platform-specific>

       <!-- OFBiz customization hook - decorator sections named 
"post-template" are included here -->
       <decorator-section-include name="post-template"/>
     </widgets>
   </section>
</screen>

I added the "pre-template" decorator-section-include so that the 
<page-action> feature of JPublish could be simulated. The problem is, 
any scripts that are specified in the "pre-template" decorator sections 
in the components aren't run BEFORE the header.ftl template is output. 
The "pre-template" scripts seem to run where the 
<decorator-section-include name="body"/> line appears.

My component's XML file looks something like this:

<screen name="myPage">
   <section>
     <actions>
       <set field="headerItem" value="main"/>
     </actions>
     <widgets>
       <decorator-screen name="main-decorator" 
location="component://common/widget/CommonScreens.xml">
         <decorator-section name="pre-template">
           <section>
             <actions>
               <script 
location="component://myapp/webapp/WEB-INF/actions/main/mainScript.bsh"/>
             </actions>
             <widgets>
             </widgets>
           </section>
         </decorator-section>
         <decorator-section name="body">
           <section>
             <actions>
               <script 
location="component://myapp/webapp/WEB-INF/actions/main/myPage.bsh"/>
             </actions>
             <widgets>
               <platform-specific> 
<html><html-template 
location="component://myapp/webapp/main/myPage.ftl"/></html>
               </platform-specific>
             </widgets>
           </section>
         </decorator-section>
       </decorator-screen>
     </widgets>
   </section>
</screen>


The goal is to have the mainScript.bsh run first. Then the templates in 
main-decorator are used. Finally, the myPage.bsh script runs when 
myPage.ftl is output.

The myPage.bsh/myPage.ftl combination work fine. It's just the 
mainScript.bsh part that I can't seem to get to work as desired.

Everything else seems to work well with this arrangement.




More information about the Users mailing list