fixing caching issues with edit of forms. need to carefully trash FormProcessorSessions when user navigates away from a form. call reset in AVMEditBean when the user clicks cancel.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4797 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2007-01-11 18:00:45 +00:00
parent ebae3000cf
commit d13abef6ec
4 changed files with 41 additions and 26 deletions

View File

@@ -292,6 +292,11 @@ public class AVMEditBean
*/ */
public void setFormProcessorSession(final FormProcessor.Session formProcessorSession) public void setFormProcessorSession(final FormProcessor.Session formProcessorSession)
{ {
if (this.formProcessorSession != null &&
this.formProcessorSession != formProcessorSession)
{
this.formProcessorSession.destroy();
}
this.formProcessorSession = formProcessorSession; this.formProcessorSession = formProcessorSession;
} }
@@ -354,8 +359,11 @@ public class AVMEditBean
MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype)) MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype))
{ {
// make content available to the editing screen // make content available to the editing screen
setEditorOutput(reader.getContentString()); this.setEditorOutput(reader.getContentString());
this.setFormProcessorSession(null);
this.instanceDataDocument = null;
this.form = null;
// navigate to appropriate screen // navigate to appropriate screen
outcome = ((MimetypeMap.MIMETYPE_XML.equals(mimetype) && outcome = ((MimetypeMap.MIMETYPE_XML.equals(mimetype) &&
this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA)) this.avmService.hasAspect(-1, avmPath, WCMAppModel.ASPECT_FORM_INSTANCE_DATA))
@@ -546,8 +554,8 @@ public class AVMEditBean
clearUpload(); clearUpload();
setDocumentContent(null); setDocumentContent(null);
setEditorOutput(null); setEditorOutput(null);
this.setFormProcessorSession(null);
this.instanceDataDocument = null; this.instanceDataDocument = null;
this.formProcessorSession = null;
this.form = null; this.form = null;
} }

View File

@@ -25,18 +25,21 @@ import javax.faces.el.ValueBinding;
import org.alfresco.web.forms.*; import org.alfresco.web.forms.*;
import org.alfresco.web.ui.common.Utils; import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.SelfRenderingComponent; import org.alfresco.web.ui.common.component.SelfRenderingComponent;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document; import org.w3c.dom.Document;
/** /**
* @author Ariel Backenroth * @author Ariel Backenroth
*/ */
public class UIFormProcessor extends SelfRenderingComponent public class UIFormProcessor
extends SelfRenderingComponent
{ {
private Document formInstanceData = null; private static final Log LOGGER = LogFactory.getLog(UIFormProcessor.class);
private Form form = null;
private FormProcessor.Session formProcessorSession;
private Document formInstanceData = null;
private Form form = null;
private FormProcessor.Session formProcessorSession = null;
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Component implementation // Component implementation
@@ -61,14 +64,14 @@ public class UIFormProcessor extends SelfRenderingComponent
public Object saveState(FacesContext context) public Object saveState(FacesContext context)
{ {
final Object values[] = { return new Object[]
{
// standard component attributes are saved by the super class // standard component attributes are saved by the super class
super.saveState(context), super.saveState(context),
this.formInstanceData, this.formInstanceData,
this.form, this.form,
this.formProcessorSession this.formProcessorSession
}; };
return values;
} }
/** /**
@@ -86,21 +89,23 @@ public class UIFormProcessor extends SelfRenderingComponent
final ResponseWriter out = context.getResponseWriter(); final ResponseWriter out = context.getResponseWriter();
final Form form = this.getForm(); final Form form = this.getForm();
final FormProcessor fp = form.getFormProcessors().get(0); final FormProcessor fp = form.getFormProcessors().get(0);
final FormProcessor.Session fps = this.getFormProcessorSession();
final Document fid = this.getFormInstanceData();
try try
{ {
if (this.getFormProcessorSession() != null && if (fps != null && fps.getFormInstanceData().equals(fid))
this.getFormProcessorSession().getForm().equals(this.getForm()))
{ {
fp.process(this.getFormProcessorSession(), out); LOGGER.debug("reusing form processor session " + fps);
fp.process(this.formProcessorSession, out);
} }
else else
{ {
if (this.getFormProcessorSession() != null) if (fps != null)
{ {
this.getFormProcessorSession().destroy();
this.setFormProcessorSession(null); this.setFormProcessorSession(null);
} }
this.setFormProcessorSession(fp.process(this.getFormInstanceData(), LOGGER.debug("creating a new session for " + fid);
this.setFormProcessorSession(fp.process(fid,
form, form,
out)); out));
} }
@@ -127,7 +132,6 @@ public class UIFormProcessor extends SelfRenderingComponent
{ {
this.formInstanceData = (Document)vb.getValue(getFacesContext()); this.formInstanceData = (Document)vb.getValue(getFacesContext());
} }
return this.formInstanceData; return this.formInstanceData;
} }
@@ -153,7 +157,6 @@ public class UIFormProcessor extends SelfRenderingComponent
{ {
this.form = (Form)vb.getValue(getFacesContext()); this.form = (Form)vb.getValue(getFacesContext());
} }
return this.form; return this.form;
} }
@@ -180,7 +183,7 @@ public class UIFormProcessor extends SelfRenderingComponent
this.formProcessorSession = (FormProcessor.Session) this.formProcessorSession = (FormProcessor.Session)
vb.getValue(getFacesContext()); vb.getValue(getFacesContext());
} }
LOGGER.debug("getFormProcessorSession() = " + this.formProcessorSession);
return this.formProcessorSession; return this.formProcessorSession;
} }
@@ -191,11 +194,15 @@ public class UIFormProcessor extends SelfRenderingComponent
*/ */
public void setFormProcessorSession(final FormProcessor.Session formProcessorSession) public void setFormProcessorSession(final FormProcessor.Session formProcessorSession)
{ {
if (formProcessorSession == null && this.formProcessorSession != null)
{
this.formProcessorSession.destroy();
}
this.formProcessorSession = formProcessorSession;
final ValueBinding vb = this.getValueBinding("formProcessorSession"); final ValueBinding vb = this.getValueBinding("formProcessorSession");
if (vb != null) if (vb != null)
{ {
vb.setValue(getFacesContext(), formProcessorSession); vb.setValue(getFacesContext(), formProcessorSession);
} }
this.formProcessorSession = formProcessorSession;
} }
} }

View File

@@ -25,12 +25,12 @@ import org.alfresco.web.ui.common.tag.BaseComponentTag;
/** /**
* @author Ariel Backenroth * @author Ariel Backenroth
*/ */
public class FormProcessorTag extends BaseComponentTag public class FormProcessorTag
extends BaseComponentTag
{ {
private String formInstanceData = null;
private String formInstanceData; private String form = null;
private String form; private String formProcessorSession = null;
private String formProcessorSession;
/** /**
* @see javax.faces.webapp.UIComponentTag#getComponentType() * @see javax.faces.webapp.UIComponentTag#getComponentType()

View File

@@ -121,7 +121,7 @@ function _xforms_getSubmitButtons()
<tr><td class="dialogButtonSpacing"></td></tr> <tr><td class="dialogButtonSpacing"></td></tr>
<tr> <tr>
<td align="center"> <td align="center">
<h:commandButton value="#{msg.cancel}" action="dialog:close" styleClass="dialogControls" /> <h:commandButton value="#{msg.cancel}" action="#{AVMEditBean.cancel}" styleClass="dialogControls" />
</td> </td>
</tr> </tr>
</table> </table>