Index: core/src/main/java/org/icefaces/impl/event/FormSubmit.java =================================================================== --- core/src/main/java/org/icefaces/impl/event/FormSubmit.java (revision 24095) +++ core/src/main/java/org/icefaces/impl/event/FormSubmit.java (working copy) @@ -37,97 +37,102 @@ import java.io.IOException; public class FormSubmit implements SystemEventListener { - public static final String DISABLE_CAPTURE_SUBMIT = "DISABLE_CAPTURE_SUBMIT"; - private static final String CAPTURE_SUBMIT_SUFFIX = "_captureSubmit"; - private boolean deltaSubmit; - private boolean partialStateSaving; + public static final String DISABLE_CAPTURE_SUBMIT = "DISABLE_CAPTURE_SUBMIT"; + private static final String CAPTURE_SUBMIT_SUFFIX = "_captureSubmit"; + private boolean deltaSubmit; + private boolean partialStateSaving; - public FormSubmit() { - FacesContext facesContext = FacesContext.getCurrentInstance(); - deltaSubmit = EnvUtils.isDeltaSubmit(facesContext); - partialStateSaving = EnvUtils.isPartialStateSaving(facesContext); - } + public FormSubmit() { + FacesContext facesContext = FacesContext.getCurrentInstance(); + deltaSubmit = EnvUtils.isDeltaSubmit(facesContext); + partialStateSaving = EnvUtils.isPartialStateSaving(facesContext); + } - public void processEvent(SystemEvent event) throws AbortProcessingException { - FacesContext context = FacesContext.getCurrentInstance(); - if (!EnvUtils.isICEfacesView(context)) { - return; - } + public void processEvent(SystemEvent event) throws AbortProcessingException { + // This should not be processed in case of an AJAX-Request while + // Restoring the view, which actually happens. + if (!(event instanceof PostAddToViewEvent)) { + return; + } + FacesContext context = FacesContext.getCurrentInstance(); + if (!EnvUtils.isICEfacesView(context)) { + return; + } - //using PostAddToViewEvent ensures that the component resource is added to the view only once - final HtmlForm form = (HtmlForm) ((PostAddToViewEvent) event).getComponent(); - if (form.getAttributes().get(DISABLE_CAPTURE_SUBMIT) != null) { - return; - } - String componentId = form.getId() + CAPTURE_SUBMIT_SUFFIX; + // using PostAddToViewEvent ensures that the component resource is added to the view only once + final HtmlForm form = (HtmlForm) ((PostAddToViewEvent) event).getComponent(); + if (form.getAttributes().get(DISABLE_CAPTURE_SUBMIT) != null) { + return; + } + String componentId = form.getId() + CAPTURE_SUBMIT_SUFFIX; - if (!partialStateSaving) { - for (UIComponent child : form.getChildren()) { - String id = child.getId(); - if ((null != id) && id.endsWith(CAPTURE_SUBMIT_SUFFIX)) { - return; - } - } - } + if (!partialStateSaving) { + for (UIComponent child : form.getChildren()) { + String id = child.getId(); + if ((null != id) && id.endsWith(CAPTURE_SUBMIT_SUFFIX)) { + return; + } + } + } - UIOutput scriptWriter = new UIOutputWriter() { - public void encode(ResponseWriter writer, FacesContext context) throws IOException { - if (form.getAttributes().get(DISABLE_CAPTURE_SUBMIT) != null) { - return; - } - String formId = form.getClientId(context); - writer.startElement("script", this); - writer.writeAttribute("type", "text/javascript", "type"); - writer.writeAttribute("id", getClientId(context), "id"); - writer.write("ice.captureSubmit('"); - writer.write(formId); - writer.write("',"); - writer.write(Boolean.toString(deltaSubmit)); - writer.write(");"); - writer.write("ice.captureEnterKey('"); - writer.write(formId); - writer.write("');"); - writer.endElement("script"); - } - }; + UIOutput scriptWriter = new UIOutputWriter() { + public void encode(ResponseWriter writer, FacesContext context) throws IOException { + if (form.getAttributes().get(DISABLE_CAPTURE_SUBMIT) != null) { + return; + } + String formId = form.getClientId(context); + writer.startElement("script", this); + writer.writeAttribute("type", "text/javascript", "type"); + writer.writeAttribute("id", getClientId(context), "id"); + writer.write("ice.captureSubmit('"); + writer.write(formId); + writer.write("',"); + writer.write(Boolean.toString(deltaSubmit)); + writer.write(");"); + writer.write("ice.captureEnterKey('"); + writer.write(formId); + writer.write("');"); + writer.endElement("script"); + } + }; - scriptWriter.setId(componentId); - scriptWriter.setTransient(true); - form.getChildren().add(0, scriptWriter); + scriptWriter.setId(componentId); + scriptWriter.setTransient(true); + form.getChildren().add(0, scriptWriter); - AjaxDisabledWriter disabledWriter = new AjaxDisabledWriter(); - disabledWriter.setTransient(true); - //add to end of list - form.getChildren().add(disabledWriter); + AjaxDisabledWriter disabledWriter = new AjaxDisabledWriter(); + disabledWriter.setTransient(true); + //add to end of list + form.getChildren().add(disabledWriter); - } + } - public boolean isListenerForSource(Object source) { - return source instanceof HtmlForm; - } + public boolean isListenerForSource(Object source) { + return source instanceof HtmlForm; + } } class AjaxDisabledWriter extends UIOutputWriter { - public void encode(ResponseWriter writer, FacesContext context) - throws IOException { - UIForm form = AjaxDisabledList.getContainingForm(this); - //consume with remove to reset the list each time - String value = (String) form.getAttributes() - .remove(AjaxDisabledList.DISABLED_LIST); - if (null == value) { - return; - } - writer.startElement("input", this); - writer.writeAttribute("type", "hidden", "type"); - writer.writeAttribute("id", getClientId(context), "id"); - writer.writeAttribute("disabled", "true", "disabled"); - writer.writeAttribute("value", value, "value"); - writer.endElement("input"); - } + public void encode(ResponseWriter writer, FacesContext context) + throws IOException { + UIForm form = AjaxDisabledList.getContainingForm(this); + //consume with remove to reset the list each time + String value = (String) form.getAttributes() + .remove(AjaxDisabledList.DISABLED_LIST); + if (null == value) { + return; + } + writer.startElement("input", this); + writer.writeAttribute("type", "hidden", "type"); + writer.writeAttribute("id", getClientId(context), "id"); + writer.writeAttribute("disabled", "true", "disabled"); + writer.writeAttribute("value", value, "value"); + writer.endElement("input"); + } - public String getClientId(FacesContext context) { - UIForm form = AjaxDisabledList.getContainingForm(this); - return (form.getClientId() + UINamingContainer - .getSeparatorChar(context)+ "ajaxDisabled"); - } + public String getClientId(FacesContext context) { + UIForm form = AjaxDisabledList.getContainingForm(this); + return (form.getClientId() + UINamingContainer + .getSeparatorChar(context)+ "ajaxDisabled"); + } } Index: core/src/main/java/org/icefaces/impl/event/WindowAndViewIDSetup.java =================================================================== --- core/src/main/java/org/icefaces/impl/event/WindowAndViewIDSetup.java (revision 24095) +++ core/src/main/java/org/icefaces/impl/event/WindowAndViewIDSetup.java (working copy) @@ -38,67 +38,72 @@ import java.util.logging.Logger; public class WindowAndViewIDSetup implements SystemEventListener { - private static final Logger Log = Logger.getLogger(WindowAndViewIDSetup.class.getName()); - private static final String ID_SUFFIX = "_windowviewid"; - private boolean partialStateSaving; + private static final Logger Log = Logger.getLogger(WindowAndViewIDSetup.class.getName()); + private static final String ID_SUFFIX = "_windowviewid"; + private boolean partialStateSaving; - public WindowAndViewIDSetup() { - partialStateSaving = EnvUtils.isPartialStateSaving( - FacesContext.getCurrentInstance() ); - } + public WindowAndViewIDSetup() { + partialStateSaving = EnvUtils.isPartialStateSaving( + FacesContext.getCurrentInstance() ); + } - public void processEvent(SystemEvent event) throws AbortProcessingException { - final FacesContext context = FacesContext.getCurrentInstance(); - if (!EnvUtils.isICEfacesView(context)) { - return; - } + public void processEvent(SystemEvent event) throws AbortProcessingException { + // This should not be processed in case of an AJAX-Request while + // Restoring the view, which actually happens. + if (!(event instanceof PostAddToViewEvent)) { + return; + } + final FacesContext context = FacesContext.getCurrentInstance(); + if (!EnvUtils.isICEfacesView(context)) { + return; + } - HtmlForm form = (HtmlForm) ((PostAddToViewEvent) event).getComponent(); - String componentId = form.getId() + ID_SUFFIX; + HtmlForm form = (HtmlForm) ((PostAddToViewEvent) event).getComponent(); + String componentId = form.getId() + ID_SUFFIX; - if (!partialStateSaving) { - for (UIComponent child : form.getChildren()) { - String id = child.getId(); - if ((null != id) && id.endsWith(ID_SUFFIX)) { - return; - } - } - } + if (!partialStateSaving) { + for (UIComponent child : form.getChildren()) { + String id = child.getId(); + if ((null != id) && id.endsWith(ID_SUFFIX)) { + return; + } + } + } - UIOutput output = new UIOutputWriter() { - public void encode(ResponseWriter writer, FacesContext context) throws IOException { - Map requestMap = context.getExternalContext().getRequestMap(); + UIOutput output = new UIOutputWriter() { + public void encode(ResponseWriter writer, FacesContext context) throws IOException { + Map requestMap = context.getExternalContext().getRequestMap(); - if (WindowScopeManager.lookupAssociatedWindowID(requestMap) == null) { - Log.severe("Missing window ID attribute. Request map cleared prematurely."); - return; - } - String viewId = BridgeSetup.getViewID(context.getExternalContext()); - if (viewId == null) { - Log.severe("Missing view ID attribute. Request map cleared prematurely."); - return; - } + if (WindowScopeManager.lookupAssociatedWindowID(requestMap) == null) { + Log.severe("Missing window ID attribute. Request map cleared prematurely."); + return; + } + String viewId = BridgeSetup.getViewID(context.getExternalContext()); + if (viewId == null) { + Log.severe("Missing view ID attribute. Request map cleared prematurely."); + return; + } - writer.startElement("input", this); - writer.writeAttribute("type", "hidden", null); - writer.writeAttribute("name", "ice.window", null); - writer.writeAttribute("value", WindowScopeManager.lookupWindowScope(context).getId(), null); - writer.endElement("input"); + writer.startElement("input", this); + writer.writeAttribute("type", "hidden", null); + writer.writeAttribute("name", "ice.window", null); + writer.writeAttribute("value", WindowScopeManager.lookupWindowScope(context).getId(), null); + writer.endElement("input"); - writer.startElement("input", this); - writer.writeAttribute("type", "hidden", null); - writer.writeAttribute("name", "ice.view", null); - writer.writeAttribute("value", viewId, null); - writer.endElement("input"); - } - }; + writer.startElement("input", this); + writer.writeAttribute("type", "hidden", null); + writer.writeAttribute("name", "ice.view", null); + writer.writeAttribute("value", viewId, null); + writer.endElement("input"); + } + }; - output.setTransient(true); - output.setId(componentId); - form.getChildren().add(0, output); - } + output.setTransient(true); + output.setId(componentId); + form.getChildren().add(0, output); + } - public boolean isListenerForSource(Object source) { - return source instanceof HtmlForm; - } + public boolean isListenerForSource(Object source) { + return source instanceof HtmlForm; + } }