Files
ofbiz-framework/specialpurpose/example/widget/example/ExampleCompoundWidgets.xml
T
Jacques Le Roux 3aadf4e8da A slightly modified patch from James Yong for "Autocompletion for Compound Widget" https://issues.apache.org/jira/browse/OFBIZ-7061
1. The following xsd are duplicated to use namespaces
  site-conf.xsd     ->  site-conf-ns.xsd
  widget-form.xsd   ->  widget-form-ns.xsd
  widget-screen.xsd ->  widget-screen-ns.xsd
  widget-menu.xsd   ->  widget-menu-ns.xsd
  simple-methods.xsd->  simple-methods-ns.xsd
For example, in site-conf-ns.xsd, we have the following document level attribute
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" xmlns="http://ofbiz.apache.org/Site-Conf" targetNamespace="http://ofbiz.apache.org/Site-Conf">
instead of 
  <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">

2. The above schema are used into compound-widgets.xsd so that compound widgets use only one consolidated schema. 

3. Update ExampleCompoundWidgets.xml to use the new compound-widgets.xsd. For example
<compound-widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xmlns:sc="http://ofbiz.apache.org/Site-Conf"
        xmlns:sm="http://ofbiz.apache.org/Simple-Method"
        xmlns:wf="http://ofbiz.apache.org/Widget-Form"
        xmlns:wt="http://ofbiz.apache.org/Widget-Tree"
        xmlns:wm="http://ofbiz.apache.org/Widget-Menu"
        xmlns:ws="http://ofbiz.apache.org/Widget-Screen"
        xsi:noNamespaceSchemaLocation="../../../../framework/widget/dtd/compound-widgets.xsd">
    
    <sc:site-conf>
        <sc:request-map uri="CompoundWidgets1">
            <sc:security https="true" auth="true"/>
            <sc:event type="simple" invoke="CompoundWidgetsFunc" path="component://example/widget/example/ExampleCompoundWidgets.xml"/>
            <sc:response name="success" type="view" value="CompoundWidgets1"/>
        </sc:request-map>
        <sc:request-map uri="CompoundWidgets2"><sc:security https="true" auth="true"/><sc:response name="success" type="view" value="CompoundWidgets2"/></sc:request-map>

        <sc:view-map name="CompoundWidgets1" type="screen" page="component://example/widget/example/ExampleCompoundWidgets.xml#CompoundWidgets1"/>
        <sc:view-map name="CompoundWidgets2" type="screen" page="component://example/widget/example/ExampleCompoundWidgets.xml#CompoundWidgets2"/>
    </sc:site-conf>
...... the rest

4. Change java code to support reading xml with namespace (i.e. xml for compound widgets)

jleroux: I simply replaced tabs by spaces in Java files and removed this commented out line 
  <compound-widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/compound-widgets.xsd">
in ExampleCompoundWidgets.xml

We decided to duplicate the simple-methods.xsd rather than updating all concerned files. Else we would have to update the attributes at document level for rest of the controllers, menus, forms, simple methods and screens. For example, in controller.xml, we would have to change 
  xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd”
to 
  xmlns="http://ofbiz.apache.org/sc” xsi:schemaLocation="http://ofbiz.apache.org/dtds/site-conf-ns.xsd”>
But especially we would have to use the same syntax with namespaces prefixes than in ExampleCompoundWidgets.xml (see example above). This can be discussed because with auto-completion it's not a big deal, but could be overwhelming for existing custom projects...

James mentionned that "the schema location at compound-widgets.xsd is relative to the project...". I don't see any problems with that. We can keep as is as long as we maintain the relation (ie if the main XSDs are moved). Moreover with the previous addition of compound-widgets.xsd in widget-catalog.xml it seems all things work correctly (eg w/o the new *-ns.xsd yet committed, the auto-completion works well in ExampleCompoundWidgets.xml




git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@1746302 13f79535-47bb-0310-9956-ffa450edef68
2016-05-31 16:48:09 +00:00

122 lines
6.1 KiB
XML

<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<!-- This document serves as an example for Compound Screen Widget feature -->
<compound-widgets xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:sc="http://ofbiz.apache.org/Site-Conf"
xmlns:sm="http://ofbiz.apache.org/Simple-Method"
xmlns:wf="http://ofbiz.apache.org/Widget-Form"
xmlns:wt="http://ofbiz.apache.org/Widget-Tree"
xmlns:wm="http://ofbiz.apache.org/Widget-Menu"
xmlns:ws="http://ofbiz.apache.org/Widget-Screen"
xsi:noNamespaceSchemaLocation="../../../../framework/widget/dtd/compound-widgets.xsd">
<sc:site-conf>
<sc:request-map uri="CompoundWidgets1">
<sc:security https="true" auth="true"/>
<sc:event type="simple" invoke="CompoundWidgetsFunc" path="component://example/widget/example/ExampleCompoundWidgets.xml"/>
<sc:response name="success" type="view" value="CompoundWidgets1"/>
</sc:request-map>
<sc:request-map uri="CompoundWidgets2"><sc:security https="true" auth="true"/><sc:response name="success" type="view" value="CompoundWidgets2"/></sc:request-map>
<sc:view-map name="CompoundWidgets1" type="screen" page="component://example/widget/example/ExampleCompoundWidgets.xml#CompoundWidgets1"/>
<sc:view-map name="CompoundWidgets2" type="screen" page="component://example/widget/example/ExampleCompoundWidgets.xml#CompoundWidgets2"/>
</sc:site-conf>
<wm:menus>
<wm:menu name="CompoundWidgetsMenu" extends="CommonTabBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
<wm:menu-item name="Example1" title="${uiLabelMap.ExampleExample} 1">
<wm:link target="CompoundWidgets1"/>
</wm:menu-item>
<wm:menu-item name="Example2" title="${uiLabelMap.ExampleExample} 2">
<wm:link target="CompoundWidgets2"/>
</wm:menu-item>
</wm:menu>
</wm:menus>
<ws:screens>
<ws:screen name="CompoundWidgets1">
<ws:section>
<ws:actions>
<ws:set field="headerItem" value="ExampleCompoundWidgets" />
<ws:set field="tabButtonItem" value="Example1"/>
</ws:actions>
<ws:widgets>
<ws:decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
<ws:decorator-section name="pre-body">
<ws:include-menu name="CompoundWidgetsMenu" location="component://example/widget/example/ExampleCompoundWidgets.xml" />
</ws:decorator-section>
<ws:decorator-section name="body">
<ws:section>
<ws:widgets>
<ws:container style="clear" />
<ws:label>Demo For Compound Screen Widget</ws:label>
<ws:include-form location="component://example/widget/example/ExampleCompoundWidgets.xml" name="CompoundWidgetsForm1"/>
</ws:widgets>
</ws:section>
</ws:decorator-section>
</ws:decorator-screen>
</ws:widgets>
</ws:section>
</ws:screen>
<ws:screen name="CompoundWidgets2">
<ws:section>
<ws:actions>
<ws:set field="headerItem" value="ExampleCompoundWidgets" />
<ws:set field="tabButtonItem" value="Example2"/>
</ws:actions>
<ws:widgets>
<ws:decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
<ws:decorator-section name="pre-body">
<ws:include-menu name="CompoundWidgetsMenu" location="component://example/widget/example/ExampleCompoundWidgets.xml" />
</ws:decorator-section>
<ws:decorator-section name="body">
<ws:section>
<ws:widgets>
<ws:container style="clear" />
<ws:label>Demo For Compound Screen Widget</ws:label>
<ws:include-form location="component://example/widget/example/ExampleCompoundWidgets.xml" name="CompoundWidgetsForm2"/>
</ws:widgets>
</ws:section>
</ws:decorator-section>
</ws:decorator-screen>
</ws:widgets>
</ws:section>
</ws:screen>
</ws:screens>
<wf:forms>
<wf:form name="CompoundWidgetsForm1">
<wf:field name="exampleName" title="${uiLabelMap.FormFieldTitle_exampleName} 1" required-field="true"><wf:text /></wf:field>
</wf:form>
<wf:form name="CompoundWidgetsForm2">
<wf:field name="exampleName" title="${uiLabelMap.FormFieldTitle_exampleName} 2" required-field="true"><wf:text /></wf:field>
</wf:form>
</wf:forms>
<sm:simple-methods>
<sm:simple-method method-name="CompoundWidgetsFunc">
<sm:log message="CompoundWidgetsFunc runs" sm:level="info"/>
</sm:simple-method>
</sm:simple-methods>
</compound-widgets>