mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -292,6 +292,11 @@ public class AVMEditBean
|
||||
*/
|
||||
public void setFormProcessorSession(final FormProcessor.Session formProcessorSession)
|
||||
{
|
||||
if (this.formProcessorSession != null &&
|
||||
this.formProcessorSession != formProcessorSession)
|
||||
{
|
||||
this.formProcessorSession.destroy();
|
||||
}
|
||||
this.formProcessorSession = formProcessorSession;
|
||||
}
|
||||
|
||||
@@ -354,7 +359,10 @@ public class AVMEditBean
|
||||
MimetypeMap.MIMETYPE_JAVASCRIPT.equals(mimetype))
|
||||
{
|
||||
// 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
|
||||
outcome = ((MimetypeMap.MIMETYPE_XML.equals(mimetype) &&
|
||||
@@ -546,8 +554,8 @@ public class AVMEditBean
|
||||
clearUpload();
|
||||
setDocumentContent(null);
|
||||
setEditorOutput(null);
|
||||
this.setFormProcessorSession(null);
|
||||
this.instanceDataDocument = null;
|
||||
this.formProcessorSession = null;
|
||||
this.form = null;
|
||||
}
|
||||
|
||||
|
@@ -25,18 +25,21 @@ import javax.faces.el.ValueBinding;
|
||||
import org.alfresco.web.forms.*;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class UIFormProcessor extends SelfRenderingComponent
|
||||
public class UIFormProcessor
|
||||
extends SelfRenderingComponent
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(UIFormProcessor.class);
|
||||
|
||||
private Document formInstanceData = null;
|
||||
|
||||
private Form form = null;
|
||||
private FormProcessor.Session formProcessorSession;
|
||||
|
||||
private FormProcessor.Session formProcessorSession = null;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Component implementation
|
||||
@@ -61,14 +64,14 @@ public class UIFormProcessor extends SelfRenderingComponent
|
||||
|
||||
public Object saveState(FacesContext context)
|
||||
{
|
||||
final Object values[] = {
|
||||
return new Object[]
|
||||
{
|
||||
// standard component attributes are saved by the super class
|
||||
super.saveState(context),
|
||||
this.formInstanceData,
|
||||
this.form,
|
||||
this.formProcessorSession
|
||||
};
|
||||
return values;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,21 +89,23 @@ public class UIFormProcessor extends SelfRenderingComponent
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
final Form form = this.getForm();
|
||||
final FormProcessor fp = form.getFormProcessors().get(0);
|
||||
final FormProcessor.Session fps = this.getFormProcessorSession();
|
||||
final Document fid = this.getFormInstanceData();
|
||||
try
|
||||
{
|
||||
if (this.getFormProcessorSession() != null &&
|
||||
this.getFormProcessorSession().getForm().equals(this.getForm()))
|
||||
if (fps != null && fps.getFormInstanceData().equals(fid))
|
||||
{
|
||||
fp.process(this.getFormProcessorSession(), out);
|
||||
LOGGER.debug("reusing form processor session " + fps);
|
||||
fp.process(this.formProcessorSession, out);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.getFormProcessorSession() != null)
|
||||
if (fps != null)
|
||||
{
|
||||
this.getFormProcessorSession().destroy();
|
||||
this.setFormProcessorSession(null);
|
||||
}
|
||||
this.setFormProcessorSession(fp.process(this.getFormInstanceData(),
|
||||
LOGGER.debug("creating a new session for " + fid);
|
||||
this.setFormProcessorSession(fp.process(fid,
|
||||
form,
|
||||
out));
|
||||
}
|
||||
@@ -127,7 +132,6 @@ public class UIFormProcessor extends SelfRenderingComponent
|
||||
{
|
||||
this.formInstanceData = (Document)vb.getValue(getFacesContext());
|
||||
}
|
||||
|
||||
return this.formInstanceData;
|
||||
}
|
||||
|
||||
@@ -153,7 +157,6 @@ public class UIFormProcessor extends SelfRenderingComponent
|
||||
{
|
||||
this.form = (Form)vb.getValue(getFacesContext());
|
||||
}
|
||||
|
||||
return this.form;
|
||||
}
|
||||
|
||||
@@ -180,7 +183,7 @@ public class UIFormProcessor extends SelfRenderingComponent
|
||||
this.formProcessorSession = (FormProcessor.Session)
|
||||
vb.getValue(getFacesContext());
|
||||
}
|
||||
|
||||
LOGGER.debug("getFormProcessorSession() = " + this.formProcessorSession);
|
||||
return this.formProcessorSession;
|
||||
}
|
||||
|
||||
@@ -191,11 +194,15 @@ public class UIFormProcessor extends SelfRenderingComponent
|
||||
*/
|
||||
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");
|
||||
if (vb != null)
|
||||
{
|
||||
vb.setValue(getFacesContext(), formProcessorSession);
|
||||
}
|
||||
this.formProcessorSession = formProcessorSession;
|
||||
}
|
||||
}
|
||||
|
@@ -25,12 +25,12 @@ import org.alfresco.web.ui.common.tag.BaseComponentTag;
|
||||
/**
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class FormProcessorTag extends BaseComponentTag
|
||||
public class FormProcessorTag
|
||||
extends BaseComponentTag
|
||||
{
|
||||
|
||||
private String formInstanceData;
|
||||
private String form;
|
||||
private String formProcessorSession;
|
||||
private String formInstanceData = null;
|
||||
private String form = null;
|
||||
private String formProcessorSession = null;
|
||||
|
||||
/**
|
||||
* @see javax.faces.webapp.UIComponentTag#getComponentType()
|
||||
|
@@ -121,7 +121,7 @@ function _xforms_getSubmitButtons()
|
||||
<tr><td class="dialogButtonSpacing"></td></tr>
|
||||
<tr>
|
||||
<td align="center">
|
||||
<h:commandButton value="#{msg.cancel}" action="dialog:close" styleClass="dialogControls" />
|
||||
<h:commandButton value="#{msg.cancel}" action="#{AVMEditBean.cancel}" styleClass="dialogControls" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
Reference in New Issue
Block a user