diff --git a/framework/example/webapp/example/WEB-INF/controller.xml b/framework/example/webapp/example/WEB-INF/controller.xml index b1b82e3463..c300e8b44d 100644 --- a/framework/example/webapp/example/WEB-INF/controller.xml +++ b/framework/example/webapp/example/WEB-INF/controller.xml @@ -146,6 +146,9 @@ under the License. + + + @@ -166,8 +169,8 @@ under the License. - - + + diff --git a/framework/example/webapp/example/ajax/createExampleAjax.ftl b/framework/example/webapp/example/ajax/createExampleAjax.ftl deleted file mode 100644 index 428e70ff31..0000000000 --- a/framework/example/webapp/example/ajax/createExampleAjax.ftl +++ /dev/null @@ -1,110 +0,0 @@ -<#-- -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. ---> - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Type - -
Status - -
Example Name
Description
Long Description
Comments
Example Size
Example DateView Calendar -
Another DateView Calendar -
Another Text
 
-
- diff --git a/framework/example/webapp/example/ajax/listExamplesAjax.ftl b/framework/example/webapp/example/ajax/listExamplesAjax.ftl deleted file mode 100644 index 9f91f73ebc..0000000000 --- a/framework/example/webapp/example/ajax/listExamplesAjax.ftl +++ /dev/null @@ -1,44 +0,0 @@ -<#-- -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. ---> - - - - - - - - - - - <#list examples as example> - <#assign type = (example.getRelatedOne("ExampleType"))?if_exists/> - <#assign status = (example.getRelatedOne("StatusItem"))?if_exists/> - - - - - - - - -
Example IDNameTypeStatusDescription
${example.exampleId}${example.exampleName?if_exists}${(type.description)?if_exists}${(status.description)?if_exists}${example.description?if_exists}
- -
\ No newline at end of file diff --git a/framework/example/widget/example/ExampleAjaxScreens.xml b/framework/example/widget/example/ExampleAjaxScreens.xml index 54230bf08f..42c940b279 100644 --- a/framework/example/widget/example/ExampleAjaxScreens.xml +++ b/framework/example/widget/example/ExampleAjaxScreens.xml @@ -27,7 +27,6 @@ under the License. - @@ -39,13 +38,10 @@ under the License. - - + + - - - - + @@ -57,33 +53,28 @@ under the License. - +
- + + + - - - +
- - +
- - - - - + + + - - - +
- \ No newline at end of file + diff --git a/framework/example/widget/example/ExampleForms.xml b/framework/example/widget/example/ExampleForms.xml index 8b715da3ac..ef6b80b9e8 100644 --- a/framework/example/widget/example/ExampleForms.xml +++ b/framework/example/widget/example/ExampleForms.xml @@ -20,10 +20,9 @@ under the License. -
+ - + @@ -34,6 +33,7 @@ under the License. +
@@ -88,6 +88,10 @@ under the License. +
+ + +
diff --git a/framework/images/webapp/images/selectall.js b/framework/images/webapp/images/selectall.js index 7fb351c802..77a948549b 100644 --- a/framework/images/webapp/images/selectall.js +++ b/framework/images/webapp/images/selectall.js @@ -208,6 +208,17 @@ function confirmActionFormLink(msg, formName) { } } +// NOTE: REQUIRES prototype.js +// On the form element make sure you have something like: +// id="theFormId" +// On the submit button elements make sure you have something like: +// onclick="javascript:submitAjaxForm($('theFormId'), 'id-of-div-surrounding-or-on-form', '<@ofbizUrl>createExampleForm');" +function submitFormInBackground(form, areaName, submitUrl) { + submitFormDisableSubmits(form); + new Ajax.Request(form.action, { parameters: form.serialize(true) }); + new Ajax.Updater(areaName, submitUrl); +} + function submitFormDisableSubmits(form) { for (var i=0;i - + + The form type is always required unless you are extending another form. @@ -793,6 +794,9 @@ under the License. + + This will submit the form in the background and refresh just this form and not the rest of the page. Note that the button-type must be button. + diff --git a/framework/widget/dtd/widget-screen.xsd b/framework/widget/dtd/widget-screen.xsd index e049f36787..9a643e84a1 100644 --- a/framework/widget/dtd/widget-screen.xsd +++ b/framework/widget/dtd/widget-screen.xsd @@ -754,6 +754,7 @@ under the License. + diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java index 34584b1fac..88a515b661 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelForm.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelForm.java @@ -1920,7 +1920,12 @@ public class ModelForm extends ModelWidget { * @return */ public String getContainerId() { - return this.containerId; + // use the name if there is no id + if (UtilValidate.isNotEmpty(this.containerId)) { + return this.containerId; + } else { + return this.getName(); + } } /** diff --git a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java index b88e85ce01..beb51aad1f 100644 --- a/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java +++ b/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java @@ -2726,6 +2726,7 @@ public class ModelFormField { public static class SubmitField extends FieldInfo { protected String buttonType; protected String imageLocation; + protected FlexibleStringExpander backgroundSubmitRefreshTargetExdr; protected SubmitField() { super(); @@ -2743,6 +2744,7 @@ public class ModelFormField { super(element, modelFormField); this.buttonType = element.getAttribute("button-type"); this.imageLocation = element.getAttribute("image-location"); + this.backgroundSubmitRefreshTargetExdr = new FlexibleStringExpander(element.getAttribute("background-submit-refresh-target")); } public void renderFieldString(StringBuffer buffer, Map context, FormStringRenderer formStringRenderer) { @@ -2776,6 +2778,10 @@ public class ModelFormField { public void setImageLocation(String string) { imageLocation = string; } + + public String getBackgroundSubmitRefreshTarget(Map context) { + return this.backgroundSubmitRefreshTargetExdr.expandString(context); + } } public static class ResetField extends FieldInfo { diff --git a/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java b/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java index 51f72c109c..b2fbe035b9 100644 --- a/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java @@ -823,7 +823,6 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe public void renderSubmitField(StringBuffer buffer, Map context, SubmitField submitField) { ModelFormField modelFormField = submitField.getModelFormField(); ModelForm modelForm = modelFormField.getModelForm(); - String singleClickAction = " onClick=\"javascript:submitFormDisableButton(this)\" "; String event = null; String action = null; @@ -867,15 +866,18 @@ public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRe buffer.append("=\""); buffer.append(action); buffer.append('"'); - } else { - // disabling for now, using form onSubmit action instead: buffer.append(singleClickAction); } buffer.append("/>"); } else { // default to "button" - buffer.append(""); } diff --git a/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java b/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java index ffad673225..0d9f3e1af6 100644 --- a/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java +++ b/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java @@ -91,6 +91,21 @@ public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStri public void renderContainerEnd(Writer writer, Map context, ModelScreenWidget.Container container) throws IOException { writer.write(""); appendWhitespace(writer); + String autoUpdateTarget = container.getAutoUpdateTargetExdr(context); + String containerId = container.getId(context); + if (UtilValidate.isNotEmpty(autoUpdateTarget) && UtilValidate.isNotEmpty(containerId)) { + HttpServletResponse response = (HttpServletResponse) context.get("response"); + HttpServletRequest request = (HttpServletRequest) context.get("request"); + ServletContext ctx = (ServletContext) request.getAttribute("servletContext"); + RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); + + writer.write(""); + appendWhitespace(writer); + } } public void renderScreenletBegin(Writer writer, Map context, boolean collapsed, ModelScreenWidget.Screenlet screenlet) throws IOException { diff --git a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java index 26d94c48fb..9550debacd 100644 --- a/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java +++ b/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java @@ -262,12 +262,14 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa public static class Container extends ModelScreenWidget { protected FlexibleStringExpander idExdr; protected FlexibleStringExpander styleExdr; + protected FlexibleStringExpander autoUpdateTargetExdr; protected List subWidgets; public Container(ModelScreen modelScreen, Element containerElement) { super(modelScreen, containerElement); this.idExdr = new FlexibleStringExpander(containerElement.getAttribute("id")); this.styleExdr = new FlexibleStringExpander(containerElement.getAttribute("style")); + this.autoUpdateTargetExdr = new FlexibleStringExpander(containerElement.getAttribute("auto-update-target")); // read sub-widgets List subElementList = UtilXml.childElementList(containerElement); @@ -297,8 +299,12 @@ public abstract class ModelScreenWidget extends ModelWidget implements Serializa return this.styleExdr.expandString(context); } + public String getAutoUpdateTargetExdr(Map context) { + return this.autoUpdateTargetExdr.expandString(context); + } + public String rawString() { - return ""; + return ""; } }