╰☆把酒言欢
                               聪明出于勤奋,天才在于积累.

what   why


v.在ofbiz中的应用的主题是可以通过数据来配置的,在webtools 组件中的catalog,  content 菜单下可分别设置店铺和网站的主题。且ofbiz在设计前端页面时,不使用table之类的html元素进行布局,而是大量使用div元素进行布局。 这样可以为一个网站或店铺设置多种不同的视觉风格,同时做到html中内容和风格的分离,提高开发效率及可维护性。

how

v.在ofbiz 中的ecommerce 示例中网站的主题是根据一个action 中的 service 的得到的。 而这个Service 使用mini 语言实现的。

在Ecommerce 下的CommonScreens.xml#main-decorator   action 中通过service 标签调用 mini 语言实现的服务。

<script location="component://ecommerce/widget/EcommerceSetup.groovy"/>  
<!-- Get the store VisualTheme -->  
<set field="visualThemeId" from-field="productStore.visualThemeId" default-value="EC_DEFAULT"/>  
<SPAN style="COLOR: #ff0000">
	<service service-name="getVisualThemeResources">
</SPAN>  
<field-map field-name="visualThemeId"/>  
<field-map field-name="themeResources" from-field="layoutSettings"/>  
</service>  
<set field="layoutSettings" from-field="themeResources" default-value="${layoutSettings}" global="true"/>  
<set field="headerTemplateLocation" from-field="layoutSettings.VT_HDR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/header.ftl"/>  
<set field="footerTemplateLocation" from-field="layoutSettings.VT_FTR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/footer.ftl"/>  

<script location="component://ecommerce/widget/EcommerceSetup.groovy"/>

<!-- Get the store VisualTheme -->
<set field="visualThemeId" from-field="productStore.visualThemeId" default-value="EC_DEFAULT"/>
<service service-name="getVisualThemeResources">
	<field-map field-name="visualThemeId"/>
	<field-map field-name="themeResources" from-field="layoutSettings"/>
</service>
<set field="layoutSettings" from-field="themeResources" default-value="${layoutSettings}" global="true"/>
<set field="headerTemplateLocation" from-field="layoutSettings.VT_HDR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/header.ftl"/>
<set field="footerTemplateLocation" from-field="layoutSettings.VT_FTR_TMPLT_LOC[0]" default-value="component://ecommerce/webapp/ecommerce/includes/footer.ftl"/>


mini 语言实现的服务在ofbiz\framework\common\script\org\ofbiz\common\CommonServices.xml 中。

<simple-method method-name="<SPAN style="COLOR: #ff6600">getVisualThemeResources</SPAN>" short-description="Get visual theme resources" login-required="false">  
       <set field="visualThemeId" from-field="parameters.visualThemeId"/>  
       <set field="themeResources" from-field="parameters.themeResources"/>  
       <entity-condition list="resourceList" entity-name="VisualThemeResource" use-cache="true">  
           <condition-expr field-name="visualThemeId" from-field="visualThemeId"/>  
           <order-by field-name="resourceTypeEnumId"/>  
           <order-by field-name="sequenceId"/>  
       </entity-condition>  
       <if-empty field="resourceList">  
           <!-- if not found use the good old initial ofbiz theme so the system will at least start up and will be usable -->  
           <log level="error" message="Could not find the '${visualThemeId}' theme, reverting back to the good old OFBiz theme..."></log>  
           <entity-condition list="resourceList" entity-name="VisualThemeResource" use-cache="true">  
               <condition-expr field-name="visualThemeId" value="FLAT_GREY"/>  
               <order-by field-name="resourceTypeEnumId"/>  
               <order-by field-name="sequenceId"/>  
           </entity-condition>  
       </if-empty>  
       <if-empty field="resourceList">  
           <add-error><fail-property property="CommonVisualThemeResourcesNotFound" resource="CommonUiLabels"/></add-error>  
           <check-errors/>  
       </if-empty>  
       <iterate list="resourceList" entry="resourceRecord">  
           <set field="resourceTypeEnumId" from-field="resourceRecord.resourceTypeEnumId"/>  
           <set field="resourceValue" from-field="resourceRecord.resourceValue"/>  
           <if-empty field="resourceValue">  
               <property-to-field field="warningMsg" property="CommonVisualThemeInvalidRecord" resource="CommonUiLabels"/>  
               <log level="warning" message="${warningMsg}"/>  
               <else>  
                   <set field="themeResources[resourceTypeEnumId][]" from-field="resourceValue"/>  
               </else>  
           </if-empty>  
       </iterate>  
       <field-to-result field="themeResources"/>  
   </simple-method>  


收藏备查,转载自:http://blog.csdn.net/kl323/article/details/7365521

posted on 2012-10-25 16:11  把酒言欢  阅读(2800)  评论(0编辑  收藏  举报