svn commit: r586349 - in /ofbiz/trunk/framework/example: config/ExampleUiLabels.properties webapp/example/WEB-INF/controller.xml widget/example/ExampleMenus.xml widget/example/FormWidgetExampleForms.xml widget/example/FormWidgetExampleScreens.xml

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r586349 - in /ofbiz/trunk/framework/example: config/ExampleUiLabels.properties webapp/example/WEB-INF/controller.xml widget/example/ExampleMenus.xml widget/example/FormWidgetExampleForms.xml widget/example/FormWidgetExampleScreens.xml

jacopoc
Author: jacopoc
Date: Fri Oct 19 02:39:51 2007
New Revision: 586349

URL: http://svn.apache.org/viewvc?rev=586349&view=rev
Log:
Added new screen and form to the Example application as a proof of concept for a way to create a library of tricks and best practices for form widget definitions; the Example application could then be used as a repository of easily accessible examples for widgets. In this example I've started to document some useful ways to use the drop-down fields.
What do you think? I did this change using the CTR (commit-then-review) policy: if you don't like this idea I will immediately revert.

Added:
    ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml
    ofbiz/trunk/framework/example/widget/example/FormWidgetExampleScreens.xml
Modified:
    ofbiz/trunk/framework/example/config/ExampleUiLabels.properties
    ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml
    ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml

Modified: ofbiz/trunk/framework/example/config/ExampleUiLabels.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/config/ExampleUiLabels.properties?rev=586349&r1=586348&r2=586349&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/config/ExampleUiLabels.properties (original)
+++ ofbiz/trunk/framework/example/config/ExampleUiLabels.properties Fri Oct 19 02:39:51 2007
@@ -34,6 +34,7 @@
 ExampleExampleFeature=Example Feature
 ExampleExampleFeatureId=Example Feature ID
 ExampleExplicitOption=Explicit Option
+ExampleFormWidgetExamples=Form Widget Examples
 ExampleMainPage=Example Main Page
 ExampleMessage=For something interesting make sure you are logged in, try username:admin, password:ofbiz.
 ExampleNewExample=New Example
@@ -46,6 +47,7 @@
 ExampleWelcome=Welcome to the Example application!
 
 PageTitleFindExample=Find Example
+PageTitleFormWidgetExamples=Form Widget Examples
 PageTitleEditExample=Edit Example
 PageTitleEditExampleItems=Edit Example Items
 PageTitleEditExampleFeatureAppls=Edit Example Features

Modified: ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml?rev=586349&r1=586348&r2=586349&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml (original)
+++ ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml Fri Oct 19 02:39:51 2007
@@ -142,7 +142,9 @@
         <response name="success" type="view" value="EditExampleFeatureExampleAppls"/>
         <response name="error" type="view" value="EditExampleFeatureExampleAppls"/>
     </request-map>
-    
+
+    <request-map uri="FormWidgetExamples"><security https="true" auth="true"/><response name="success" type="view" value="FormWidgetExamples"/></request-map>
+
     <request-map uri="LookupExampleFeature"><security https="true" auth="true"/><response name="success" type="view" value="LookupExampleFeature"/></request-map>
     <!-- end of request mappings -->
 
@@ -157,6 +159,8 @@
     <view-map name="FindExampleFeature" type="screen" page="component://example/widget/example/ExampleFeatureScreens.xml#FindExampleFeature"/>
     <view-map name="EditExampleFeature" type="screen" page="component://example/widget/example/ExampleFeatureScreens.xml#EditExampleFeature"/>
     <view-map name="EditExampleFeatureExampleAppls" type="screen" page="component://example/widget/example/ExampleFeatureScreens.xml#EditExampleFeatureExampleAppls"/>
+
+    <view-map name="FormWidgetExamples" type="screen" page="component://example/widget/example/FormWidgetExampleScreens.xml#FormWidgetExamples"/>
 
     <view-map name="LookupExampleFeature" type="screen" page="component://example/widget/example/ExampleFeatureScreens.xml#LookupExampleFeature"/>
     <!-- end of view mappings -->

Modified: ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml?rev=586349&r1=586348&r2=586349&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml (original)
+++ ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml Fri Oct 19 02:39:51 2007
@@ -26,6 +26,7 @@
         <menu-item name="main" title="${uiLabelMap.CommonMain}"><link target="main"/></menu-item>
         <menu-item name="Example" title="${uiLabelMap.ExampleExample}"><link target="FindExample"/></menu-item>
         <menu-item name="ExampleFeature" title="${uiLabelMap.ExampleFeature}"><link target="FindExampleFeature"/></menu-item>
+        <menu-item name="FormWidgetExamples" title="${uiLabelMap.ExampleFormWidgetExamples}"><link target="FormWidgetExamples"/></menu-item>
 
         <menu-item name="Logout" title="Logout" align-style="col-right" selected-style="selected">
             <condition><not><if-empty field-name="userLogin"/></not></condition>

Added: ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml?rev=586349&view=auto
==============================================================================
--- ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml (added)
+++ ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml Fri Oct 19 02:39:51 2007
@@ -0,0 +1,143 @@
+<?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.
+-->
+
+<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">
+    <form name="DropDownFieldsExampleForm" type="single" title="">
+        <field name="entityOptionsFields1" title="entity-options"><display description="All these fields retrieve the list of values from another entity by using the entity-options element." also-hidden="false"/></field>
+        <field name="entityOptionsFields2" title=""><display description="entity-options will look up options for the field in the given entity." also-hidden="false"/></field>
+        <field name="entityOptionsFields3" title=""><display description="The complete syntax is... TODO" also-hidden="false"/></field>
+        <!-- ***************** -->
+        <!-- ***   field1  *** -->
+        <!-- ***************** -->
+        <field name="field1"
+               title="Field1: optional"
+               tooltip="This is an example of a drop-down field with allow-empty set to true: as you can see, an empty entry is automatically added.">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="ExampleType"
+                                key-field-name="exampleTypeId"
+                                description="${description}">
+                    <entity-order-by field-name="description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <!-- ***************** -->
+        <!-- ***   field2  *** -->
+        <!-- ***************** -->
+        <field name="field2"
+               title="Field2: mandatory"
+               tooltip="The same as above, but here allow-empty is set to false (the default, if not specified): as you can see, there is no empty selection.">
+            <drop-down allow-empty="false"> <!-- allow-empty="false" is also the default value, so you can also not specify this attribute here -->
+                <entity-options entity-name="ExampleType"
+                                key-field-name="exampleTypeId"
+                                description="${description}">
+                    <entity-order-by field-name="description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <!-- ***************** -->
+        <!-- ***   field3  *** -->
+        <!-- ***************** -->
+        <field name="field3"
+               title="Field3: sort in descending order"
+               tooltip="TODO">
+            <drop-down>
+                <entity-options entity-name="ExampleType"
+                                key-field-name="exampleTypeId"
+                                description="${description}">
+                    <entity-order-by field-name="-description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <!-- ***************** -->
+        <!-- ***   field4  *** -->
+        <!-- ***************** -->
+        <field name="field4"
+               title="Field4: combined description"
+               tooltip="TODO">
+            <drop-down>
+                <entity-options entity-name="ExampleType"
+                                key-field-name="exampleTypeId"
+                                description="${exampleTypeId} - ${description}">
+                    <entity-order-by field-name="description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <!-- ***************** -->
+        <!-- ***   field5  *** -->
+        <!-- ***************** -->
+        <field name="field5"
+               title="Field5: selection of a default value from the list"
+               tooltip="TODO">
+            <drop-down no-current-selected-key="INSPIRED">
+                <entity-options entity-name="ExampleType"
+                                key-field-name="exampleTypeId"
+                                description="${description}">
+                    <entity-order-by field-name="description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <!-- ***************** -->
+        <!-- ***   field6  *** -->
+        <!-- ***************** -->
+        <field name="exampleTypeId"
+               title="Field6 (exampleTypeId): shortest notation"
+               tooltip="TODO">
+            <drop-down>
+                <entity-options entity-name="ExampleType"
+                                description="${description}"/>
+            </drop-down>
+        </field>
+        <!-- ***************** -->
+        <!-- ***   field7  *** -->
+        <!-- ***************** -->
+        <field name="field7"
+               title="Field7: additional constraint"
+               tooltip="TODO">
+            <drop-down>
+                <entity-options entity-name="ExampleType"
+                                key-field-name="exampleTypeId"
+                                description="${description}">
+                    <entity-constraint name="exampleTypeId"
+                                       value="INSPIRED"
+                                       operator="greater"/>
+                    <entity-order-by field-name="description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+        <!-- ***************** -->
+        <!-- ***   field8  *** -->
+        <!-- ***************** -->
+        <field name="field8"
+               title="Field8: Javascript event"
+               event="onChange"
+               action="return alert('You have changed the value in the select box');"
+               tooltip="TODO">
+            <drop-down allow-empty="true">
+                <entity-options entity-name="ExampleType"
+                                key-field-name="exampleTypeId"
+                                description="${description}">
+                    <entity-order-by field-name="description"/>
+                </entity-options>
+            </drop-down>
+        </field>
+    </form>
+
+</forms>

Added: ofbiz/trunk/framework/example/widget/example/FormWidgetExampleScreens.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/FormWidgetExampleScreens.xml?rev=586349&view=auto
==============================================================================
--- ofbiz/trunk/framework/example/widget/example/FormWidgetExampleScreens.xml (added)
+++ ofbiz/trunk/framework/example/widget/example/FormWidgetExampleScreens.xml Fri Oct 19 02:39:51 2007
@@ -0,0 +1,56 @@
+<?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.
+-->
+
+<screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+        xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
+    <screen name="FormWidgetExamples">
+        <section>
+            <actions>
+                <set field="headerItem" value="FormWidgetExamples"/>
+                <set field="titleProperty" value="PageTitleFormWidgetExamples"/>
+            </actions>
+            <widgets>
+                <decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
+                    <decorator-section name="body">
+                        <section>
+                            <condition>
+                                <if-has-permission permission="EXAMPLE" action="_VIEW"/>
+                            </condition>
+                            <widgets>
+                                <container><label style="head1">${uiLabelMap.${titleProperty}}</label></container>
+                                <container><label style="head2">Drop down fields</label></container>
+                                <container>
+                                    <label style="head3">Source Code</label>
+                                    <label> - see the form definition with name &quot;DropDownFieldsExampleForm&quot; in the file: </label>
+                                    <link target="http://svn.apache.org/repos/asf/ofbiz/trunk/framework/example/widget/example/FormWidgetExampleForms.xml" url-mode="plain" target-window="svnPage" text="framework/example/widget/example/FormWidgetExampleForms.xml" style="buttontext"/>
+                                </container>
+
+                                <include-form name="DropDownFieldsExampleForm" location="component://example/widget/example/FormWidgetExampleForms.xml"/>
+                            </widgets>
+                            <fail-widgets>
+                                <label style="head3">${uiLabelMap.ExampleViewPermissionError}</label>
+                            </fail-widgets>
+                        </section>
+                    </decorator-section>
+                </decorator-screen>
+            </widgets>
+        </section>
+    </screen>
+</screens>