Improved screen widget Ajax support.
The original Ajax work was a great start, but there were limitations. These changes open things up a bit: 1) Ajax rendering falls back to plain HTML when the user has JavaScript disabled. 2) You can have more than one area updated during an event. IE7 updates only <div> elements, so be aware of that when using the Ajax feature. See the Example component for a demonstration. git-svn-id: https://svn.apache.org/repos/asf/ofbiz/trunk@658281 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
@@ -26,7 +26,6 @@ under the License.
|
||||
<actions>
|
||||
<set field="headerItem" value="AjaxExample"/>
|
||||
<set field="titleProperty" value="PageTitleFindExample"/>
|
||||
<set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/prototype.js" global="true"/>
|
||||
</actions>
|
||||
<widgets>
|
||||
<decorator-screen name="main-decorator" location="${parameters.mainDecoratorLocation}">
|
||||
@@ -37,11 +36,22 @@ under the License.
|
||||
</condition>
|
||||
<widgets>
|
||||
<container style="h1"><label>${uiLabelMap.${titleProperty}}</label></container>
|
||||
<container id="ListExamplesAutoUpdate" auto-update-target="ListExampleFormOnly">
|
||||
<section>
|
||||
<condition>
|
||||
<if-compare field-name="javaScriptEnabled" value="true" operator="equals"/>
|
||||
</condition>
|
||||
<widgets/>
|
||||
<fail-widgets>
|
||||
<container style="button-bar"><label>${uiLabelMap.ExampleAjaxIntro}</label></container>
|
||||
</fail-widgets>
|
||||
</section>
|
||||
<container id="ListExamplesAjax">
|
||||
<include-screen name="ListExampleFormOnly"/>
|
||||
</container>
|
||||
<container style="h2"><label>${uiLabelMap.ExampleNewExample}</label></container>
|
||||
<include-screen name="CreateExampleFormOnly"/>
|
||||
<container id="EditExampleAjax">
|
||||
<include-screen name="CreateExampleFormOnly"/>
|
||||
</container>
|
||||
</widgets>
|
||||
<fail-widgets>
|
||||
<label style="h3">${uiLabelMap.ExampleViewPermissionError}</label>
|
||||
@@ -55,21 +65,29 @@ under the License.
|
||||
|
||||
<screen name="ListExampleFormOnly">
|
||||
<section>
|
||||
<condition>
|
||||
<if-has-permission permission="EXAMPLE" action="_VIEW"/>
|
||||
</condition>
|
||||
<actions>
|
||||
<!-- NOTE: these are needed because this may be run as a top level screen and would have no decorator -->
|
||||
<property-map resource="ExampleUiLabels" map-name="uiLabelMap" global="true"/>
|
||||
<property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
|
||||
</actions>
|
||||
<widgets>
|
||||
<include-form name="ListExamples" location="component://example/widget/example/ExampleForms.xml"/>
|
||||
<include-form name="ListExamplesAjax" location="component://example/widget/example/ExampleForms.xml"/>
|
||||
</widgets>
|
||||
</section>
|
||||
</screen>
|
||||
|
||||
<screen name="CreateExampleFormOnly">
|
||||
<section>
|
||||
<condition>
|
||||
<if-has-permission permission="EXAMPLE" action="_VIEW"/>
|
||||
</condition>
|
||||
<actions>
|
||||
<!-- these are only needed so that when bsh evaluates use-when attributes these will exist and not cause an error -->
|
||||
<property-map resource="ExampleUiLabels" map-name="uiLabelMap" global="true"/>
|
||||
<property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>
|
||||
<set field="exampleId" from-field="parameters.exampleId"/>
|
||||
<entity-one entity-name="Example" value-name="example"/>
|
||||
</actions>
|
||||
|
||||
@@ -34,6 +34,12 @@ under the License.
|
||||
<field name="description" title="${uiLabelMap.CommonDescription}"><display/></field>
|
||||
</form>
|
||||
|
||||
<!-- Typically, this extended form wouldn't be necessary. The parent form (ListExamples) would
|
||||
have these attributes. -->
|
||||
<form name="ListExamplesAjax" extends="ListExamples" type="list" paginate-target="authview/findExampleAjax" view-size="3">
|
||||
<on-event-update-area event-type="paginate" area-id="ListExamplesAjax" area-target="ListExampleFormOnly"/>
|
||||
</form>
|
||||
|
||||
<form name="EditExample" type="single" target="updateExample" title="" default-map-name="example">
|
||||
<actions>
|
||||
<entity-one entity-name="StatusItem" value-name="currentStatus" auto-field-map="false">
|
||||
@@ -84,9 +90,12 @@ under the License.
|
||||
<field name="submitButton" use-when="example!=null" title="${uiLabelMap.CommonUpdate}"><submit button-type="button"/></field>
|
||||
</form>
|
||||
|
||||
<form name="EditExampleBackgroundSubmit" extends="EditExample">
|
||||
<field name="submitButton" use-when="example==null" title="${uiLabelMap.CommonCreate}"><submit button-type="button" background-submit-refresh-target="CreateExampleFormOnly"/></field>
|
||||
<field name="submitButton" use-when="example!=null" title="${uiLabelMap.CommonUpdate}"><submit button-type="button" background-submit-refresh-target="CreateExampleFormOnly"/></field>
|
||||
<!-- Typically, this extended form wouldn't be necessary. The parent form (EditExample) would
|
||||
have these settings. -->
|
||||
<form name="EditExampleBackgroundSubmit" type="single" extends="EditExample" target="updateExampleAjax">
|
||||
<alt-target use-when="example==null" target="createExampleAjax"/>
|
||||
<on-event-update-area event-type="submit" area-id="ListExamplesAjax" area-target="ListExampleFormOnly"/>
|
||||
<on-event-update-area event-type="submit" area-id="EditExampleAjax" area-target="CreateExampleFormOnly"/>
|
||||
</form>
|
||||
|
||||
<!-- ExampleItem -->
|
||||
|
||||
Reference in New Issue
Block a user