Author: jaz
Date: Thu Apr 3 11:03:53 2008 New Revision: 644429 URL: http://svn.apache.org/viewvc?rev=644429&view=rev Log: added a simple example of using prototype (ajax) with screens Added: ofbiz/trunk/framework/example/webapp/example/ajax/ ofbiz/trunk/framework/example/webapp/example/ajax/createExampleAjax.ftl ofbiz/trunk/framework/example/webapp/example/ajax/listExamplesAjax.ftl ofbiz/trunk/framework/example/widget/example/ExampleAjaxScreens.xml Modified: ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml 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=644429&r1=644428&r2=644429&view=diff ============================================================================== --- ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml (original) +++ ofbiz/trunk/framework/example/webapp/example/WEB-INF/controller.xml Thu Apr 3 11:03:53 2008 @@ -163,5 +163,11 @@ <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"/> + + <!-- ajax view mappings --> + <view-map name="findExampleAjax" type="screen" page="component://example/widget/example/ExampleAjaxScreens.xml#AjaxExample"/> + <view-map name="listExamples" type="screen" page="component://example/widget/example/ExampleAjaxScreens.xml#listExamples"/> + <view-map name="createExampleForm" type="screen" page="component://example/widget/example/ExampleAjaxScreens.xml#createScreenForm"/> + <!-- end of view mappings --> </site-conf> Added: ofbiz/trunk/framework/example/webapp/example/ajax/createExampleAjax.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/webapp/example/ajax/createExampleAjax.ftl?rev=644429&view=auto ============================================================================== --- ofbiz/trunk/framework/example/webapp/example/ajax/createExampleAjax.ftl (added) +++ ofbiz/trunk/framework/example/webapp/example/ajax/createExampleAjax.ftl Thu Apr 3 11:03:53 2008 @@ -0,0 +1,110 @@ +<#-- +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. +--> + +<script type="text/javascript"> + function submitForm(form) { + submitFormDisableSubmits(form); + new Ajax.Request(form.action, { parameters: form.serialize(true) }); + new Ajax.Updater('create-form', '<@ofbizUrl>/authview/createExampleForm</@ofbizUrl>'); + } +</script> +<form id="createForm" method="post" action="<@ofbizUrl>createExample</@ofbizUrl>" class="basic-form" + onSubmit="javascript:submitFormDisableSubmits(this)" name="EditExample"> + <table cellspacing="0"> + <tr> + <td class="label">Type</td> + <td> + <select name="exampleTypeId" size="1"> + <#list types as type> + <option value="${type.exampleTypeId}">${type.description}</option> + </#list> + </select> + </td> + </tr> + <tr> + <td class="label">Status</td> + <td> + <select name="statusId" size="1"> + <#list statusItems as statusItem> + <option value="${statusItem.statusId}">${statusItem.description}</option> + </#list> + </select> + </td> + </tr> + <tr> + <td class="label">Example Name</td> + <td><input type="text" name="exampleName" size="40" maxlength="60" autocomplete="off"/></td> + </tr> + <tr> + <td class="label">Description</td> + <td><input type="text" name="description" size="60" maxlength="250" autocomplete="off"/></td> + </tr> + <tr> + <td class="label">Long Description</td> + <td><textarea name="longDescription" cols="60" rows="2"></textarea></td> + </tr> + <tr> + <td class="label">Comments</td> + <td><input type="text" name="comments" size="60" maxlength="250" autocomplete="off"/></td> + </tr> + <tr> + <td class="label">Example Size</td> + <td><input type="text" name="exampleSize" size="6" autocomplete="off"/></td> + </tr> + <tr> + <td class="label">Example Date</td> + <td><input type="text" name="exampleDate" title="Format: yyyy-MM-dd HH:mm:ss.SSS" size="25" maxlength="30"/><a + href="javascript:call_cal(document.EditExample.exampleDate,'2008-04-03%2010:29:25.526');"><img + src="/images/cal.gif" width="16" height="16" border="0" alt="View Calendar" title="View Calendar"/></a> + </td> + </tr> + <tr> + <td class="label">Another Date</td> + <td><input type="text" name="anotherDate" title="Format: yyyy-MM-dd HH:mm:ss.SSS" size="25" maxlength="30"/><a + href="javascript:call_cal(document.EditExample.anotherDate,'2008-04-03%2010:29:25.526');"><img + src="/images/cal.gif" width="16" height="16" border="0" alt="View Calendar" title="View Calendar"/></a> + </td> + </tr> + <tr> + <td class="label">Another Text</td> + <td><select name="anotherText" size="1"> + <option value=""> </option> + <option value="Explicit Option">Explicit Option</option> + <option value="Configurable Good">Configurable Good</option> + <option value="Configurable Good Configuration">Configurable Good Configuration</option> + <option value="Digital Good">Digital Good</option> + <option value="Finished Good">Finished Good</option> + <option value="Finished/Digital Good">Finished/Digital Good</option> + <option value="Fixed Asset Usage">Fixed Asset Usage</option> + <option value="Good">Good</option> + <option value="Marketing Package: Auto Manufactured">Marketing Package</option> + <option value="Marketing Package: Pick Assembly">Marketing Package: Pick Assembly</option> + <option value="Raw Material">Raw Material</option> + <option value="Service">Service</option> + <option value="Subassembly">Subassembly</option> + <option value="Work In Process">Work In Process</option> + </select></td> + </tr> + <tr> + <td class="label"> </td> + <td colspan="4"><input type="button" name="submitButton" value="Create" onclick="javascript:submitForm($('createForm'));"/></td> + </tr> + </table> +</form> + Added: ofbiz/trunk/framework/example/webapp/example/ajax/listExamplesAjax.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/webapp/example/ajax/listExamplesAjax.ftl?rev=644429&view=auto ============================================================================== --- ofbiz/trunk/framework/example/webapp/example/ajax/listExamplesAjax.ftl (added) +++ ofbiz/trunk/framework/example/webapp/example/ajax/listExamplesAjax.ftl Thu Apr 3 11:03:53 2008 @@ -0,0 +1,44 @@ +<#-- +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. +--> + + <script type="text/javascript"> + new Ajax.PeriodicalUpdater('example-list', '<@ofbizUrl>/authview/listExamples</@ofbizUrl>'); + </script> + <table cellspacing="0" class="basic-table form-widget-table dark-grid"> + <tr class="header-row"> + <td>Example ID</td> + <td>Name</td> + <td>Type</td> + <td>Status</td> + <td>Description</td> + </tr> + <#list examples as example> + <#assign type = (example.getRelatedOne("ExampleType"))?if_exists/> + <#assign status = (example.getRelatedOne("StatusItem"))?if_exists/> + <tr> + <td><a class="buttontext" href="<@ofbizUrl>EditExample?exampleId=${example.exampleId}</@ofbizUrl>">${example.exampleId}</a></td> + <td>${example.exampleName?if_exists}</td> + <td>${(type.description)?if_exists}</td> + <td>${(status.description)?if_exists}</td> + <td>${example.description?if_exists}</td> + </tr> + </#list> + </table> + +<br/> \ No newline at end of file Added: ofbiz/trunk/framework/example/widget/example/ExampleAjaxScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/ExampleAjaxScreens.xml?rev=644429&view=auto ============================================================================== --- ofbiz/trunk/framework/example/widget/example/ExampleAjaxScreens.xml (added) +++ ofbiz/trunk/framework/example/widget/example/ExampleAjaxScreens.xml Thu Apr 3 11:03:53 2008 @@ -0,0 +1,89 @@ +<?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="AjaxExample"> + <section> + <actions> + <set field="headerItem" value="Example"/> + <set field="titleProperty" value="PageTitleFindExample"/> + + <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/validation.js" global="true"/> + <set field="layoutSettings.javaScripts[+0]" value="/images/prototypejs/prototype.js" global="true"/> + </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="h1">${uiLabelMap.${titleProperty}}</label></container> + <container id="example-list"> + <include-screen name="listExamples"/> + </container> + <container/> + <container id="create-form"> + <include-screen name="createScreenForm"/> + </container> + </widgets> + <fail-widgets> + <label style="h3">${uiLabelMap.ExampleViewPermissionError}</label> + </fail-widgets> + </section> + </decorator-section> + </decorator-screen> + </widgets> + </section> + </screen> + + <screen name="listExamples"> + <section> + <actions> + <entity-condition entity-name="Example" list-name="examples"/> + </actions> + <widgets> + <container id="list-example-table"> + <platform-specific><html><html-template location="component://example/webapp/example/ajax/listExamplesAjax.ftl"/></html></platform-specific> + </container> + </widgets> + </section> + </screen> + + <screen name="createScreenForm"> + <section> + <actions> + <entity-condition entity-name="ExampleType" list-name="types"/> + <entity-condition entity-name="StatusItem" list-name="statusItems"> + <condition-expr field-name="statusTypeId" operator="equals" value="EXAMPLE_STATUS"/> + <order-by field-name="sequenceId"/> + </entity-condition> + </actions> + <widgets> + <container id="create-example-form"> + <platform-specific><html><html-template location="component://example/webapp/example/ajax/createExampleAjax.ftl"/></html></platform-specific> + </container> + </widgets> + </section> + </screen> +</screens> \ No newline at end of file |
Free forum by Nabble | Edit this page |