mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- implementing move up move down on the server side
- many repeater fixes (both filed and unfiled) - reducing groups from generated xform - testing complex types in forms - more test cases for repeats - adding description and title to create form git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4288 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -46,6 +46,7 @@ import org.alfresco.web.data.IDataContainer;
|
||||
import org.alfresco.web.data.QuickSort;
|
||||
import org.alfresco.web.forms.*;
|
||||
import org.alfresco.web.forms.xforms.SchemaFormBuilder;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.apache.xerces.xs.*;
|
||||
@@ -126,6 +127,7 @@ public class CreateFormWizard extends BaseWizardBean
|
||||
|
||||
private String schemaRootElementName;
|
||||
private String formName;
|
||||
private String formTitle;
|
||||
private String formDescription;
|
||||
private Class renderingEngineType = null;
|
||||
protected ContentService contentService;
|
||||
@@ -172,7 +174,7 @@ public class CreateFormWizard extends BaseWizardBean
|
||||
|
||||
// apply the titled aspect - title and description
|
||||
Map<QName, Serializable> props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(ContentModel.PROP_TITLE, this.getFormName());
|
||||
props.put(ContentModel.PROP_TITLE, this.getFormTitle());
|
||||
props.put(ContentModel.PROP_DESCRIPTION, this.getFormDescription());
|
||||
this.nodeService.addAspect(schemaNodeRef, ContentModel.ASPECT_TITLED, props);
|
||||
|
||||
@@ -228,6 +230,7 @@ public class CreateFormWizard extends BaseWizardBean
|
||||
this.removeUploadedRenderingEngineFile();
|
||||
this.schemaRootElementName = null;
|
||||
this.formName = null;
|
||||
this.formTitle = null;
|
||||
this.formDescription = null;
|
||||
this.renderingEngineType = null;
|
||||
this.renderingEngines = new ArrayList<RenderingEngineData>();
|
||||
@@ -575,9 +578,9 @@ public class CreateFormWizard extends BaseWizardBean
|
||||
final List<SelectItem> result = new LinkedList<SelectItem>();
|
||||
if (this.getSchemaFile() != null)
|
||||
{
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
try
|
||||
{
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final Document d = ts.parseXML(this.getSchemaFile());
|
||||
final XSModel xsm = SchemaFormBuilder.loadSchema(d);
|
||||
final XSNamedMap elementsMap = xsm.getComponents(XSConstants.ELEMENT_DECLARATION);
|
||||
@@ -591,6 +594,7 @@ public class CreateFormWizard extends BaseWizardBean
|
||||
{
|
||||
final String msg = "unable to parse " + this.getSchemaFileName();
|
||||
this.removeUploadedSchemaFile();
|
||||
Utils.addErrorMessage(msg, e);
|
||||
throw new AlfrescoRuntimeException(msg, e);
|
||||
}
|
||||
}
|
||||
@@ -615,6 +619,24 @@ public class CreateFormWizard extends BaseWizardBean
|
||||
: this.formName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the title for this form.
|
||||
*/
|
||||
public void setFormTitle(final String formTitle)
|
||||
{
|
||||
this.formTitle = formTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the title for this form.
|
||||
*/
|
||||
public String getFormTitle()
|
||||
{
|
||||
return (this.formTitle == null && this.getSchemaFileName() != null
|
||||
? this.getSchemaFileName().replaceAll("(.+)\\..*", "$1")
|
||||
: this.formTitle);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the description for this form.
|
||||
*/
|
||||
|
@@ -1049,7 +1049,8 @@ public class SchemaFormBuilder
|
||||
//(modelSection is the enclosing bind of the element)
|
||||
final NodeList binds = modelSection.getElementsByTagNameNS(XFORMS_NS, "bind");
|
||||
String bindId = null;
|
||||
for (int j = 0; j < binds.getLength() && bindId == null; j++) {
|
||||
for (int j = 0; j < binds.getLength() && bindId == null; j++)
|
||||
{
|
||||
Element bind = (Element) binds.item(j);
|
||||
String nodeset = bind.getAttributeNS(XFORMS_NS, "nodeset");
|
||||
if (nodeset != null)
|
||||
@@ -1073,7 +1074,7 @@ public class SchemaFormBuilder
|
||||
context.getPointer("//*[@" + SchemaFormBuilder.XFORMS_NS_PREFIX +
|
||||
"bind='" + bindId + "']");
|
||||
if (pointer != null)
|
||||
control = (Element) pointer.getNode();
|
||||
control = (Element)pointer.getNode();
|
||||
}
|
||||
|
||||
//copy it
|
||||
@@ -1087,7 +1088,6 @@ public class SchemaFormBuilder
|
||||
|
||||
formSection.appendChild(newControl);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1423,8 +1423,6 @@ public class SchemaFormBuilder
|
||||
{
|
||||
final TreeSet<XSTypeDefinition> compatibleTypes =
|
||||
this.typeTree.get(controlType.getName());
|
||||
//TreeSet compatibleTypes = (TreeSet) typeTree.get(controlType);
|
||||
|
||||
if (compatibleTypes == null)
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
@@ -1434,7 +1432,7 @@ public class SchemaFormBuilder
|
||||
{
|
||||
relative = false;
|
||||
|
||||
if (true || LOGGER.isDebugEnabled())
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("compatible types for " + typeName + ":");
|
||||
for (XSTypeDefinition compType : compatibleTypes)
|
||||
@@ -1843,7 +1841,9 @@ public class SchemaFormBuilder
|
||||
return found;
|
||||
}
|
||||
|
||||
private boolean doesElementComeFromExtension(XSElementDeclaration element, XSComplexTypeDefinition controlType) {
|
||||
private boolean doesElementComeFromExtension(XSElementDeclaration element,
|
||||
XSComplexTypeDefinition controlType)
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("doesElementComeFromExtension for " + element.getName() + " and controlType=" + controlType.getName());
|
||||
boolean comesFromExtension = false;
|
||||
@@ -1868,7 +1868,8 @@ public class SchemaFormBuilder
|
||||
/**
|
||||
* check that the element defined by this name is declared directly in the type
|
||||
*/
|
||||
private boolean isAttributeDeclaredIn(XSAttributeUse attr, XSComplexTypeDefinition type, boolean recursive) {
|
||||
private boolean isAttributeDeclaredIn(XSAttributeUse attr, XSComplexTypeDefinition type, boolean recursive)
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
@@ -1912,7 +1913,8 @@ public class SchemaFormBuilder
|
||||
* check that the element defined by this name is declared directly in the type
|
||||
* -> idem with string
|
||||
*/
|
||||
private boolean isAttributeDeclaredIn(String attrName, XSComplexTypeDefinition type, boolean recursive) {
|
||||
private boolean isAttributeDeclaredIn(String attrName, XSComplexTypeDefinition type, boolean recursive)
|
||||
{
|
||||
boolean found = false;
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
@@ -1960,9 +1962,11 @@ public class SchemaFormBuilder
|
||||
return found;
|
||||
}
|
||||
|
||||
private boolean doesAttributeComeFromExtension(XSAttributeUse attr, XSComplexTypeDefinition controlType) {
|
||||
private boolean doesAttributeComeFromExtension(XSAttributeUse attr, XSComplexTypeDefinition controlType)
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug("doesAttributeComeFromExtension for " + attr.getAttrDeclaration().getName() + " and controlType=" + controlType.getName());
|
||||
LOGGER.debug("doesAttributeComeFromExtension for " + attr.getAttrDeclaration().getName() +
|
||||
" and controlType=" + controlType.getName());
|
||||
boolean comesFromExtension = false;
|
||||
if (controlType.getDerivationMethod() == XSConstants.DERIVATION_EXTENSION) {
|
||||
XSTypeDefinition baseType = controlType.getBaseType();
|
||||
@@ -2036,10 +2040,10 @@ public class SchemaFormBuilder
|
||||
|
||||
if (term instanceof XSModelGroup)
|
||||
{
|
||||
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
LOGGER.debug(" term is a group");
|
||||
|
||||
|
||||
this.addGroup(xForm,
|
||||
modelSection,
|
||||
defaultInstanceElement,
|
||||
@@ -2105,13 +2109,12 @@ public class SchemaFormBuilder
|
||||
LOGGER.warn("Corresponding control not found");
|
||||
else
|
||||
{
|
||||
Element newControl = (Element) control.cloneNode(true);
|
||||
Element newControl = (Element)control.cloneNode(true);
|
||||
//set new Ids to XForm elements
|
||||
this.resetXFormIds(newControl);
|
||||
|
||||
repeatContentWrapper.appendChild(newControl);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2121,7 +2124,7 @@ public class SchemaFormBuilder
|
||||
final String path = (pathToRoot.length() == 0
|
||||
? elementName
|
||||
: pathToRoot + "/" + elementName);
|
||||
|
||||
|
||||
final Element newDefaultInstanceElement = xForm.createElement(elementName);
|
||||
defaultInstanceElement.appendChild(newDefaultInstanceElement);
|
||||
if (element.getConstraintType() != XSConstants.VC_NONE)
|
||||
@@ -2138,6 +2141,10 @@ public class SchemaFormBuilder
|
||||
element,
|
||||
element.getTypeDefinition(),
|
||||
path);
|
||||
for (int i = 1; i < this.getOccurance(element).minimum; i++)
|
||||
{
|
||||
defaultInstanceElement.appendChild(newDefaultInstanceElement.cloneNode(true));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2185,11 +2192,8 @@ public class SchemaFormBuilder
|
||||
bindId = bind.getAttributeNS(SchemaFormBuilder.XFORMS_NS, "id");
|
||||
else
|
||||
{
|
||||
LOGGER.warn("addRepeatIfNecessary: bind not found: "
|
||||
+ bind
|
||||
+ " (model selection name="
|
||||
+ modelSection.getNodeName()
|
||||
+ ")");
|
||||
LOGGER.warn("addRepeatIfNecessary: bind not found: " + bind
|
||||
+ " (model selection name=" + modelSection.getNodeName() + ")");
|
||||
|
||||
//if no bind is found -> modelSection is already a bind, get its parent last child
|
||||
bind = DOMUtil.getLastChildElement(modelSection.getParentNode());
|
||||
@@ -2257,11 +2261,8 @@ public class SchemaFormBuilder
|
||||
Element bindElement = xForm.createElementNS(XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "bind");
|
||||
String bindId = this.setXFormsId(bindElement);
|
||||
bindElement.setAttributeNS(XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "nodeset",
|
||||
pathToRoot);
|
||||
modelSection.appendChild(bindElement);
|
||||
bindElement = this.startBindElement(bindElement, schema, controlType, owner, o);
|
||||
bindElement = this.startBindElement(bindElement, schema, controlType, owner, pathToRoot, o);
|
||||
|
||||
// add a group if a repeat !
|
||||
if (owner instanceof XSElementDeclaration && o.maximum != 1)
|
||||
@@ -2295,17 +2296,17 @@ public class SchemaFormBuilder
|
||||
contentWrapper = this.wrapper.createGroupContentWrapper(repeatSection);
|
||||
|
||||
//if there is a repeat -> create another bind with "."
|
||||
Element bindElement2 =
|
||||
xForm.createElementNS(XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "bind");
|
||||
String bindId2 = this.setXFormsId(bindElement2);
|
||||
bindElement2.setAttributeNS(XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "nodeset",
|
||||
".");
|
||||
bindElement.appendChild(bindElement2);
|
||||
|
||||
bindElement = bindElement2;
|
||||
bindId = bindId2;
|
||||
// Element bindElement2 =
|
||||
// xForm.createElementNS(XFORMS_NS,
|
||||
// SchemaFormBuilder.XFORMS_NS_PREFIX + "bind");
|
||||
// String bindId2 = this.setXFormsId(bindElement2);
|
||||
// bindElement2.setAttributeNS(XFORMS_NS,
|
||||
// SchemaFormBuilder.XFORMS_NS_PREFIX + "nodeset",
|
||||
// ".");
|
||||
// bindElement.appendChild(bindElement2);
|
||||
//
|
||||
// bindElement = bindElement2;
|
||||
// bindId = bindId2;
|
||||
}
|
||||
|
||||
final String caption = owner != null ? createCaption(owner) : createCaption(owningElementName);
|
||||
@@ -2565,9 +2566,9 @@ public class SchemaFormBuilder
|
||||
final TreeSet<XSTypeDefinition> newDescendents =
|
||||
new TreeSet<XSTypeDefinition>(this.typeExtensionSorter);
|
||||
newDescendents.addAll(descendents);
|
||||
|
||||
//extension (we only add it to "newDescendants" because we don't want
|
||||
//to have a type descendant to itself, but to consider it for the parent
|
||||
|
||||
//extension (we only add it to "newDescendants" because we don't want
|
||||
//to have a type descendant to itself, but to consider it for the parent
|
||||
if (type.getTypeCategory() == XSTypeDefinition.COMPLEX_TYPE)
|
||||
{
|
||||
final XSComplexTypeDefinition complexType = (XSComplexTypeDefinition)type;
|
||||
@@ -2576,7 +2577,7 @@ public class SchemaFormBuilder
|
||||
!descendents.contains(type))
|
||||
newDescendents.add(type);
|
||||
}
|
||||
//note: extensions are impossible on simpleTypes !
|
||||
//note: extensions are impossible on simpleTypes !
|
||||
|
||||
this.buildTypeTree(parentType, newDescendents);
|
||||
}
|
||||
@@ -2599,7 +2600,8 @@ public class SchemaFormBuilder
|
||||
}
|
||||
|
||||
// build the type tree for simple types
|
||||
for (int i = 0; i < types.getLength(); i++) {
|
||||
for (int i = 0; i < types.getLength(); i++)
|
||||
{
|
||||
final XSTypeDefinition t = (XSTypeDefinition) types.item(i);
|
||||
if (t.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE)
|
||||
{
|
||||
@@ -2609,7 +2611,7 @@ public class SchemaFormBuilder
|
||||
}
|
||||
|
||||
// print out type hierarchy for debugging purposes
|
||||
if (true || LOGGER.isDebugEnabled())
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
for (String typeName : this.typeTree.keySet())
|
||||
{
|
||||
@@ -3332,6 +3334,7 @@ public class SchemaFormBuilder
|
||||
final XSModel schema,
|
||||
final XSTypeDefinition controlType,
|
||||
final XSObject owner,
|
||||
final String pathToRoot,
|
||||
final Occurs o)
|
||||
{
|
||||
// START WORKAROUND
|
||||
@@ -3341,6 +3344,15 @@ public class SchemaFormBuilder
|
||||
//
|
||||
// type.getName() may be 'null' for anonymous types, so compare against
|
||||
// static string (see bug #1172541 on sf.net)
|
||||
|
||||
String nodeset = pathToRoot;
|
||||
// if (o.maximum > 1 || o.isUnbounded())
|
||||
// nodeset = pathToRoot + "[position() != last()]";
|
||||
|
||||
bindElement.setAttributeNS(XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "nodeset",
|
||||
nodeset);
|
||||
|
||||
if (!"anyType".equals(controlType.getName()))
|
||||
{
|
||||
Element enveloppe = bindElement.getOwnerDocument().getDocumentElement();
|
||||
@@ -3386,7 +3398,7 @@ public class SchemaFormBuilder
|
||||
: (minConstraint != null
|
||||
? minConstraint
|
||||
: maxConstraint));
|
||||
if (constraint != null && constraint.length() != 0)
|
||||
if (constraint != null)
|
||||
bindElement.setAttributeNS(XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "constraint",
|
||||
constraint);
|
||||
@@ -3486,7 +3498,12 @@ public class SchemaFormBuilder
|
||||
final XSImplementation xsImpl = (XSImplementation)
|
||||
registry.getDOMImplementation("XS-Loader");
|
||||
final XSLoader schemaLoader = xsImpl.createXSLoader(null);
|
||||
return schemaLoader.load(in);
|
||||
final XSModel result = schemaLoader.load(in);
|
||||
if (result == null)
|
||||
{
|
||||
throw new FormBuilderException("invalid schema");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (ClassNotFoundException x)
|
||||
{
|
||||
|
@@ -38,9 +38,14 @@ import org.w3c.dom.Node;
|
||||
import org.alfresco.web.bean.wcm.AVMBrowseBean;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.chiba.xml.xforms.ChibaBean;
|
||||
import org.chiba.xml.xforms.Instance;
|
||||
import org.chiba.xml.xforms.XFormsElement;
|
||||
import org.chiba.xml.xforms.connector.http.AbstractHTTPConnector;
|
||||
import org.chiba.xml.xforms.core.ModelItem;
|
||||
import org.chiba.xml.xforms.exception.XFormsException;
|
||||
import org.chiba.xml.xforms.events.XFormsEvent;
|
||||
import org.chiba.xml.xforms.events.XFormsEventFactory;
|
||||
import org.chiba.xml.xforms.ui.BoundElement;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
|
||||
@@ -48,7 +53,6 @@ import org.w3c.dom.ls.*;
|
||||
import org.w3c.dom.events.Event;
|
||||
import org.w3c.dom.events.EventListener;
|
||||
import org.w3c.dom.events.EventTarget;
|
||||
import org.chiba.xml.xforms.connector.http.AbstractHTTPConnector;
|
||||
|
||||
/**
|
||||
* Bean for interacting with the chiba processor from the ui using ajax requests.
|
||||
@@ -56,317 +60,376 @@ import org.chiba.xml.xforms.connector.http.AbstractHTTPConnector;
|
||||
*/
|
||||
public class XFormsBean
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(XFormsBean.class);
|
||||
private static final Log LOGGER = LogFactory.getLog(XFormsBean.class);
|
||||
|
||||
private Form tt;
|
||||
private FormProcessor.InstanceData instanceData = null;
|
||||
private ChibaBean chibaBean;
|
||||
private final LinkedList<XFormsEvent> eventLog = new LinkedList<XFormsEvent>();
|
||||
private Form tt;
|
||||
private FormProcessor.InstanceData instanceData = null;
|
||||
private ChibaBean chibaBean;
|
||||
private final LinkedList<XFormsEvent> eventLog = new LinkedList<XFormsEvent>();
|
||||
|
||||
/** @return the form */
|
||||
public Form getForm()
|
||||
{
|
||||
return this.tt;
|
||||
}
|
||||
/** @return the form */
|
||||
public Form getForm()
|
||||
{
|
||||
return this.tt;
|
||||
}
|
||||
|
||||
/** @param tt the template type */
|
||||
public void setForm(final Form tt)
|
||||
{
|
||||
this.tt = tt;
|
||||
}
|
||||
/** @param tt the template type */
|
||||
public void setForm(final Form tt)
|
||||
{
|
||||
this.tt = tt;
|
||||
}
|
||||
|
||||
/** @param instanceData the instance data being modified. */
|
||||
public void setInstanceData(final FormProcessor.InstanceData instanceData)
|
||||
{
|
||||
this.instanceData = instanceData;
|
||||
}
|
||||
/** @param instanceData the instance data being modified. */
|
||||
public void setInstanceData(final FormProcessor.InstanceData instanceData)
|
||||
{
|
||||
this.instanceData = instanceData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the chiba process with the xform and registers any necessary
|
||||
* event listeners.
|
||||
*/
|
||||
public void init()
|
||||
throws XFormsException
|
||||
{
|
||||
LOGGER.debug("initializing " + this + " with tt " + tt.getName());
|
||||
this.chibaBean = new ChibaBean();
|
||||
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
final ExternalContext externalContext = facesContext.getExternalContext();
|
||||
final HttpServletRequest request = (HttpServletRequest)
|
||||
externalContext.getRequest();
|
||||
final HttpSession session = (HttpSession)
|
||||
externalContext.getSession(true);
|
||||
final AVMBrowseBean browseBean = (AVMBrowseBean)
|
||||
session.getAttribute("AVMBrowseBean");
|
||||
LOGGER.debug("avm cwd is " + browseBean.getCurrentPath());
|
||||
/**
|
||||
* Initializes the chiba process with the xform and registers any necessary
|
||||
* event listeners.
|
||||
*/
|
||||
public void init()
|
||||
throws XFormsException
|
||||
{
|
||||
LOGGER.debug("initializing " + this + " with tt " + tt.getName());
|
||||
this.chibaBean = new ChibaBean();
|
||||
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||
final ExternalContext externalContext = facesContext.getExternalContext();
|
||||
final HttpServletRequest request = (HttpServletRequest)
|
||||
externalContext.getRequest();
|
||||
final HttpSession session = (HttpSession)
|
||||
externalContext.getSession(true);
|
||||
final AVMBrowseBean browseBean = (AVMBrowseBean)
|
||||
session.getAttribute("AVMBrowseBean");
|
||||
LOGGER.debug("avm cwd is " + browseBean.getCurrentPath());
|
||||
|
||||
XFormsBean.storeCookies(request.getCookies(), this.chibaBean);
|
||||
XFormsBean.storeCookies(request.getCookies(), this.chibaBean);
|
||||
|
||||
try
|
||||
{
|
||||
final Document form = this.buildXForm(instanceData.getContent(),
|
||||
tt,
|
||||
browseBean.getCurrentPath(),
|
||||
request);
|
||||
this.chibaBean.setXMLContainer(form);
|
||||
try
|
||||
{
|
||||
final Document form = this.buildXForm(instanceData.getContent(),
|
||||
tt,
|
||||
browseBean.getCurrentPath(),
|
||||
request);
|
||||
this.chibaBean.setXMLContainer(form);
|
||||
|
||||
final EventTarget et = (EventTarget)
|
||||
this.chibaBean.getXMLContainer().getDocumentElement();
|
||||
final EventListener el = new EventListener()
|
||||
{
|
||||
public void handleEvent(Event e)
|
||||
{
|
||||
XFormsBean.LOGGER.debug("received event " + e);
|
||||
XFormsBean.this.eventLog.add((XFormsEvent)e);
|
||||
}
|
||||
};
|
||||
// interaction events my occur during init so we have to register before
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_LOAD_URI, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_RENDER_MESSAGE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_REPLACE_ALL, el, true);
|
||||
final EventTarget et = (EventTarget)
|
||||
this.chibaBean.getXMLContainer().getDocumentElement();
|
||||
final EventListener el = new EventListener()
|
||||
{
|
||||
public void handleEvent(Event e)
|
||||
{
|
||||
XFormsBean.LOGGER.debug("received event " + e);
|
||||
XFormsBean.this.eventLog.add((XFormsEvent)e);
|
||||
}
|
||||
};
|
||||
// interaction events my occur during init so we have to register before
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_LOAD_URI, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_RENDER_MESSAGE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_REPLACE_ALL, el, true);
|
||||
|
||||
this.chibaBean.init();
|
||||
this.chibaBean.init();
|
||||
|
||||
// register for notification events
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_DONE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_ERROR, el, true);
|
||||
et.addEventListener(XFormsEventFactory.REQUIRED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.OPTIONAL, el, true);
|
||||
et.addEventListener(XFormsEventFactory.VALID, el, true);
|
||||
et.addEventListener(XFormsEventFactory.INVALID, el, true);
|
||||
et.addEventListener(XFormsEventFactory.OUT_OF_RANGE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_STATE_CHANGED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_PROTOTYPE_CLONED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ID_GENERATED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ITEM_INSERTED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ITEM_DELETED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_INDEX_CHANGED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_SWITCH_TOGGLED, el, true);
|
||||
}
|
||||
catch (FormBuilderException fbe)
|
||||
{
|
||||
LOGGER.error(fbe);
|
||||
}
|
||||
}
|
||||
// register for notification events
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_DONE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_ERROR, el, true);
|
||||
et.addEventListener(XFormsEventFactory.REQUIRED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.OPTIONAL, el, true);
|
||||
et.addEventListener(XFormsEventFactory.VALID, el, true);
|
||||
et.addEventListener(XFormsEventFactory.INVALID, el, true);
|
||||
et.addEventListener(XFormsEventFactory.OUT_OF_RANGE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_STATE_CHANGED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_PROTOTYPE_CLONED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ID_GENERATED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ITEM_INSERTED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ITEM_DELETED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_INDEX_CHANGED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_SWITCH_TOGGLED, el, true);
|
||||
}
|
||||
catch (FormBuilderException fbe)
|
||||
{
|
||||
LOGGER.error(fbe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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()
|
||||
throws IOException,
|
||||
XFormsException
|
||||
{
|
||||
LOGGER.debug(this + " building xform");
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
LOGGER.debug("building xform for " + this.tt.getName());
|
||||
final Node form = this.chibaBean.getXMLContainer();
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
ts.writeXML(form, out);
|
||||
}
|
||||
/**
|
||||
* 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()
|
||||
throws IOException,
|
||||
XFormsException
|
||||
{
|
||||
LOGGER.debug(this + " building xform");
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
LOGGER.debug("building xform for " + this.tt.getName());
|
||||
final Node form = this.chibaBean.getXMLContainer();
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
ts.writeXML(form, out);
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the value of a control in the processor.
|
||||
*
|
||||
* @param id the id of the control in the host document
|
||||
* @param value the new value
|
||||
* @return the list of events that may result through this action
|
||||
*/
|
||||
public void setXFormsValue()
|
||||
throws XFormsException, IOException
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
final String value = (String)requestParameters.get("value");
|
||||
/**
|
||||
* sets the value of a control in the processor.
|
||||
*
|
||||
* @param id the id of the control in the host document
|
||||
* @param value the new value
|
||||
* @return the list of events that may result through this action
|
||||
*/
|
||||
public void setXFormsValue()
|
||||
throws XFormsException, IOException
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
final String value = (String)requestParameters.get("value");
|
||||
|
||||
LOGGER.debug(this + " setXFormsValue(" + id + ", " + value + ")");
|
||||
this.chibaBean.updateControlValue(id, value);
|
||||
LOGGER.debug(this + " setXFormsValue(" + id + ", " + value + ")");
|
||||
this.chibaBean.updateControlValue(id, value);
|
||||
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the value of a control in the processor.
|
||||
*
|
||||
* @param id the id of the control in the host document
|
||||
* @param value the new value
|
||||
* @return the list of events that may result through this action
|
||||
*/
|
||||
public void setRepeatIndex()
|
||||
throws XFormsException, IOException
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
final int index = Integer.parseInt((String)requestParameters.get("index"));
|
||||
/**
|
||||
* sets the value of a control in the processor.
|
||||
*
|
||||
* @param id the id of the control in the host document
|
||||
* @param value the new value
|
||||
* @return the list of events that may result through this action
|
||||
*/
|
||||
public void setRepeatIndex()
|
||||
throws XFormsException, IOException
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
final int index = Integer.parseInt((String)requestParameters.get("index"));
|
||||
|
||||
LOGGER.debug(this + " setRepeatIndex(" + id + ", " + index + ")");
|
||||
this.chibaBean.updateRepeatIndex(id, index);
|
||||
LOGGER.debug(this + " setRepeatIndex(" + id + ", " + index + ")");
|
||||
this.chibaBean.updateRepeatIndex(id, index);
|
||||
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* fires an action associated with a trigger.
|
||||
*
|
||||
* @param id the id of the control in the host document
|
||||
*/
|
||||
public void fireAction()
|
||||
throws XFormsException, IOException
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
/**
|
||||
* fires an action associated with a trigger.
|
||||
*
|
||||
* @param id the id of the control in the host document
|
||||
*/
|
||||
public void fireAction()
|
||||
throws XFormsException, IOException
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
|
||||
LOGGER.debug(this + " fireAction(" + id + ")");
|
||||
this.chibaBean.dispatch(id, XFormsEventFactory.DOM_ACTIVATE);
|
||||
LOGGER.debug(this + " fireAction(" + id + ")");
|
||||
this.chibaBean.dispatch(id, XFormsEventFactory.DOM_ACTIVATE);
|
||||
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* handles submits and sets the instance data.
|
||||
*/
|
||||
public void handleAction()
|
||||
throws Exception
|
||||
{
|
||||
LOGGER.debug(this + " handleAction");
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final HttpServletRequest request = (HttpServletRequest)
|
||||
context.getExternalContext().getRequest();
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final Document result = ts.parseXML(request.getInputStream());
|
||||
this.instanceData.setContent(result);
|
||||
/**
|
||||
* handles submits and sets the instance data.
|
||||
*/
|
||||
public void handleAction()
|
||||
throws Exception
|
||||
{
|
||||
LOGGER.debug(this + " handleAction");
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final HttpServletRequest request = (HttpServletRequest)
|
||||
context.getExternalContext().getRequest();
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final Document result = ts.parseXML(request.getInputStream());
|
||||
this.instanceData.setContent(result);
|
||||
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(result, out);
|
||||
out.close();
|
||||
}
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(result, out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Swaps model nodes to implement reordering within repeats.
|
||||
*/
|
||||
public void swapRepeatItems()
|
||||
throws Exception
|
||||
{
|
||||
LOGGER.debug(this + " handleAction");
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final HttpServletRequest request = (HttpServletRequest)
|
||||
context.getExternalContext().getRequest();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
|
||||
private void rewriteInlineURIs(final Document schemaDocument,
|
||||
final String cwdAvmPath)
|
||||
{
|
||||
final NodeList includes =
|
||||
schemaDocument.getElementsByTagNameNS(SchemaFormBuilder.XMLSCHEMA_NS, "include");
|
||||
LOGGER.debug("rewriting " + includes.getLength() + " includes");
|
||||
for (int i = 0; i < includes.getLength(); i++)
|
||||
{
|
||||
final Element includeEl = (Element)includes.item(i);
|
||||
if (includeEl.hasAttribute("schemaLocation"))
|
||||
{
|
||||
String uri = includeEl.getAttribute("schemaLocation");
|
||||
final String baseURI = (uri.charAt(0) == '/'
|
||||
? AVMConstants.buildAVMStoreUrl(cwdAvmPath)
|
||||
: AVMConstants.buildAVMAssetUrl(cwdAvmPath));
|
||||
final String fromItemId = (String)requestParameters.get("fromItemId");
|
||||
final String toItemId = (String)requestParameters.get("toItemId");
|
||||
LOGGER.debug("swapping from " + fromItemId + " to " + toItemId);
|
||||
this.swapRepeatItems(this.chibaBean.lookup(fromItemId),
|
||||
this.chibaBean.lookup(toItemId));
|
||||
|
||||
LOGGER.debug("rewriting " + uri + " as " + (baseURI + uri));
|
||||
includeEl.setAttribute("schemaLocation", baseURI + uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the xforms based on the schema.
|
||||
*/
|
||||
private Document buildXForm(Document xmlContent,
|
||||
final Form tt,
|
||||
final String cwdAvmPath,
|
||||
final HttpServletRequest request)
|
||||
throws FormBuilderException
|
||||
{
|
||||
final Document schemaDocument = tt.getSchema();
|
||||
this.rewriteInlineURIs(schemaDocument, cwdAvmPath);
|
||||
final String baseUrl = (request.getScheme() + "://" +
|
||||
request.getServerName() + ':' +
|
||||
request.getServerPort() +
|
||||
request.getContextPath());
|
||||
LOGGER.debug("using baseUrl " + baseUrl + " for schemaformbuilder");
|
||||
final SchemaFormBuilder builder =
|
||||
new SchemaFormBuilder("/ajax/invoke/XFormsBean.handleAction",
|
||||
SchemaFormBuilder.SUBMIT_METHOD_POST,
|
||||
new XHTMLWrapperElementsBuilder(),
|
||||
baseUrl);
|
||||
LOGGER.debug("building xform for schema " + tt.getName());
|
||||
final Document result = builder.buildForm(xmlContent,
|
||||
schemaDocument,
|
||||
tt.getRootTagName());
|
||||
LOGGER.debug("generated xform: " + result);
|
||||
// LOGGER.debug(ts.writeXMLToString(result));
|
||||
return result;
|
||||
}
|
||||
private void swapRepeatItems(final XFormsElement from,
|
||||
final XFormsElement to)
|
||||
{
|
||||
LOGGER.debug("swapping repeat item " + from + " with " + to);
|
||||
|
||||
private Node getEventLog()
|
||||
{
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final Document result = ts.newDocument();
|
||||
final Element eventsElement = result.createElement("events");
|
||||
result.appendChild(eventsElement);
|
||||
for (XFormsEvent xfe : this.eventLog)
|
||||
{
|
||||
final String type = xfe.getType();
|
||||
LOGGER.debug("adding event " + type + " to the event log");
|
||||
final Element target = (Element)xfe.getTarget();
|
||||
if (from instanceof BoundElement && to instanceof BoundElement)
|
||||
{
|
||||
LOGGER.debug("from instance id " + ((BoundElement)from).getInstanceId());
|
||||
final Instance instance = from.getModel().getInstance(((BoundElement)from).getInstanceId());
|
||||
assert instance == to.getModel().getInstance(((BoundElement)to).getInstanceId());
|
||||
|
||||
final Element eventElement = result.createElement(type);
|
||||
eventsElement.appendChild(eventElement);
|
||||
eventElement.setAttribute("targetId", target.getAttributeNS(null, "id"));
|
||||
eventElement.setAttribute("targetName", target.getLocalName());
|
||||
final String fromLocationPath = ((BoundElement)from).getLocationPath();
|
||||
final ModelItem fromModelItem = instance.getModelItem(fromLocationPath);
|
||||
|
||||
final Collection properties = xfe.getPropertyNames();
|
||||
if (properties != null)
|
||||
{
|
||||
for (Object name : properties)
|
||||
{
|
||||
final Object value = xfe.getContextInfo((String)name);
|
||||
LOGGER.debug("adding property {" + name +
|
||||
":" + value + "} to event " + type);
|
||||
final Element propertyElement = result.createElement("property");
|
||||
eventElement.appendChild(propertyElement);
|
||||
propertyElement.setAttribute("name", name.toString());
|
||||
propertyElement.setAttribute("value",
|
||||
value != null ? value.toString() : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.eventLog.clear();
|
||||
return result;
|
||||
}
|
||||
final String toLocationPath = ((BoundElement)to).getLocationPath();
|
||||
final ModelItem toModelItem = instance.getModelItem(toLocationPath);
|
||||
|
||||
/**
|
||||
* stores cookies that may exist in request and passes them on to processor for usage in
|
||||
* HTTPConnectors. Instance loading and submission then uses these cookies. Important for
|
||||
* applications using auth.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void storeCookies(final javax.servlet.http.Cookie[] cookiesIn,
|
||||
final ChibaBean chibaBean){
|
||||
if (cookiesIn != null) {
|
||||
org.apache.commons.httpclient.Cookie[] commonsCookies =
|
||||
new org.apache.commons.httpclient.Cookie[cookiesIn.length];
|
||||
for (int i = 0; i < cookiesIn.length; i += 1) {
|
||||
commonsCookies[i] =
|
||||
new org.apache.commons.httpclient.Cookie(cookiesIn[i].getDomain(),
|
||||
cookiesIn[i].getName(),
|
||||
cookiesIn[i].getValue(),
|
||||
cookiesIn[i].getPath(),
|
||||
cookiesIn[i].getMaxAge(),
|
||||
cookiesIn[i].getSecure());
|
||||
}
|
||||
chibaBean.getContext().put(AbstractHTTPConnector.REQUEST_COOKIE,
|
||||
commonsCookies);
|
||||
}
|
||||
}
|
||||
LOGGER.debug("from[" + from.getId() + "] " + fromLocationPath + "=" + fromModelItem.getValue());
|
||||
LOGGER.debug("to[" + to.getId() + "] " + toLocationPath + "=" + toModelItem.getValue());
|
||||
|
||||
final Node fromNode = (Node)fromModelItem.getNode();
|
||||
final Node toNode = (Node)toModelItem.getNode();
|
||||
Node swapNode = fromNode;
|
||||
fromModelItem.setNode(toNode);
|
||||
toModelItem.setNode(swapNode);
|
||||
|
||||
final Node parentNode = fromNode.getParentNode();
|
||||
assert parentNode.equals(toNode.getParentNode());
|
||||
|
||||
swapNode = parentNode.getOwnerDocument().createTextNode("swap");
|
||||
parentNode.replaceChild(swapNode, fromNode);
|
||||
parentNode.replaceChild(fromNode, toNode);
|
||||
parentNode.replaceChild(toNode, swapNode);
|
||||
}
|
||||
}
|
||||
|
||||
private void rewriteInlineURIs(final Document schemaDocument,
|
||||
final String cwdAvmPath)
|
||||
{
|
||||
final NodeList includes =
|
||||
schemaDocument.getElementsByTagNameNS(SchemaFormBuilder.XMLSCHEMA_NS, "include");
|
||||
LOGGER.debug("rewriting " + includes.getLength() + " includes");
|
||||
for (int i = 0; i < includes.getLength(); i++)
|
||||
{
|
||||
final Element includeEl = (Element)includes.item(i);
|
||||
if (includeEl.hasAttribute("schemaLocation"))
|
||||
{
|
||||
String uri = includeEl.getAttribute("schemaLocation");
|
||||
final String baseURI = (uri.charAt(0) == '/'
|
||||
? AVMConstants.buildAVMStoreUrl(cwdAvmPath)
|
||||
: AVMConstants.buildAVMAssetUrl(cwdAvmPath));
|
||||
|
||||
LOGGER.debug("rewriting " + uri + " as " + (baseURI + uri));
|
||||
includeEl.setAttribute("schemaLocation", baseURI + uri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the xforms based on the schema.
|
||||
*/
|
||||
private Document buildXForm(Document xmlContent,
|
||||
final Form tt,
|
||||
final String cwdAvmPath,
|
||||
final HttpServletRequest request)
|
||||
throws FormBuilderException
|
||||
{
|
||||
final Document schemaDocument = tt.getSchema();
|
||||
this.rewriteInlineURIs(schemaDocument, cwdAvmPath);
|
||||
final String baseUrl = (request.getScheme() + "://" +
|
||||
request.getServerName() + ':' +
|
||||
request.getServerPort() +
|
||||
request.getContextPath());
|
||||
LOGGER.debug("using baseUrl " + baseUrl + " for schemaformbuilder");
|
||||
final SchemaFormBuilder builder =
|
||||
new SchemaFormBuilder("/ajax/invoke/XFormsBean.handleAction",
|
||||
SchemaFormBuilder.SUBMIT_METHOD_POST,
|
||||
new XHTMLWrapperElementsBuilder(),
|
||||
baseUrl);
|
||||
LOGGER.debug("building xform for schema " + tt.getName());
|
||||
final Document result = builder.buildForm(xmlContent,
|
||||
schemaDocument,
|
||||
tt.getRootTagName());
|
||||
LOGGER.debug("generated xform: " + result);
|
||||
// LOGGER.debug(ts.writeXMLToString(result));
|
||||
return result;
|
||||
}
|
||||
|
||||
private Node getEventLog()
|
||||
{
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
final Document result = ts.newDocument();
|
||||
final Element eventsElement = result.createElement("events");
|
||||
result.appendChild(eventsElement);
|
||||
for (XFormsEvent xfe : this.eventLog)
|
||||
{
|
||||
final String type = xfe.getType();
|
||||
LOGGER.debug("adding event " + type + " to the event log");
|
||||
final Element target = (Element)xfe.getTarget();
|
||||
|
||||
final Element eventElement = result.createElement(type);
|
||||
eventsElement.appendChild(eventElement);
|
||||
eventElement.setAttribute("targetId", target.getAttributeNS(null, "id"));
|
||||
eventElement.setAttribute("targetName", target.getLocalName());
|
||||
|
||||
final Collection properties = xfe.getPropertyNames();
|
||||
if (properties != null)
|
||||
{
|
||||
for (Object name : properties)
|
||||
{
|
||||
final Object value = xfe.getContextInfo((String)name);
|
||||
LOGGER.debug("adding property {" + name +
|
||||
":" + value + "} to event " + type);
|
||||
final Element propertyElement = result.createElement("property");
|
||||
eventElement.appendChild(propertyElement);
|
||||
propertyElement.setAttribute("name", name.toString());
|
||||
propertyElement.setAttribute("value",
|
||||
value != null ? value.toString() : null);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.eventLog.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* stores cookies that may exist in request and passes them on to processor for usage in
|
||||
* HTTPConnectors. Instance loading and submission then uses these cookies. Important for
|
||||
* applications using auth.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private static void storeCookies(final javax.servlet.http.Cookie[] cookiesIn,
|
||||
final ChibaBean chibaBean){
|
||||
if (cookiesIn != null) {
|
||||
org.apache.commons.httpclient.Cookie[] commonsCookies =
|
||||
new org.apache.commons.httpclient.Cookie[cookiesIn.length];
|
||||
for (int i = 0; i < cookiesIn.length; i += 1) {
|
||||
commonsCookies[i] =
|
||||
new org.apache.commons.httpclient.Cookie(cookiesIn[i].getDomain(),
|
||||
cookiesIn[i].getName(),
|
||||
cookiesIn[i].getValue(),
|
||||
cookiesIn[i].getPath(),
|
||||
cookiesIn[i].getMaxAge(),
|
||||
cookiesIn[i].getSecure());
|
||||
}
|
||||
chibaBean.getContext().put(AbstractHTTPConnector.REQUEST_COOKIE,
|
||||
commonsCookies);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user