diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java index 09c1e4f157..b27ac90a36 100644 --- a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java +++ b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java @@ -283,7 +283,7 @@ public class XFormsBean * Writes the xform out to the http servlet response. This allows * us to use the browser to parse the xform using XMLHttpRequest. */ - public void getXForm() + public synchronized void getXForm() throws IOException, XFormsException { @@ -302,7 +302,7 @@ public class XFormsBean * @param value the new value * @return the list of events that may result through this action */ - public void setXFormsValue() + public synchronized void setXFormsValue() throws XFormsException, IOException { final FacesContext context = FacesContext.getCurrentInstance(); @@ -357,7 +357,7 @@ public class XFormsBean * * @param id the id of the control in the host document */ - public void fireAction() + public synchronized void fireAction() throws XFormsException, IOException { final FacesContext context = FacesContext.getCurrentInstance(); @@ -376,7 +376,7 @@ public class XFormsBean /** * handles submits and sets the instance data. */ - public void handleAction() + public synchronized void handleAction() { LOGGER.debug(this + ".handleAction"); try @@ -410,7 +410,7 @@ public class XFormsBean /** * Swaps model nodes to implement reordering within repeats. */ - public void swapRepeatItems() + public synchronized void swapRepeatItems() throws Exception { final FacesContext context = FacesContext.getCurrentInstance(); @@ -420,8 +420,17 @@ public class XFormsBean final String toItemId = (String)requestParameters.get("toItemId"); LOGGER.debug(this + ".swapRepeatItems(" + fromItemId + ", " + toItemId + ")"); final ChibaBean chibaBean = this.xformsSession.chibaBean; - this.swapRepeatItems((RepeatItem)chibaBean.getContainer().lookup(fromItemId), - (RepeatItem)chibaBean.getContainer().lookup(toItemId)); + final RepeatItem from = (RepeatItem)chibaBean.getContainer().lookup(fromItemId); + if (from == null) + { + throw new NullPointerException("unable to find source repeat item " + fromItemId); + } + final RepeatItem to = (RepeatItem)chibaBean.getContainer().lookup(toItemId); + if (to == null) + { + throw new NullPointerException("unable to find destination repeat item " + toItemId); + } + this.swapRepeatItems(from, to); final ResponseWriter out = context.getResponseWriter(); XMLUtil.print(this.getEventLog(), out); diff --git a/source/web/scripts/ajax/xforms.js b/source/web/scripts/ajax/xforms.js index ffe82c45d3..51b420ad9f 100644 --- a/source/web/scripts/ajax/xforms.js +++ b/source/web/scripts/ajax/xforms.js @@ -2352,6 +2352,7 @@ dojo.declare("alfresco.xforms.Repeat", { this.repeatControls = []; this._selectedIndex = -1; + this._locked = false; }, { ///////////////////////////////////////////////////////////////// @@ -2727,13 +2728,14 @@ dojo.declare("alfresco.xforms.Repeat", { dojo.event.browser.stopEvent(event); var repeat = event.target.repeat; - if (repeat.isInsertRepeatItemEnabled()) + if (!repeat._locked && repeat.isInsertRepeatItemEnabled()) { var index = repeat.repeatControls.indexOf(event.target.parentNode); var repeatItem = repeat.getChildAt(index); this.setFocusedChild(repeatItem); var trigger = this._getRepeatItemTrigger("insert", { position: "after" }); trigger.fire(); + repeat._locked = true; } }, @@ -2747,11 +2749,12 @@ dojo.declare("alfresco.xforms.Repeat", { dojo.event.browser.stopEvent(event); var repeat = event.target.repeat; - if (repeat.isInsertRepeatItemEnabled()) + if (!repeat._locked && repeat.isInsertRepeatItemEnabled()) { this.setFocusedChild(null); var trigger = this._getRepeatItemTrigger("insert", { position: "before" }); trigger.fire(); + repeat._locked = true; } } }, @@ -2764,13 +2767,14 @@ dojo.declare("alfresco.xforms.Repeat", { dojo.event.browser.stopEvent(event); var repeat = event.target.repeat; - if (repeat.isRemoveRepeatItemEnabled()) + if (!repeat._locked && repeat.isRemoveRepeatItemEnabled()) { var index = repeat.repeatControls.indexOf(event.target.parentNode); var repeatItem = repeat.getChildAt(index); this.setFocusedChild(repeatItem); var trigger = this._getRepeatItemTrigger("delete", {}); trigger.fire(); + repeat._locked = true; } }, @@ -2783,11 +2787,12 @@ dojo.declare("alfresco.xforms.Repeat", dojo.event.browser.stopEvent(event); var repeat = event.target.repeat; var index = repeat.repeatControls.indexOf(event.target.parentNode); - if (index != 0 && repeat._children.length != 1) + if (!repeat._locked && index != 0 && repeat._children.length != 1) { var repeatItem = repeat.getChildAt(index); this.setFocusedChild(repeatItem); repeat._swapChildren(index, index - 1); + repeat._locked = true; } }, @@ -2800,11 +2805,12 @@ dojo.declare("alfresco.xforms.Repeat", dojo.event.browser.stopEvent(event); var repeat = event.target.repeat; var index = repeat.repeatControls.indexOf(event.target.parentNode); - if (index != repeat._children.length - 1 && repeat._children.length != 1) + if (!repeat._locked && index != repeat._children.length - 1 && repeat._children.length != 1) { var repeatItem = repeat.getChildAt(index); this.setFocusedChild(repeatItem); repeat._swapChildren(index, index + 1); + repeat._locked = true; } }, @@ -2847,6 +2853,7 @@ dojo.declare("alfresco.xforms.Repeat", var w = this.xform.createWidget(clonedPrototype); this._insertChildAt(w, position); this.xform.loadWidgets(w.xformsNode, w); + this._locked = false; }, /** Deletes the item at the specified position. */ @@ -2854,6 +2861,7 @@ dojo.declare("alfresco.xforms.Repeat", { dojo.debug(this.id + ".handleItemDeleted(" + position + ")"); this._removeChildAt(position); + this._locked = false; } });