mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
adding the ability to save a draft from the xforms ui. currently this is only surfaced when clicking back in the create web content wizard (it saves a draft so that entered values don't get blown away).
also fixing a couple bugs related to namespaces within instance data. being more rigorous about placing the namespace prefix in the right place basically. removing the wrapperelementbuilders from the schemaformbuilder. they were confusing and not used anywhere. (reduces cruft from the schemaformbuilder). git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4816 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -224,6 +224,15 @@ public class FormImpl
|
|||||||
"}");
|
"}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean equals(final Object other)
|
||||||
|
{
|
||||||
|
if (other == null || !(other instanceof FormImpl))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return this.getNodeRef().equals(((FormImpl)other).getNodeRef());
|
||||||
|
}
|
||||||
|
|
||||||
protected ServiceRegistry getServiceRegistry()
|
protected ServiceRegistry getServiceRegistry()
|
||||||
{
|
{
|
||||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
|
@@ -142,7 +142,6 @@ public class SchemaFormBuilder
|
|||||||
private final String action;
|
private final String action;
|
||||||
private final SubmitMethod submitMethod;
|
private final SubmitMethod submitMethod;
|
||||||
private final String base;
|
private final String base;
|
||||||
protected WrapperElementsBuilder wrapper = new XHTMLWrapperElementsBuilder();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* generic counter -> replaced by an hashMap with:
|
* generic counter -> replaced by an hashMap with:
|
||||||
@@ -167,22 +166,17 @@ public class SchemaFormBuilder
|
|||||||
/**
|
/**
|
||||||
* Creates a new SchemaFormBuilder object.
|
* Creates a new SchemaFormBuilder object.
|
||||||
*
|
*
|
||||||
* @param rootElementName _UNDOCUMENTED_
|
|
||||||
* @param instanceSource _UNDOCUMENTED_
|
|
||||||
* @param action _UNDOCUMENTED_
|
* @param action _UNDOCUMENTED_
|
||||||
* @param submitMethod _UNDOCUMENTED_
|
* @param submitMethod _UNDOCUMENTED_
|
||||||
* @param wrapper _UNDOCUMENTED_
|
|
||||||
*/
|
*/
|
||||||
public SchemaFormBuilder(final String action,
|
public SchemaFormBuilder(final String action,
|
||||||
final SubmitMethod submitMethod,
|
final SubmitMethod submitMethod,
|
||||||
final WrapperElementsBuilder wrapper,
|
|
||||||
final String base)
|
final String base)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.submitMethod = submitMethod;
|
this.submitMethod = submitMethod;
|
||||||
this.wrapper = wrapper;
|
|
||||||
this.base = base;
|
this.base = base;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,18 +244,19 @@ public class SchemaFormBuilder
|
|||||||
//refCounter = 0;
|
//refCounter = 0;
|
||||||
this.counter.clear();
|
this.counter.clear();
|
||||||
|
|
||||||
final Document xForm = this.createFormTemplate(rootElementName);
|
final Document xformsDocument = this.createFormTemplate(rootElementName);
|
||||||
|
|
||||||
//find form element: last element created
|
//find form element: last element created
|
||||||
final Element formSection = (Element)
|
final Element formSection = (Element)
|
||||||
xForm.getDocumentElement().getLastChild();
|
xformsDocument.getDocumentElement().getLastChild();
|
||||||
final Element modelSection = (Element)
|
final Element modelSection = (Element)
|
||||||
xForm.getDocumentElement().getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, "model").item(0);
|
xformsDocument.getDocumentElement().getElementsByTagNameNS(NamespaceConstants.XFORMS_NS,
|
||||||
|
"model").item(0);
|
||||||
|
|
||||||
//add XMLSchema if we use schema types
|
//add XMLSchema if we use schema types
|
||||||
modelSection.setAttributeNS(NamespaceConstants.XFORMS_NS, "schema", "#schema-1");
|
modelSection.setAttributeNS(NamespaceConstants.XFORMS_NS, "schema", "#schema-1");
|
||||||
final Element importedSchemaDocumentElement = (Element)
|
final Element importedSchemaDocumentElement = (Element)
|
||||||
xForm.importNode(schemaDocument.getDocumentElement(), true);
|
xformsDocument.importNode(schemaDocument.getDocumentElement(), true);
|
||||||
importedSchemaDocumentElement.setAttributeNS(null, "id", "schema-1");
|
importedSchemaDocumentElement.setAttributeNS(null, "id", "schema-1");
|
||||||
|
|
||||||
modelSection.appendChild(importedSchemaDocumentElement);
|
modelSection.appendChild(importedSchemaDocumentElement);
|
||||||
@@ -282,50 +277,55 @@ public class SchemaFormBuilder
|
|||||||
// this.targetNamespace);
|
// this.targetNamespace);
|
||||||
|
|
||||||
|
|
||||||
//TODO: WARNING: in Xerces 2.6.1, parameters are switched !!! (name, namespace)
|
final XSElementDeclaration rootElementDecl =
|
||||||
//XSElementDeclaration rootElementDecl =schema.getElementDeclaration(this.targetNamespace, _rootElementName);
|
|
||||||
XSElementDeclaration rootElementDecl =
|
|
||||||
schema.getElementDeclaration(rootElementName, this.targetNamespace);
|
schema.getElementDeclaration(rootElementName, this.targetNamespace);
|
||||||
|
|
||||||
if (rootElementDecl == null)
|
if (rootElementDecl == null)
|
||||||
{
|
{
|
||||||
//Debug
|
|
||||||
rootElementDecl = schema.getElementDeclaration(this.targetNamespace,
|
|
||||||
rootElementName);
|
|
||||||
if (rootElementDecl != null && LOGGER.isDebugEnabled())
|
|
||||||
LOGGER.debug("getElementDeclaration: inversed parameters OK !!!");
|
|
||||||
|
|
||||||
throw new FormBuilderException("Invalid root element tag name ["
|
throw new FormBuilderException("Invalid root element tag name ["
|
||||||
+ rootElementName
|
+ rootElementName
|
||||||
+ ", targetNamespace="
|
+ ", targetNamespace="
|
||||||
+ this.targetNamespace
|
+ this.targetNamespace
|
||||||
+ "]");
|
+ "]");
|
||||||
}
|
}
|
||||||
rootElementName = this.getElementName(rootElementDecl, xForm);
|
|
||||||
|
rootElementName = this.getElementName(rootElementDecl, xformsDocument);
|
||||||
final Element instanceElement =
|
final Element instanceElement =
|
||||||
xForm.createElementNS(NamespaceConstants.XFORMS_NS,
|
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":instance");
|
NamespaceConstants.XFORMS_PREFIX + ":instance");
|
||||||
modelSection.appendChild(instanceElement);
|
modelSection.appendChild(instanceElement);
|
||||||
this.setXFormsId(instanceElement);
|
this.setXFormsId(instanceElement);
|
||||||
|
|
||||||
final Element defaultInstanceDocumentElement = xForm.createElement(rootElementName);
|
final Element defaultInstanceDocumentElement = xformsDocument.createElement(rootElementName);
|
||||||
this.addNamespace(defaultInstanceDocumentElement,
|
this.addNamespace(defaultInstanceDocumentElement,
|
||||||
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX,
|
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX,
|
||||||
NamespaceConstants.XMLSCHEMA_INSTANCE_NS);
|
NamespaceConstants.XMLSCHEMA_INSTANCE_NS);
|
||||||
|
if (this.targetNamespace != null)
|
||||||
|
{
|
||||||
|
this.addNamespace(defaultInstanceDocumentElement,
|
||||||
|
schemaDocument.lookupPrefix(this.targetNamespace),
|
||||||
|
this.targetNamespace);
|
||||||
|
this.addNamespace(xformsDocument.getDocumentElement(),
|
||||||
|
schemaDocument.lookupPrefix(this.targetNamespace),
|
||||||
|
this.targetNamespace);
|
||||||
|
}
|
||||||
|
|
||||||
Element importedInstanceDocumentElement = null;
|
Element importedInstanceDocumentElement = null;
|
||||||
if (instanceDocument == null || instanceDocument.getDocumentElement() == null)
|
if (instanceDocument == null || instanceDocument.getDocumentElement() == null)
|
||||||
|
{
|
||||||
instanceElement.appendChild(defaultInstanceDocumentElement);
|
instanceElement.appendChild(defaultInstanceDocumentElement);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Element instanceDocumentElement = instanceDocument.getDocumentElement();
|
Element instanceDocumentElement = instanceDocument.getDocumentElement();
|
||||||
if (!instanceDocumentElement.getNodeName().equals(rootElementName))
|
if (!instanceDocumentElement.getNodeName().equals(rootElementName))
|
||||||
|
{
|
||||||
throw new IllegalArgumentException("instance document root tag name invalid. " +
|
throw new IllegalArgumentException("instance document root tag name invalid. " +
|
||||||
"expected " + rootElementName +
|
"expected " + rootElementName +
|
||||||
", got " + instanceDocumentElement.getNodeName());
|
", got " + instanceDocumentElement.getNodeName());
|
||||||
|
}
|
||||||
LOGGER.debug("importing rootElement from other document");
|
LOGGER.debug("importing rootElement from other document");
|
||||||
importedInstanceDocumentElement = (Element)
|
importedInstanceDocumentElement = (Element)
|
||||||
xForm.importNode(instanceDocumentElement, true);
|
xformsDocument.importNode(instanceDocumentElement, true);
|
||||||
//add XMLSchema instance NS
|
//add XMLSchema instance NS
|
||||||
this.addNamespace(importedInstanceDocumentElement,
|
this.addNamespace(importedInstanceDocumentElement,
|
||||||
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX,
|
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX,
|
||||||
@@ -333,21 +333,21 @@ public class SchemaFormBuilder
|
|||||||
instanceElement.appendChild(importedInstanceDocumentElement);
|
instanceElement.appendChild(importedInstanceDocumentElement);
|
||||||
|
|
||||||
final Element prototypeInstanceElement =
|
final Element prototypeInstanceElement =
|
||||||
xForm.createElementNS(NamespaceConstants.XFORMS_NS,
|
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":instance");
|
NamespaceConstants.XFORMS_PREFIX + ":instance");
|
||||||
modelSection.appendChild(prototypeInstanceElement);
|
modelSection.appendChild(prototypeInstanceElement);
|
||||||
this.setXFormsId(prototypeInstanceElement, "instance_prototype");
|
this.setXFormsId(prototypeInstanceElement, "instance_prototype");
|
||||||
prototypeInstanceElement.appendChild(defaultInstanceDocumentElement);
|
prototypeInstanceElement.appendChild(defaultInstanceDocumentElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element formContentWrapper = this.wrapper.createGroupContentWrapper(formSection);
|
Element formContentWrapper = formSection;
|
||||||
this.addElement(xForm,
|
this.addElement(xformsDocument,
|
||||||
modelSection,
|
modelSection,
|
||||||
defaultInstanceDocumentElement,
|
defaultInstanceDocumentElement,
|
||||||
formContentWrapper,
|
formContentWrapper,
|
||||||
schema,
|
schema,
|
||||||
rootElementDecl,
|
rootElementDecl,
|
||||||
"/" + getElementName(rootElementDecl, xForm),
|
"/" + getElementName(rootElementDecl, xformsDocument),
|
||||||
resourceBundle);
|
resourceBundle);
|
||||||
if (importedInstanceDocumentElement != null)
|
if (importedInstanceDocumentElement != null)
|
||||||
{
|
{
|
||||||
@@ -355,50 +355,16 @@ public class SchemaFormBuilder
|
|||||||
defaultInstanceDocumentElement);
|
defaultInstanceDocumentElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element submitInfoElement =
|
this.createSubmitElements(xformsDocument, modelSection, formContentWrapper);
|
||||||
xForm.createElementNS(NamespaceConstants.XFORMS_NS,
|
this.createTriggersForRepeats(xformsDocument);
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":submission");
|
|
||||||
modelSection.appendChild(submitInfoElement);
|
|
||||||
|
|
||||||
//submitInfoElement.setAttributeNS(NamespaceConstants.XFORMS_NS,NamespaceConstants.XFORMS_PREFIX + ":id","save");
|
|
||||||
String submissionId = this.setXFormsId(submitInfoElement);
|
|
||||||
|
|
||||||
//action
|
|
||||||
submitInfoElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":action",
|
|
||||||
this.action == null ? "" : this.base + this.action);
|
|
||||||
|
|
||||||
//method
|
|
||||||
submitInfoElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":method",
|
|
||||||
(this.submitMethod != null
|
|
||||||
? this.submitMethod
|
|
||||||
: SchemaFormBuilder.SubmitMethod.POST).toString());
|
|
||||||
|
|
||||||
final Element submitButton =
|
|
||||||
xForm.createElementNS(NamespaceConstants.XFORMS_NS, NamespaceConstants.XFORMS_PREFIX + ":submit");
|
|
||||||
final Element submitControlWrapper = this.wrapper.createControlsWrapper(submitButton);
|
|
||||||
formContentWrapper.appendChild(submitControlWrapper);
|
|
||||||
submitButton.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":submission",
|
|
||||||
submissionId);
|
|
||||||
this.setXFormsId(submitButton);
|
|
||||||
|
|
||||||
final Element submitButtonCaption =
|
|
||||||
xForm.createElementNS(NamespaceConstants.XFORMS_NS,
|
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":label");
|
|
||||||
submitButton.appendChild(submitButtonCaption);
|
|
||||||
submitButtonCaption.appendChild(xForm.createTextNode("Submit"));
|
|
||||||
this.setXFormsId(submitButtonCaption);
|
|
||||||
this.createTriggersForRepeats(xForm);
|
|
||||||
|
|
||||||
final Comment comment =
|
final Comment comment =
|
||||||
xForm.createComment("This XForm was generated by " + this.getClass().getName() +
|
xformsDocument.createComment("This XForm was generated by " + this.getClass().getName() +
|
||||||
" on " + (new Date()) + " from the '" + rootElementName +
|
" on " + (new Date()) + " from the '" + rootElementName +
|
||||||
"' element of the '" + this.targetNamespace + "' XML Schema.");
|
"' element of the '" + this.targetNamespace + "' XML Schema.");
|
||||||
xForm.getDocumentElement().insertBefore(comment,
|
xformsDocument.getDocumentElement().insertBefore(comment,
|
||||||
xForm.getDocumentElement().getFirstChild());
|
xformsDocument.getDocumentElement().getFirstChild());
|
||||||
return xForm;
|
return xformsDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -888,8 +854,9 @@ public class SchemaFormBuilder
|
|||||||
Element groupWrapper = groupElement;
|
Element groupWrapper = groupElement;
|
||||||
|
|
||||||
if (groupElement != modelSection)
|
if (groupElement != modelSection)
|
||||||
groupWrapper = this.wrapper.createGroupContentWrapper(groupElement);
|
{
|
||||||
|
groupWrapper = groupElement;
|
||||||
|
}
|
||||||
final SchemaUtil.Occurance o = SchemaUtil.getOccurance(owner);
|
final SchemaUtil.Occurance o = SchemaUtil.getOccurance(owner);
|
||||||
final Element repeatSection = this.addRepeatIfNecessary(xForm,
|
final Element repeatSection = this.addRepeatIfNecessary(xForm,
|
||||||
modelSection,
|
modelSection,
|
||||||
@@ -902,7 +869,7 @@ public class SchemaFormBuilder
|
|||||||
if (repeatSection != groupWrapper)
|
if (repeatSection != groupWrapper)
|
||||||
{
|
{
|
||||||
// we have a repeat
|
// we have a repeat
|
||||||
repeatContentWrapper = this.wrapper.createGroupContentWrapper(repeatSection);
|
repeatContentWrapper = repeatSection;
|
||||||
relative = true;
|
relative = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1278,11 +1245,8 @@ public class SchemaFormBuilder
|
|||||||
constraint);
|
constraint);
|
||||||
}
|
}
|
||||||
|
|
||||||
Element choicesControlWrapper = this.wrapper.createControlsWrapper(choices);
|
control.appendChild(choices);
|
||||||
control.appendChild(choicesControlWrapper);
|
formSection.appendChild(control);
|
||||||
|
|
||||||
Element controlWrapper = this.wrapper.createControlsWrapper(control);
|
|
||||||
formSection.appendChild(controlWrapper);
|
|
||||||
|
|
||||||
///////////////// ///////////////
|
///////////////// ///////////////
|
||||||
// add content to select1
|
// add content to select1
|
||||||
@@ -1322,9 +1286,7 @@ public class SchemaFormBuilder
|
|||||||
NamespaceConstants.XFORMS_PREFIX + ":switch");
|
NamespaceConstants.XFORMS_PREFIX + ":switch");
|
||||||
this.setXFormsId(switchElement);
|
this.setXFormsId(switchElement);
|
||||||
|
|
||||||
Element switchControlWrapper =
|
formSection.appendChild(switchElement);
|
||||||
this.wrapper.createControlsWrapper(switchElement);
|
|
||||||
formSection.appendChild(switchControlWrapper);
|
|
||||||
//formSection.appendChild(switchElement);
|
//formSection.appendChild(switchElement);
|
||||||
|
|
||||||
/////////////// add this type //////////////
|
/////////////// add this type //////////////
|
||||||
@@ -1539,8 +1501,7 @@ public class SchemaFormBuilder
|
|||||||
//selector -> no more needed?
|
//selector -> no more needed?
|
||||||
//this.addSelector(xForm, repeatSection);
|
//this.addSelector(xForm, repeatSection);
|
||||||
//group wrapper
|
//group wrapper
|
||||||
repeatContentWrapper =
|
repeatContentWrapper = repeatSection;
|
||||||
this.wrapper.createGroupContentWrapper(repeatSection);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
@@ -1758,9 +1719,7 @@ public class SchemaFormBuilder
|
|||||||
NamespaceConstants.XFORMS_PREFIX + ":appearance",
|
NamespaceConstants.XFORMS_PREFIX + ":appearance",
|
||||||
"full");
|
"full");
|
||||||
|
|
||||||
final Element controlWrapper =
|
formSection.appendChild(repeatSection);
|
||||||
this.wrapper.createControlsWrapper(repeatSection);
|
|
||||||
formSection.appendChild(controlWrapper);
|
|
||||||
|
|
||||||
//add a group inside the repeat?
|
//add a group inside the repeat?
|
||||||
final Element group = xForm.createElementNS(NamespaceConstants.XFORMS_NS,
|
final Element group = xForm.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
@@ -1812,9 +1771,7 @@ public class SchemaFormBuilder
|
|||||||
(XSElementDeclaration)owner,
|
(XSElementDeclaration)owner,
|
||||||
resourceBundle);
|
resourceBundle);
|
||||||
//set content
|
//set content
|
||||||
formSection = (groupElement == modelSection
|
formSection = groupElement;
|
||||||
? groupElement
|
|
||||||
: this.wrapper.createGroupContentWrapper(groupElement));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//eventual repeat
|
//eventual repeat
|
||||||
@@ -1832,7 +1789,7 @@ public class SchemaFormBuilder
|
|||||||
if (repeatSection != formSection)
|
if (repeatSection != formSection)
|
||||||
{
|
{
|
||||||
//content of repeat
|
//content of repeat
|
||||||
contentWrapper = this.wrapper.createGroupContentWrapper(repeatSection);
|
contentWrapper = repeatSection;
|
||||||
|
|
||||||
//if there is a repeat -> create another bind with "."
|
//if there is a repeat -> create another bind with "."
|
||||||
Element bindElement2 =
|
Element bindElement2 =
|
||||||
@@ -1860,7 +1817,7 @@ public class SchemaFormBuilder
|
|||||||
bindElement,
|
bindElement,
|
||||||
o,
|
o,
|
||||||
resourceBundle);
|
resourceBundle);
|
||||||
contentWrapper.appendChild(this.wrapper.createControlsWrapper(formControl));
|
contentWrapper.appendChild(formControl);
|
||||||
|
|
||||||
// if this is a repeatable then set ref to point to current element
|
// if this is a repeatable then set ref to point to current element
|
||||||
// not sure if this is a workaround or this is just the way XForms works...
|
// not sure if this is a workaround or this is just the way XForms works...
|
||||||
@@ -1878,9 +1835,6 @@ public class SchemaFormBuilder
|
|||||||
//if (repeatSection != formSection)
|
//if (repeatSection != formSection)
|
||||||
//this.addSelector(xForm, (Element) formControl.getParentNode());
|
//this.addSelector(xForm, (Element) formControl.getParentNode());
|
||||||
//
|
//
|
||||||
// TODO: Generate help message based on datatype and restrictions
|
|
||||||
this.endFormControl(formControl, controlType, o);
|
|
||||||
this.endBindElement(bindElement);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSimpleType(final Document xForm,
|
private void addSimpleType(final Document xForm,
|
||||||
@@ -1966,7 +1920,6 @@ public class SchemaFormBuilder
|
|||||||
(XSSimpleTypeDefinition)controlType);
|
(XSSimpleTypeDefinition)controlType);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.startFormControl(formControl, controlType);
|
|
||||||
formControl.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
formControl.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":bind",
|
NamespaceConstants.XFORMS_PREFIX + ":bind",
|
||||||
bindId);
|
bindId);
|
||||||
@@ -2063,7 +2016,14 @@ public class SchemaFormBuilder
|
|||||||
{
|
{
|
||||||
final Document xformsDocument = XMLUtil.newDocument();
|
final Document xformsDocument = XMLUtil.newDocument();
|
||||||
|
|
||||||
final Element envelopeElement = this.wrapper.createEnvelope(xformsDocument);
|
final Element envelopeElement = xformsDocument.createElementNS(NamespaceConstants.XHTML_NS,
|
||||||
|
NamespaceConstants.XHTML_PREFIX + ":html");
|
||||||
|
xformsDocument.appendChild(envelopeElement);
|
||||||
|
|
||||||
|
//set namespace attribute
|
||||||
|
this.addNamespace(envelopeElement,
|
||||||
|
NamespaceConstants.XHTML_PREFIX,
|
||||||
|
NamespaceConstants.XHTML_NS);
|
||||||
this.addNamespace(envelopeElement,
|
this.addNamespace(envelopeElement,
|
||||||
NamespaceConstants.XFORMS_PREFIX,
|
NamespaceConstants.XFORMS_PREFIX,
|
||||||
NamespaceConstants.XFORMS_NS);
|
NamespaceConstants.XFORMS_NS);
|
||||||
@@ -2079,22 +2039,27 @@ public class SchemaFormBuilder
|
|||||||
|
|
||||||
//base
|
//base
|
||||||
if (this.base != null && this.base.length() != 0)
|
if (this.base != null && this.base.length() != 0)
|
||||||
|
{
|
||||||
envelopeElement.setAttributeNS(NamespaceConstants.XML_NS,
|
envelopeElement.setAttributeNS(NamespaceConstants.XML_NS,
|
||||||
NamespaceConstants.XML_PREFIX + ":base",
|
NamespaceConstants.XML_PREFIX + ":base",
|
||||||
this.base);
|
this.base);
|
||||||
|
}
|
||||||
|
|
||||||
//model element
|
//model element
|
||||||
Element modelElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
Element modelElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":model");
|
NamespaceConstants.XFORMS_PREFIX + ":model");
|
||||||
this.setXFormsId(modelElement);
|
this.setXFormsId(modelElement);
|
||||||
Element modelWrapper = this.wrapper.createModelWrapper(modelElement);
|
Element modelWrapper = xformsDocument.createElementNS(NamespaceConstants.XHTML_NS,
|
||||||
|
NamespaceConstants.XHTML_PREFIX + ":head");
|
||||||
|
modelWrapper.appendChild(modelElement);
|
||||||
envelopeElement.appendChild(modelWrapper);
|
envelopeElement.appendChild(modelWrapper);
|
||||||
|
|
||||||
//form control wrapper -> created by wrapper
|
//form control wrapper -> created by wrapper
|
||||||
//Element formWrapper = xformsDocument.createElement("body");
|
//Element formWrapper = xformsDocument.createElement("body");
|
||||||
//envelopeElement.appendChild(formWrapper);
|
//envelopeElement.appendChild(formWrapper);
|
||||||
Element formWrapper = this.wrapper.createFormWrapper(envelopeElement);
|
Element formWrapper = xformsDocument.createElementNS(NamespaceConstants.XHTML_NS,
|
||||||
|
NamespaceConstants.XHTML_PREFIX + ":body");
|
||||||
|
envelopeElement.appendChild(formWrapper);
|
||||||
return xformsDocument;
|
return xformsDocument;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2108,26 +2073,17 @@ public class SchemaFormBuilder
|
|||||||
Element groupElement =
|
Element groupElement =
|
||||||
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":group");
|
NamespaceConstants.XFORMS_PREFIX + ":group");
|
||||||
groupElement = startFormGroup(groupElement, owner);
|
this.setXFormsId(groupElement);
|
||||||
|
|
||||||
if (groupElement == null)
|
//groupElement = (Element) formSection.appendChild(groupElement);
|
||||||
groupElement = modelSection;
|
formSection.appendChild(groupElement);
|
||||||
else
|
|
||||||
{
|
Element captionElement =
|
||||||
this.setXFormsId(groupElement);
|
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
|
NamespaceConstants.XFORMS_PREFIX + ":label");
|
||||||
Element controlsWrapper = this.wrapper.createControlsWrapper(groupElement);
|
groupElement.appendChild(captionElement);
|
||||||
|
this.setXFormsId(captionElement);
|
||||||
//groupElement = (Element) formSection.appendChild(groupElement);
|
captionElement.appendChild(xformsDocument.createTextNode(this.createCaption(owner, resourceBundle)));
|
||||||
formSection.appendChild(controlsWrapper);
|
|
||||||
|
|
||||||
Element captionElement =
|
|
||||||
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
|
||||||
NamespaceConstants.XFORMS_PREFIX + ":label");
|
|
||||||
groupElement.appendChild(captionElement);
|
|
||||||
this.setXFormsId(captionElement);
|
|
||||||
captionElement.appendChild(xformsDocument.createTextNode(this.createCaption(owner, resourceBundle)));
|
|
||||||
}
|
|
||||||
return groupElement;
|
return groupElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2557,31 +2513,6 @@ public class SchemaFormBuilder
|
|||||||
: null)));
|
: null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after the form builder is finished creating and processing
|
|
||||||
* a bind element. Implementations may choose to use this method to add/inspect/modify
|
|
||||||
* the bindElement prior to the builder moving onto the next bind element.
|
|
||||||
*
|
|
||||||
* @param bindElement The bind element being processed.
|
|
||||||
*/
|
|
||||||
public void endBindElement(Element bindElement)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after the form builder is finished creating and processing
|
|
||||||
* a form control. Implementations may choose to use this method to add/inspect/modify
|
|
||||||
* the controlElement prior to the builder moving onto the next control.
|
|
||||||
*
|
|
||||||
* @param controlElement The form control element that was created.
|
|
||||||
* @param controlType The XML Schema type for which <b>controlElement</b> was created.
|
|
||||||
*/
|
|
||||||
public void endFormControl(Element controlElement,
|
|
||||||
XSTypeDefinition controlType,
|
|
||||||
SchemaUtil.Occurance occurs)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is invoked after an xforms:bind element is created for the specified SimpleType.
|
* This method is invoked after an xforms:bind element is created for the specified SimpleType.
|
||||||
* The implementation is responsible for setting setting any/all bind attributes
|
* The implementation is responsible for setting setting any/all bind attributes
|
||||||
@@ -2690,43 +2621,6 @@ public class SchemaFormBuilder
|
|||||||
return bindElement;
|
return bindElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after the form builder creates a form control
|
|
||||||
* via a createControlForXXX() method but prior to decorating the form control
|
|
||||||
* with common attributes such as a caption, hint, help text elements,
|
|
||||||
* bind attributes, etc.
|
|
||||||
* The returned element is used in the XForm in place of controlElement.
|
|
||||||
* Implementations may choose to use this method to substitute controlElement
|
|
||||||
* with a different element, or perform any other processing on controlElement
|
|
||||||
* prior to it being added to the form.
|
|
||||||
*
|
|
||||||
* @param controlElement The form control element that was created.
|
|
||||||
* @param controlType The XML Schema type for which <b>controlElement</b> was created.
|
|
||||||
* @return The Element to use in the XForm - controlElement or a replacement.
|
|
||||||
*/
|
|
||||||
public Element startFormControl(Element controlElement,
|
|
||||||
XSTypeDefinition controlType)
|
|
||||||
{
|
|
||||||
return controlElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after an xforms:group element is created for the specified
|
|
||||||
* ElementDecl. A group is created whenever an element is encountered in the XML Schema
|
|
||||||
* that contains other elements and attributes (complex types or mixed content types).
|
|
||||||
* The caller automatically adds the returned element to the XForm.
|
|
||||||
*
|
|
||||||
* @param groupElement The groupElement being processed.
|
|
||||||
* @param schemaElement The schemaElement for the group.
|
|
||||||
* @return The group Element to use in the XForm - groupElement or a replacement. If a null
|
|
||||||
* value is returned, the group is not created.
|
|
||||||
*/
|
|
||||||
public Element startFormGroup(Element groupElement,
|
|
||||||
XSElementDeclaration schemaElement)
|
|
||||||
{
|
|
||||||
return groupElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a fully qualified name for this element, and eventually declares a new prefix for the namespace if
|
* Get a fully qualified name for this element, and eventually declares a new prefix for the namespace if
|
||||||
* it was not declared before
|
* it was not declared before
|
||||||
@@ -2766,10 +2660,14 @@ public class SchemaFormBuilder
|
|||||||
final String nsPrefix,
|
final String nsPrefix,
|
||||||
final String ns)
|
final String ns)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!e.hasAttributeNS(NamespaceConstants.XMLNS_NS, nsPrefix))
|
if (!e.hasAttributeNS(NamespaceConstants.XMLNS_NS, nsPrefix))
|
||||||
|
{
|
||||||
|
LOGGER.debug("adding namespace " + ns + " to " + e.getNodeType() + "(" + e.getNodeName() + ")");
|
||||||
e.setAttributeNS(NamespaceConstants.XMLNS_NS,
|
e.setAttributeNS(NamespaceConstants.XMLNS_NS,
|
||||||
NamespaceConstants.XMLNS_PREFIX + ':' + nsPrefix,
|
NamespaceConstants.XMLNS_PREFIX + ':' + nsPrefix,
|
||||||
ns);
|
ns);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createTriggersForRepeats(final Document xformsDocument)
|
private void createTriggersForRepeats(final Document xformsDocument)
|
||||||
@@ -2929,27 +2827,79 @@ public class SchemaFormBuilder
|
|||||||
|
|
||||||
final Element formSection = (Element)xformsDocument.getDocumentElement().getLastChild();
|
final Element formSection = (Element)xformsDocument.getDocumentElement().getLastChild();
|
||||||
//add the triggers
|
//add the triggers
|
||||||
final Element wrapper_triggers =
|
formSection.appendChild(trigger_insert_before);
|
||||||
this.wrapper.createControlsWrapper(trigger_insert_before);
|
formSection.appendChild(trigger_insert_after);
|
||||||
|
formSection.appendChild(trigger_delete);
|
||||||
|
}
|
||||||
|
|
||||||
if (wrapper_triggers == trigger_insert_before)
|
private Element createSubmissionElement(final Document xformDocument,
|
||||||
{
|
final String id,
|
||||||
//no wrapper
|
final boolean validate)
|
||||||
formSection.appendChild(trigger_insert_before);
|
{
|
||||||
formSection.appendChild(trigger_insert_after);
|
final Element result = xformDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
formSection.appendChild(trigger_delete);
|
NamespaceConstants.XFORMS_PREFIX + ":submission");
|
||||||
}
|
|
||||||
else
|
this.setXFormsId(result, id);
|
||||||
{
|
|
||||||
formSection.appendChild(wrapper_triggers);
|
|
||||||
final Element insert_parent = (Element)trigger_insert_before.getParentNode();
|
|
||||||
|
|
||||||
if (insert_parent != null)
|
result.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
||||||
{
|
NamespaceConstants.XFORMS_PREFIX + ":validate",
|
||||||
insert_parent.appendChild(trigger_insert_after);
|
validate ? "true" : "false");
|
||||||
insert_parent.appendChild(trigger_delete);
|
|
||||||
}
|
result.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
||||||
}
|
NamespaceConstants.XFORMS_PREFIX + ":action",
|
||||||
|
this.action == null ? "" : this.base + this.action);
|
||||||
|
|
||||||
|
result.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
||||||
|
NamespaceConstants.XFORMS_PREFIX + ":method",
|
||||||
|
(this.submitMethod != null
|
||||||
|
? this.submitMethod
|
||||||
|
: SchemaFormBuilder.SubmitMethod.POST).toString());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Element createSubmitControl(final Document xformsDocument,
|
||||||
|
final Element submission,
|
||||||
|
final String id,
|
||||||
|
final String label)
|
||||||
|
{
|
||||||
|
final Element result = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
|
NamespaceConstants.XFORMS_PREFIX + ":submit");
|
||||||
|
result.setAttributeNS(NamespaceConstants.XFORMS_NS,
|
||||||
|
NamespaceConstants.XFORMS_PREFIX + ":submission",
|
||||||
|
submission.getAttributeNS(null, "id"));
|
||||||
|
this.setXFormsId(result, id);
|
||||||
|
|
||||||
|
final Element caption =
|
||||||
|
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
|
||||||
|
NamespaceConstants.XFORMS_PREFIX + ":label");
|
||||||
|
result.appendChild(caption);
|
||||||
|
caption.appendChild(xformsDocument.createTextNode(label));
|
||||||
|
this.setXFormsId(caption);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void createSubmitElements(final Document xformsDocument,
|
||||||
|
final Element modelSection,
|
||||||
|
final Element formSection)
|
||||||
|
{
|
||||||
|
|
||||||
|
Element submission = this.createSubmissionElement(xformsDocument, "submission-validate", true);
|
||||||
|
modelSection.appendChild(submission);
|
||||||
|
|
||||||
|
Element submit = this.createSubmitControl(xformsDocument,
|
||||||
|
submission,
|
||||||
|
"submit",
|
||||||
|
"Submit");
|
||||||
|
formSection.appendChild(submit);
|
||||||
|
|
||||||
|
submission = this.createSubmissionElement(xformsDocument, "submission-draft", false);
|
||||||
|
modelSection.appendChild(submission);
|
||||||
|
|
||||||
|
submit = this.createSubmitControl(xformsDocument,
|
||||||
|
submission,
|
||||||
|
"save-draft",
|
||||||
|
"Save Draft");
|
||||||
|
formSection.appendChild(submit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Element createXFormsItem(final Document xformsDocument,
|
private Element createXFormsItem(final Document xformsDocument,
|
||||||
|
@@ -1,71 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005 Alfresco, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
|
||||||
* with a permitted attribution clause. You may obtain a
|
|
||||||
* copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.alfresco.org/legal/license.txt
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
||||||
* either express or implied. See the License for the specific
|
|
||||||
* language governing permissions and limitations under the
|
|
||||||
* License.
|
|
||||||
*/
|
|
||||||
package org.alfresco.web.forms.xforms;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This interface provides methods to create the "wrappers" elements that will contain the XForms document.
|
|
||||||
* These elements can be:
|
|
||||||
* - the first "enveloppe" element
|
|
||||||
* - other elements specific to a destination language or platform (ex: XHTML tags)
|
|
||||||
*
|
|
||||||
* @author Sophie Ramel
|
|
||||||
*/
|
|
||||||
public interface WrapperElementsBuilder
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the wrapper element of the form (exemple_ "body" for HTML)
|
|
||||||
*
|
|
||||||
* @param enveloppeElement the containing enveloppe
|
|
||||||
* @return the wrapper element, already added in the enveloppe
|
|
||||||
*/
|
|
||||||
public Element createFormWrapper(Element enveloppeElement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the wrapper element of the different controls
|
|
||||||
*
|
|
||||||
* @param controlElement the control element (input, select, repeat, group, ...)
|
|
||||||
* @return the wrapper element, already containing the control element
|
|
||||||
*/
|
|
||||||
public Element createControlsWrapper(Element controlElement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates the global enveloppe of the resulting document, and puts it in the document
|
|
||||||
*
|
|
||||||
* @return the enveloppe
|
|
||||||
*/
|
|
||||||
public Element createEnvelope(Document xForm);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the element that will contain the content of the group (or repeat) element
|
|
||||||
*
|
|
||||||
* @param groupElement the group or repeat element
|
|
||||||
* @return - the wrapper element, already containing the content of the group element
|
|
||||||
*/
|
|
||||||
public Element createGroupContentWrapper(Element groupElement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the wrapper element of the xforms:model element
|
|
||||||
*
|
|
||||||
* @param modelElement the xforms:model element
|
|
||||||
* @return - the wrapper element, already containing the model
|
|
||||||
*/
|
|
||||||
public Element createModelWrapper(Element modelElement);
|
|
||||||
}
|
|
@@ -112,7 +112,6 @@ public class XFormsBean
|
|||||||
this.schemaFormBuilder =
|
this.schemaFormBuilder =
|
||||||
new SchemaFormBuilder("/ajax/invoke/XFormsBean.handleAction",
|
new SchemaFormBuilder("/ajax/invoke/XFormsBean.handleAction",
|
||||||
SchemaFormBuilder.SubmitMethod.POST,
|
SchemaFormBuilder.SubmitMethod.POST,
|
||||||
new XHTMLWrapperElementsBuilder(),
|
|
||||||
baseUrl);
|
baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1,275 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2005 Alfresco, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Mozilla Public License version 1.1
|
|
||||||
* with a permitted attribution clause. You may obtain a
|
|
||||||
* copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.alfresco.org/legal/license.txt
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
|
||||||
* either express or implied. See the License for the specific
|
|
||||||
* language governing permissions and limitations under the
|
|
||||||
* License.
|
|
||||||
*/
|
|
||||||
package org.alfresco.web.forms.xforms;
|
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Text;
|
|
||||||
import org.chiba.xml.ns.NamespaceConstants;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XHTML implementation of WrapperElementsBuilder: allows to wrap the XForm document in XHTML tags.
|
|
||||||
*
|
|
||||||
* @author Sophie Ramel
|
|
||||||
*/
|
|
||||||
public class XHTMLWrapperElementsBuilder
|
|
||||||
implements WrapperElementsBuilder
|
|
||||||
{
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
private static class Link
|
|
||||||
{
|
|
||||||
public final String href;
|
|
||||||
public final String type;
|
|
||||||
public final String rel;
|
|
||||||
|
|
||||||
public Link(final String href, final String type, final String rel)
|
|
||||||
{
|
|
||||||
this.href = href;
|
|
||||||
this.type = type;
|
|
||||||
this.rel = rel;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
private static class Meta
|
|
||||||
{
|
|
||||||
public final String httpEquiv;
|
|
||||||
public final String name;
|
|
||||||
public final String content;
|
|
||||||
public final String scheme;
|
|
||||||
|
|
||||||
public Meta(final String httpEquiv,
|
|
||||||
final String name,
|
|
||||||
final String content,
|
|
||||||
final String scheme)
|
|
||||||
{
|
|
||||||
this.httpEquiv = httpEquiv;
|
|
||||||
this.name = name;
|
|
||||||
this.content = content;
|
|
||||||
this.scheme = scheme;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
private String title;
|
|
||||||
private final Collection<Link> links = new LinkedList<Link>();
|
|
||||||
private final Collection<Meta> meta = new LinkedList<Meta>();
|
|
||||||
private final HashMap<String, String> namespaces =
|
|
||||||
new HashMap<String, String>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance of XHTMLWrapperElementsBuilder
|
|
||||||
*/
|
|
||||||
public XHTMLWrapperElementsBuilder() { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add a tag "title" in the header of the HTML document
|
|
||||||
*/
|
|
||||||
public void setTitle(String title)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add a tag "link" in the header of the HTML document
|
|
||||||
*
|
|
||||||
* @param href the "href" parameter of the "link" tag
|
|
||||||
* @param type the "type" parameter of the "link" tag
|
|
||||||
* @param rel the "rel" parameter of the "link" tag
|
|
||||||
*/
|
|
||||||
public void addLink(final String href,
|
|
||||||
final String type,
|
|
||||||
final String rel)
|
|
||||||
{
|
|
||||||
links.add(new Link(href, type, rel));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* add a tag "meta" in the header of the HTML document
|
|
||||||
*
|
|
||||||
* @param http_equiv the "http-equiv" parameter of the "META" tag
|
|
||||||
* @param name the "name" parameter of the "META" tag
|
|
||||||
* @param content the "content" parameter of the "META" tag
|
|
||||||
* @param scheme the "scheme" parameter of the "META" tag
|
|
||||||
*/
|
|
||||||
public void addMeta(final String httpEquiv,
|
|
||||||
final String name,
|
|
||||||
final String content,
|
|
||||||
final String scheme)
|
|
||||||
{
|
|
||||||
meta.add(new Meta(httpEquiv, name, content, scheme));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addNamespaceDeclaration(final String prefix,
|
|
||||||
final String url)
|
|
||||||
{
|
|
||||||
namespaces.put(prefix, url);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the wrapper element of the different controls
|
|
||||||
*
|
|
||||||
* @param controlElement the control element (input, select, repeat, group, ...)
|
|
||||||
* @return the wrapper element, already containing the control element
|
|
||||||
*/
|
|
||||||
public Element createControlsWrapper(final Element controlElement)
|
|
||||||
{
|
|
||||||
return controlElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* creates the global enveloppe of the resulting document, and puts it in the document
|
|
||||||
*
|
|
||||||
* @return the enveloppe
|
|
||||||
*/
|
|
||||||
public Element createEnvelope(Document doc)
|
|
||||||
{
|
|
||||||
final Element html = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":html");
|
|
||||||
//set namespace attribute
|
|
||||||
html.setAttributeNS(NamespaceConstants.XMLNS_NS,
|
|
||||||
NamespaceConstants.XMLNS_PREFIX + ':' + NamespaceConstants.XHTML_PREFIX,
|
|
||||||
NamespaceConstants.XHTML_NS);
|
|
||||||
doc.appendChild(html);
|
|
||||||
|
|
||||||
//other namespaces
|
|
||||||
for (String prefix : this.namespaces.keySet())
|
|
||||||
{
|
|
||||||
html.setAttributeNS(NamespaceConstants.XMLNS_NS,
|
|
||||||
NamespaceConstants.XMLNS_PREFIX + ":" + prefix,
|
|
||||||
this.namespaces.get(prefix));
|
|
||||||
|
|
||||||
}
|
|
||||||
return html;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the element that will contain the content of the group (or repeat) element
|
|
||||||
*
|
|
||||||
* @param groupElement the group or repeat element
|
|
||||||
* @return the wrapper element
|
|
||||||
*/
|
|
||||||
public Element createGroupContentWrapper(Element groupElement)
|
|
||||||
{
|
|
||||||
return groupElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the wrapper element of the form
|
|
||||||
*
|
|
||||||
* @param enveloppeElement the form element (chiba:form or other)
|
|
||||||
* @return the wrapper element
|
|
||||||
*/
|
|
||||||
public Element createFormWrapper(Element enveloppeElement)
|
|
||||||
{
|
|
||||||
Document doc = enveloppeElement.getOwnerDocument();
|
|
||||||
Element body = doc.createElementNS(NamespaceConstants.XHTML_NS, NamespaceConstants.XHTML_PREFIX + ":body");
|
|
||||||
//body.appendChild(formElement);
|
|
||||||
enveloppeElement.appendChild(body);
|
|
||||||
return body;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* create the wrapper element of the xforms:model element
|
|
||||||
*
|
|
||||||
* @param modelElement the xforms:model element
|
|
||||||
* @return the wrapper element, already containing the model
|
|
||||||
*/
|
|
||||||
public Element createModelWrapper(final Element modelElement)
|
|
||||||
{
|
|
||||||
Document doc = modelElement.getOwnerDocument();
|
|
||||||
Element head = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":head");
|
|
||||||
head.appendChild(modelElement);
|
|
||||||
|
|
||||||
//eventually add other info
|
|
||||||
if (title != null && title.length() != 0)
|
|
||||||
{
|
|
||||||
final Element title_el = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":title");
|
|
||||||
title_el.appendChild(doc.createTextNode(title));
|
|
||||||
head.appendChild(title_el);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Meta m : this.meta)
|
|
||||||
{
|
|
||||||
final Element meta_el = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":META");
|
|
||||||
head.appendChild(meta_el);
|
|
||||||
|
|
||||||
//attributes
|
|
||||||
if (m.httpEquiv != null && m.httpEquiv.length() != 0)
|
|
||||||
{
|
|
||||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":http-equiv",
|
|
||||||
m.httpEquiv);
|
|
||||||
}
|
|
||||||
if (m.name != null && m.name.length() != 0)
|
|
||||||
{
|
|
||||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":name",
|
|
||||||
m.name);
|
|
||||||
}
|
|
||||||
if (m.content != null && m.content.length() != 0)
|
|
||||||
{
|
|
||||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":content",
|
|
||||||
m.content);
|
|
||||||
}
|
|
||||||
if (m.scheme != null && m.scheme.length() != 0)
|
|
||||||
{
|
|
||||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":scheme",
|
|
||||||
m.scheme);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Link l : this.links)
|
|
||||||
{
|
|
||||||
final Element link_el = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":LINK");
|
|
||||||
head.appendChild(link_el);
|
|
||||||
|
|
||||||
//attributes
|
|
||||||
if (l.href != null && l.href.length() != 0)
|
|
||||||
{
|
|
||||||
link_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":href",
|
|
||||||
l.href);
|
|
||||||
}
|
|
||||||
if (l.type != null && l.type.length() != 0)
|
|
||||||
{
|
|
||||||
link_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":type",
|
|
||||||
l.type);
|
|
||||||
}
|
|
||||||
if (l.rel != null && l.rel.length() != 0)
|
|
||||||
{
|
|
||||||
link_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
|
||||||
NamespaceConstants.XHTML_PREFIX + ":rel",
|
|
||||||
l.rel);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return head;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -91,9 +91,12 @@ public class UIFormProcessor
|
|||||||
final FormProcessor fp = form.getFormProcessors().get(0);
|
final FormProcessor fp = form.getFormProcessors().get(0);
|
||||||
final FormProcessor.Session fps = this.getFormProcessorSession();
|
final FormProcessor.Session fps = this.getFormProcessorSession();
|
||||||
final Document fid = this.getFormInstanceData();
|
final Document fid = this.getFormInstanceData();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (fps != null && fps.getFormInstanceData().equals(fid))
|
if (fps != null &&
|
||||||
|
fps.getForm().equals(form) &&
|
||||||
|
fps.getFormInstanceData().equals(fid))
|
||||||
{
|
{
|
||||||
LOGGER.debug("reusing form processor session " + fps);
|
LOGGER.debug("reusing form processor session " + fps);
|
||||||
fp.process(this.formProcessorSession, out);
|
fp.process(this.formProcessorSession, out);
|
||||||
@@ -103,6 +106,8 @@ public class UIFormProcessor
|
|||||||
if (fps != null)
|
if (fps != null)
|
||||||
{
|
{
|
||||||
this.setFormProcessorSession(null);
|
this.setFormProcessorSession(null);
|
||||||
|
LOGGER.debug("clearing form instance data " + fid);
|
||||||
|
fid.removeChild(fid.getDocumentElement());
|
||||||
}
|
}
|
||||||
LOGGER.debug("creating a new session for " + fid);
|
LOGGER.debug("creating a new session for " + fid);
|
||||||
this.setFormProcessorSession(fp.process(fid,
|
this.setFormProcessorSession(fp.process(fid,
|
||||||
@@ -196,6 +201,7 @@ public class UIFormProcessor
|
|||||||
{
|
{
|
||||||
if (formProcessorSession == null && this.formProcessorSession != null)
|
if (formProcessorSession == null && this.formProcessorSession != null)
|
||||||
{
|
{
|
||||||
|
LOGGER.debug("destroying old session " + this.formProcessorSession);
|
||||||
this.formProcessorSession.destroy();
|
this.formProcessorSession.destroy();
|
||||||
}
|
}
|
||||||
this.formProcessorSession = formProcessorSession;
|
this.formProcessorSession = formProcessorSession;
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:alfresco="http://www.alfresco.org/alfresco"
|
xmlns:eyestreet="http://www.eyestreet.com/eyestreet"
|
||||||
targetNamespace="http://www.alfresco.org/alfresco"
|
targetNamespace="http://www.eyestreet.com/eyestreet"
|
||||||
elementFormDefault="qualified">
|
elementFormDefault="qualified">
|
||||||
<xs:element name="footer">
|
<xs:element name="footer">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="footer-images" minOccurs="1" maxOccurs="10">
|
<xs:element name="footer-images" minOccurs="1" maxOccurs="10">
|
||||||
<xs:complexType name="imagelink">
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
<xs:element name="image" type="xs:string"/>
|
<xs:element name="image" type="xs:string"/>
|
||||||
<xs:element name="url" type="xs:string"/>
|
<xs:element name="url" type="xs:string"/>
|
||||||
|
@@ -26,6 +26,10 @@ function _xforms_getSubmitButtons()
|
|||||||
return [ document.getElementById("wizard:next-button"),
|
return [ document.getElementById("wizard:next-button"),
|
||||||
document.getElementById("wizard:finish-button") ];
|
document.getElementById("wizard:finish-button") ];
|
||||||
}
|
}
|
||||||
|
function _xforms_getSaveDraftButtons()
|
||||||
|
{
|
||||||
|
return [ document.getElementById("wizard:back-button") ];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
<wcm:formProcessor id="form-data-renderer"
|
<wcm:formProcessor id="form-data-renderer"
|
||||||
formProcessorSession="#{WizardManager.bean.formProcessorSession}"
|
formProcessorSession="#{WizardManager.bean.formProcessorSession}"
|
||||||
|
@@ -31,6 +31,11 @@ function _xforms_getSubmitButtons()
|
|||||||
{
|
{
|
||||||
return [ document.getElementById("edit-file:save-button") ];
|
return [ document.getElementById("edit-file:save-button") ];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function _xforms_getSaveDraftButtons()
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<f:view>
|
<f:view>
|
||||||
|
@@ -1487,31 +1487,41 @@ dojo.declare("alfresco.xforms.Submit",
|
|||||||
{
|
{
|
||||||
initializer: function(xform, xformsNode)
|
initializer: function(xform, xformsNode)
|
||||||
{
|
{
|
||||||
var submit_buttons = _xforms_getSubmitButtons();
|
var submit_buttons = (this.id == "submit"
|
||||||
|
? _xforms_getSubmitButtons()
|
||||||
|
: (this.id == "save-draft"
|
||||||
|
? _xforms_getSaveDraftButtons()
|
||||||
|
: null));
|
||||||
|
if (submit_buttons == null)
|
||||||
|
{
|
||||||
|
throw new Error("unknown submit button " + this.id);
|
||||||
|
}
|
||||||
for (var i = 0; i < submit_buttons.length; i++)
|
for (var i = 0; i < submit_buttons.length; i++)
|
||||||
{
|
{
|
||||||
dojo.debug("adding submit handler for " + submit_buttons[i].getAttribute('id'));
|
dojo.debug("adding submit handler for " + submit_buttons[i].getAttribute('id'));
|
||||||
submit_buttons[i].xform = this.xform;
|
submit_buttons[i].widget = this;
|
||||||
dojo.event.browser.addListener(submit_buttons[i],
|
dojo.event.browser.addListener(submit_buttons[i],
|
||||||
"onclick",
|
"onclick",
|
||||||
function(event)
|
function(event)
|
||||||
{
|
{
|
||||||
var xform = event.target.xform;
|
var xform = event.target.widget.xform;
|
||||||
if (!xform.submitWidget.done)
|
if (xform.submitWidget && xform.submitWidget.done)
|
||||||
|
{
|
||||||
|
dojo.debug("done - doing base click on " + xform.submitWidget.currentButton.id);
|
||||||
|
xform.submitWidget.currentButton = null;
|
||||||
|
xform.submitWidget = null;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
dojo.debug("triggering submit from handler " + event.target.id);
|
dojo.debug("triggering submit from handler " + event.target.id);
|
||||||
dojo.event.browser.stopEvent(event);
|
dojo.event.browser.stopEvent(event);
|
||||||
_hide_errors();
|
_hide_errors();
|
||||||
|
xform.submitWidget = event.target.widget;
|
||||||
xform.submitWidget.currentButton = event.target;
|
xform.submitWidget.currentButton = event.target;
|
||||||
xform.submitWidget.widget.buttonClick();
|
xform.submitWidget.widget.buttonClick();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dojo.debug("done - doing base click on " + xform.submitWidget.currentButton.id);
|
|
||||||
xform.submitWidget.currentButton = null;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
@@ -1519,7 +1529,6 @@ dojo.declare("alfresco.xforms.Submit",
|
|||||||
render: function(attach_point)
|
render: function(attach_point)
|
||||||
{
|
{
|
||||||
this.inherited("render", [ attach_point ]);
|
this.inherited("render", [ attach_point ]);
|
||||||
this.xform.submitWidget = this;
|
|
||||||
},
|
},
|
||||||
_clickHandler: function(event)
|
_clickHandler: function(event)
|
||||||
{
|
{
|
||||||
@@ -1975,6 +1984,7 @@ dojo.declare("alfresco.xforms.XForm",
|
|||||||
}
|
}
|
||||||
case "xforms-submit-error":
|
case "xforms-submit-error":
|
||||||
{
|
{
|
||||||
|
this.submitWidget = null;
|
||||||
var invalid = this.rootWidget.getWidgetsInvalidForSubmit();
|
var invalid = this.rootWidget.getWidgetsInvalidForSubmit();
|
||||||
_show_error(document.createTextNode("Please provide values for all required fields."));
|
_show_error(document.createTextNode("Please provide values for all required fields."));
|
||||||
var error_list = document.createElement("ul");
|
var error_list = document.createElement("ul");
|
||||||
@@ -2156,8 +2166,8 @@ function _evaluateXPath(xpath, contextNode, result_type)
|
|||||||
if (xmlDocument.evaluate)
|
if (xmlDocument.evaluate)
|
||||||
{
|
{
|
||||||
var nsResolver = (xmlDocument.createNSResolver
|
var nsResolver = (xmlDocument.createNSResolver
|
||||||
? xmlDocument.createNSResolver(xmlDocument.documentElement) :
|
? xmlDocument.createNSResolver(xmlDocument.documentElement)
|
||||||
null);
|
: null);
|
||||||
result = xmlDocument.evaluate(xpath,
|
result = xmlDocument.evaluate(xpath,
|
||||||
contextNode,
|
contextNode,
|
||||||
nsResolver,
|
nsResolver,
|
||||||
|
Reference in New Issue
Block a user