- 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:
Ariel Backenroth
2006-11-05 23:16:36 +00:00
parent c6b9543984
commit 390ca111c7
11 changed files with 902 additions and 396 deletions

View File

@@ -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.
*/

View File

@@ -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();
@@ -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
{
@@ -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);
@@ -2566,8 +2567,8 @@ public class SchemaFormBuilder
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)
{

View File

@@ -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.
@@ -255,6 +259,65 @@ public class XFormsBean
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();
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));
final FormsService ts = FormsService.getInstance();
final ResponseWriter out = context.getResponseWriter();
ts.writeXML(this.getEventLog(), out);
out.close();
}
private void swapRepeatItems(final XFormsElement from,
final XFormsElement to)
{
LOGGER.debug("swapping repeat item " + from + " with " + to);
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 String fromLocationPath = ((BoundElement)from).getLocationPath();
final ModelItem fromModelItem = instance.getModelItem(fromLocationPath);
final String toLocationPath = ((BoundElement)to).getLocationPath();
final ModelItem toModelItem = instance.getModelItem(toLocationPath);
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)

View File

@@ -0,0 +1,47 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:simpleType name="five_string_values">
<xs:restriction base="xs:string">
<xs:enumeration value="one"/>
<xs:enumeration value="two"/>
<xs:enumeration value="three"/>
<xs:enumeration value="four"/>
<xs:enumeration value="five"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="ten_string_values">
<xs:restriction base="xs:string">
<xs:enumeration value="one"/>
<xs:enumeration value="two"/>
<xs:enumeration value="three"/>
<xs:enumeration value="four"/>
<xs:enumeration value="five"/>
<xs:enumeration value="six"/>
<xs:enumeration value="seven"/>
<xs:enumeration value="eight"/>
<xs:enumeration value="nine"/>
<xs:enumeration value="ten"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="multi-input">
<xs:sequence>
<xs:element name="string" type="xs:string"/>
<xs:element name="int" type="xs:anyType"/>
</xs:sequence>
</xs:complexType>
<xs:element name="repeat-components">
<xs:complexType>
<xs:sequence>
<xs:element name="zero-to-one" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="one-to-one" type="xs:anyType" minOccurs="1" maxOccurs="1"/>
<xs:element name="one-to-inf" type="xs:date" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="zero-to-inf" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="one-to-five" type="five_string_values" minOccurs="1" maxOccurs="5"/>
<xs:element name="zero-to-five" type="ten_string_values" minOccurs="0" maxOccurs="5"/>
<xs:element name="one-to-five-multi" type="multi-input" minOccurs="1" maxOccurs="5"/>
<xs:element name="zero-to-five-multi" type="multi-input" minOccurs="0" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xhtml">
<xsl:output method="html" version="4.01" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
<xsl:preserve-space elements="*"/>
<xsl:template match="/">
<html>
<head>
<title>repeat-components</title>
</head>
<body>
<table border="1">
<tr><th>zero-to-one</th><td colspan="2"><xsl:value-of select="/repeat-components/zero-to-one"/></td></tr>
<tr><th>one-to-one</th><td colspan="2"><xsl:value-of select="/repeat-components/one-to-one"/></td></tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-components/one-to-inf)"/>
</xsl:attribute>
-->
one-to-inf
</th>
<td>
<ul>
<xsl:for-each select="/repeat-components/one-to-inf">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-components/zero-to-inf)"/>
</xsl:attribute>
-->
zero-to-inf
</th>
<td>
<ul>
<xsl:for-each select="/repeat-components/zero-to-inf">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-components/one-to-five)"/>
</xsl:attribute>
-->
one-to-five
</th>
<td>
<ul>
<xsl:for-each select="/repeat-components/one-to-five">
<li colspan="2"><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-components/zero-to-five)"/>
</xsl:attribute>
-->
zero-to-five
</th>
<td>
<ul>
<xsl:for-each select="/repeat-components/zero-to-five">
<li colspan="2"><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-components/one-to-five-multi)"/>
</xsl:attribute>
-->
one-to-five-multi
</th>
<td>
<ul>
<xsl:for-each select="/repeat-components/one-to-five-multi">
<ul>
<li><xsl:value-of select="string"/></li>
<li><xsl:value-of select="int"/></li>
</ul>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-components/zero-to-five-multi)"/>
</xsl:attribute>
-->
zero-to-five-multi
</th>
<td>
<ul>
<xsl:for-each select="/repeat-components/zero-to-five-multi">
<li>
<ul>
<li><xsl:value-of select="string"/></li>
<li><xsl:value-of select="int"/></li>
</ul>
</li>
</xsl:for-each>
</ul>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,23 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="multi-input">
<xs:sequence>
<xs:element name="string" type="xs:string"/>
<xs:element name="int" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:element name="repeat-constraints">
<xs:complexType>
<xs:sequence>
<xs:element name="zero-to-one" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="one-to-one" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="one-to-inf" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="zero-to-inf" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="one-to-five" type="xs:string" minOccurs="1" maxOccurs="5"/>
<xs:element name="three-to-five" type="xs:string" minOccurs="3" maxOccurs="5"/>
<xs:element name="zero-to-five" type="xs:string" minOccurs="0" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -0,0 +1,14 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:element name="repeat-simple">
<xs:complexType>
<xs:sequence>
<xs:element name="zero-to-one" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="one-to-one" type="xs:string" minOccurs="1" maxOccurs="1"/>
<xs:element name="one-to-inf" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="zero-to-inf" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -0,0 +1,135 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
exclude-result-prefixes="xhtml">
<xsl:output method="html" version="4.01" encoding="UTF-8" indent="yes"
doctype-public="-//W3C//DTD HTML 4.01 Transitional//EN"
doctype-system="http://www.w3.org/TR/html4/loose.dtd"/>
<xsl:preserve-space elements="*"/>
<xsl:template match="/">
<html>
<head>
<title>repeat-simple</title>
</head>
<body>
<table border="1">
<tr><th>zero-to-one</th><td colspan="2"><xsl:value-of select="/repeat-simple/zero-to-one"/></td></tr>
<tr><th>one-to-one</th><td colspan="2"><xsl:value-of select="/repeat-simple/one-to-one"/></td></tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-simple/one-to-inf)"/>
</xsl:attribute>
-->
one-to-inf
</th>
<td>
<ul>
<xsl:for-each select="/repeat-simple/one-to-inf">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-simple/zero-to-inf)"/>
</xsl:attribute>
-->
zero-to-inf
</th>
<td>
<ul>
<xsl:for-each select="/repeat-simple/zero-to-inf">
<li><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-simple/one-to-five)"/>
</xsl:attribute>
-->
one-to-five
</th>
<td>
<ul>
<xsl:for-each select="/repeat-simple/one-to-five">
<li colspan="2"><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-simple/zero-to-five)"/>
</xsl:attribute>
-->
zero-to-five
</th>
<td>
<ul>
<xsl:for-each select="/repeat-simple/zero-to-five">
<li colspan="2"><xsl:value-of select="."/></li>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-simple/one-to-five-multi)"/>
</xsl:attribute>
-->
one-to-five-multi
</th>
<td>
<ul>
<xsl:for-each select="/repeat-simple/one-to-five-multi">
<ul>
<li><xsl:value-of select="string"/></li>
<li><xsl:value-of select="int"/></li>
</ul>
</xsl:for-each>
</ul>
</td>
</tr>
<tr>
<th>
<!--
<xsl:attribute name="rowspan">
<xsl:value-of select="count(/repeat-simple/zero-to-five-multi)"/>
</xsl:attribute>
-->
zero-to-five-multi
</th>
<td>
<ul>
<xsl:for-each select="/repeat-simple/zero-to-five-multi">
<li>
<ul>
<li><xsl:value-of select="string"/></li>
<li><xsl:value-of select="int"/></li>
</ul>
</li>
</xsl:for-each>
</ul>
</td>
</tr>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

View File

@@ -0,0 +1,25 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
<xs:complexType name="multi-input">
<xs:sequence>
<xs:element name="string" type="xs:string"/>
<xs:element name="int" type="xs:int"/>
<xs:element name="date" type="xs:date"/>
</xs:sequence>
</xs:complexType>
<xs:element name="repeat-constraints">
<xs:complexType>
<xs:sequence>
<xs:element name="one-to-one" type="xs:integer" minOccurs="1" maxOccurs="1"/>
<xs:element name="one-to-one-multi-input" type="multi-input" minOccurs="1" maxOccurs="1"/>
<xs:element name="one-to-inf" type="xs:integer" minOccurs="1" maxOccurs="unbounded"/>
<xs:element name="zero-to-inf" type="xs:integer" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="two-to-four-date" type="xs:date" minOccurs="2" maxOccurs="4"/>
<xs:element name="two-to-four-integer-default" type="xs:integer" minOccurs="2" maxOccurs="4" default="224"/>
<xs:element name="three-to-five" type="xs:string" minOccurs="3" maxOccurs="5" default="default string value"/>
<xs:element name="one-to-five-multi-input" type="multi-input" minOccurs="1" maxOccurs="5"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -104,14 +104,29 @@ if (upload == null || upload.getFile() == null)
<f:selectItems id="schema-root-element-name-choices"
value="#{WizardManager.bean.schemaRootElementNameChoices}"/>
</h:selectOneMenu>
<h:graphicImage id="graphic_image_name" value="/images/icons/required_field.gif" alt="Required Field" />
<h:graphicImage id="graphic_image_name"
value="/images/icons/required_field.gif"
alt="Required Field" />
<h:outputText id="output_text_name" value="#{msg.name}:"/>
<h:inputText id="file-name" value="#{WizardManager.bean.formName}"
maxlength="1024" size="35"/>
<h:inputText id="file-name"
value="#{WizardManager.bean.formName}"
maxlength="1024"
size="35"/>
<h:graphicImage id="graphic_image_title"
value="/images/icons/required_field.gif"
alt="Required Field" />
<h:outputText id="output_text_title" value="#{msg.title}:"/>
<h:inputText id="title"
value="#{WizardManager.bean.formTitle}"
maxlength="1024"
size="35"/>
<h:outputText id="no_graphic_image_description" value=""/>
<h:outputText id="output_text_description" value="#{msg.description}:"/>
<h:inputText id="description" value="#{WizardManager.bean.formDescription}"
maxlength="1024" size="35"/>
<h:inputText id="description"
value="#{WizardManager.bean.formDescription}"
maxlength="1024"
size="35"/>
</h:panelGrid>

View File

@@ -38,24 +38,20 @@ tinyMCE.init({
dojo.declare("alfresco.xforms.Widget",
null,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.xform = xform;
this.node = node;
this.xformsNode = xformsNode;
//XXXarielb this has to come back
// this.node.widget = this;
this.id = this.node.getAttribute("id");
this.id = this.xformsNode.getAttribute("id");
this.modified = false;
this.valid = true;
},
node: null,
xformsNode: null,
labelNode: null,
parent: null,
domContainer: null,
_getBinding: function()
{
return this.xform.getBinding(this.node);
},
setModified: function(b)
{
this.modified = b;
@@ -96,17 +92,17 @@ dojo.declare("alfresco.xforms.Widget",
},
isRequired: function()
{
var binding = this._getBinding();
var binding = this.xform.getBinding(this.xformsNode);
return binding && binding.required == "true()";
},
isReadonly: function()
{
var binding = this._getBinding();
var binding = this.xform.getBinding(this.xformsNode);
return binding && binding.readonly == "true()";
},
getInitialValue: function()
{
var chibaData = _getElementsByTagNameNS(this.node,
var chibaData = _getElementsByTagNameNS(this.xformsNode,
CHIBA_NS,
CHIBA_NS_PREFIX,
"data");
@@ -115,7 +111,7 @@ dojo.declare("alfresco.xforms.Widget",
chibaData = chibaData[chibaData.length - 1];
var xpath = chibaData.getAttribute("chiba:xpath");
var d = this.node.ownerDocument;
var d = this.xformsNode.ownerDocument;
var contextNode = this.xform.getInstance();
dojo.debug("locating " + xpath +
" from " + chibaData.nodeName +
@@ -131,24 +127,24 @@ dojo.declare("alfresco.xforms.Widget",
},
_getLabelNode: function()
{
var labels = _getElementsByTagNameNS(this.node, XFORMS_NS, XFORMS_NS_PREFIX, "label");
var labels = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_NS_PREFIX, "label");
for (var i = 0; i < labels.length; i++)
{
dojo.debug("parent " + labels[i].parentNode.nodeName +
" o " + this.node.nodeName);
if (labels[i].parentNode == this.node)
" o " + this.xformsNode.nodeName);
if (labels[i].parentNode == this.xformsNode)
return labels[i];
}
return null;
},
_getAlertNode: function()
{
var labels = _getElementsByTagNameNS(this.node, XFORMS_NS, XFORMS_NS_PREFIX, "alert");
var labels = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_NS_PREFIX, "alert");
for (var i = 0; i < labels.length; i++)
{
dojo.debug("parent " + labels[i].parentNode.nodeName +
" o " + this.node.nodeName);
if (labels[i].parentNode == this.node)
" o " + this.xformsNode.nodeName);
if (labels[i].parentNode == this.xformsNode)
return labels[i];
}
return null;
@@ -188,9 +184,9 @@ dojo.declare("alfresco.xforms.Widget",
dojo.declare("alfresco.xforms.DatePicker",
alfresco.xforms.Widget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
render: function(attach_point)
{
@@ -250,9 +246,9 @@ dojo.declare("alfresco.xforms.DatePicker",
dojo.declare("alfresco.xforms.TextField",
alfresco.xforms.Widget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
render: function(attach_point)
{
@@ -265,7 +261,7 @@ dojo.declare("alfresco.xforms.TextField",
this.widget.setAttribute("type", "text");
this.widget.setAttribute("id", this.id + "-widget");
this.widget.setAttribute("value", initial_value);
if (this.xform.getType(this.node) == "string")
if (this.xform.getType(this.xformsNode) == "string")
this.widget.style.width = "100%";
this.domNode.appendChild(this.widget);
@@ -302,9 +298,9 @@ dojo.declare("alfresco.xforms.TextField",
dojo.declare("alfresco.xforms.TextArea",
alfresco.xforms.Widget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
render: function(attach_point)
{
@@ -331,14 +327,14 @@ dojo.declare("alfresco.xforms.TextArea",
dojo.declare("alfresco.xforms.AbstractSelectWidget",
alfresco.xforms.Widget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
getValues: function()
{
var binding = this._getBinding();
var values = _getElementsByTagNameNS(this.node, XFORMS_NS, XFORMS_NS_PREFIX, "item");
var binding = this.xform.getBinding(this.xformsNode);
var values = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_NS_PREFIX, "item");
var result = [];
for (var v = 0; v < values.length; v++)
{
@@ -368,9 +364,9 @@ dojo.declare("alfresco.xforms.AbstractSelectWidget",
dojo.declare("alfresco.xforms.Select",
alfresco.xforms.AbstractSelectWidget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
render: function(attach_point)
{
@@ -455,9 +451,9 @@ dojo.declare("alfresco.xforms.Select",
dojo.declare("alfresco.xforms.Select1",
alfresco.xforms.AbstractSelectWidget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
render: function(attach_point)
{
@@ -543,9 +539,9 @@ dojo.declare("alfresco.xforms.Select1",
dojo.declare("alfresco.xforms.Checkbox",
alfresco.xforms.Widget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
render: function(attach_point)
{
@@ -572,9 +568,9 @@ dojo.declare("alfresco.xforms.Checkbox",
dojo.declare("alfresco.xforms.Group",
alfresco.xforms.Widget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
this.children = [];
},
children: null,
@@ -599,7 +595,8 @@ dojo.declare("alfresco.xforms.Group",
for (var i = 0; i < this.children.length; i++)
{
dojo.debug(this.id + "[" + i + "]: " +
" is " + this.children[i].id + " the same as " + child.id + "?");
" is " + this.children[i].id +
" the same as " + child.id + "?");
if (this.children[i] == child)
return i;
}
@@ -754,9 +751,9 @@ dojo.declare("alfresco.xforms.Group",
dojo.declare("alfresco.xforms.Repeat",
alfresco.xforms.Group,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
_selectedIndex: -1,
insertChildAt: function(child, position)
@@ -819,7 +816,7 @@ dojo.declare("alfresco.xforms.Repeat",
this.setFocusedChild(event.target.repeatItem);
if (!this.insertRepeatItemAfterTrigger)
this.insertRepeatItemAfterTrigger =
_findElementById(this.node.parentNode, this.id + "-insert_after");
_findElementById(this.xformsNode.parentNode, this.id + "-insert_after");
this.xform.fireAction(this.insertRepeatItemAfterTrigger.getAttribute("id"));
},
_insertRepeatItemBefore_handler: function(event)
@@ -828,7 +825,7 @@ dojo.declare("alfresco.xforms.Repeat",
this.setFocusedChild(event.target.repeatItem);
if (!this.insertRepeatItemBeforeTrigger)
this.insertRepeatItemBeforeTrigger =
_findElementById(this.node.parentNode, this.id + "-insert_before");
_findElementById(this.xformsNode.parentNode, this.id + "-insert_before");
this.xform.fireAction(this.insertRepeatItemBeforeTrigger.getAttribute("id"));
},
_removeRepeatItem_handler: function(event)
@@ -836,7 +833,7 @@ dojo.declare("alfresco.xforms.Repeat",
dojo.event.browser.stopEvent(event);
this.setFocusedChild(event.target.repeatItem);
if (!this.removeRepeatItemTrigger)
this.removeRepeatItemTrigger = _findElementById(this.node.parentNode,
this.removeRepeatItemTrigger = _findElementById(this.xformsNode.parentNode,
this.id + "-delete");
this.xform.fireAction(this.removeRepeatItemTrigger.getAttribute("id"));
},
@@ -884,6 +881,19 @@ dojo.declare("alfresco.xforms.Repeat",
this.children[toIndex] = fromChild;
this._selectedIndex = toIndex;
this._updateDisplay();
var req = create_ajax_request(this.xform,
"swapRepeatItems",
{
fromItemId: fromChild.xformsNode.getAttribute("id"),
toItemId: toChild.xformsNode.getAttribute("id"),
instanceId: this.xform.getInstance().getAttribute("id")
},
function(type, data, event)
{
this.xform._handleEventLog(data.documentElement)
});
send_ajax_request(req);
},
setFocusedChild: function(child)
{
@@ -968,7 +978,7 @@ dojo.declare("alfresco.xforms.Repeat",
handlePrototypeCloned: function(prototypeId)
{
dojo.debug(this.id + ".handlePrototypeCloned("+ prototypeId +")");
var chibaData = _getElementsByTagNameNS(this.node, CHIBA_NS, CHIBA_NS_PREFIX, "data");
var chibaData = _getElementsByTagNameNS(this.xformsNode, CHIBA_NS, CHIBA_NS_PREFIX, "data");
chibaData = chibaData[chibaData.length - 1];
dojo.debug("chiba:data == " + dojo.dom.innerXML(chibaData));
var prototypeToClone = dojo.dom.firstElement(chibaData);
@@ -983,7 +993,7 @@ dojo.declare("alfresco.xforms.Repeat",
", " + position + ")");
var w = this.xform.createWidget(clonedPrototype);
this.insertChildAt(w, position);
this.xform.loadWidgets(w.node, w);
this.xform.loadWidgets(w.xformsNode, w);
},
handleItemDeleted: function(position)
{
@@ -995,9 +1005,9 @@ dojo.declare("alfresco.xforms.Repeat",
dojo.declare("alfresco.xforms.Trigger",
alfresco.xforms.Widget,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
},
render: function(attach_point)
{
@@ -1021,9 +1031,9 @@ dojo.declare("alfresco.xforms.Trigger",
dojo.declare("alfresco.xforms.Submit",
alfresco.xforms.Trigger,
{
initializer: function(xform, node)
initializer: function(xform, xformsNode)
{
this.inherited("initializer", [ xform, node ]);
this.inherited("initializer", [ xform, xformsNode ]);
var submit_buttons = _xforms_getSubmitButtons();
for (var i = 0; i < submit_buttons.length; i++)
{
@@ -1105,7 +1115,7 @@ dojo.declare("alfresco.xforms.XForm",
_loadHandler: function(xformDocument)
{
this.xformDocument = xformDocument;
this.node = xformDocument.documentElement;
this.xformsNode = xformDocument.documentElement;
this._bindings = this._loadBindings(this.getModel());
var bindings = this.getBindings();
@@ -1177,29 +1187,29 @@ dojo.declare("alfresco.xforms.XForm",
throw new Error("unknown type " + node.nodeName);
}
},
loadWidgets: function(modelNode, parentWidget)
loadWidgets: function(xformsNode, parentWidget)
{
for (var i = 0; i < modelNode.childNodes.length; i++)
for (var i = 0; i < xformsNode.childNodes.length; i++)
{
if (modelNode.childNodes[i].nodeType == dojo.dom.ELEMENT_NODE)
if (xformsNode.childNodes[i].nodeType == dojo.dom.ELEMENT_NODE)
{
dojo.debug("loading " + modelNode.childNodes[i] +
" nodeName " + modelNode.childNodes[i].nodeName +
dojo.debug("loading " + xformsNode.childNodes[i] +
" nodeName " + xformsNode.childNodes[i].nodeName +
" into " + parentWidget.id);
var w = this.createWidget(modelNode.childNodes[i]);
var w = this.createWidget(xformsNode.childNodes[i]);
if (w != null)
{
dojo.debug("created " + w.id + " for " + modelNode.childNodes[i].nodeName);
dojo.debug("created " + w.id + " for " + xformsNode.childNodes[i].nodeName);
parentWidget.addChild(w);
if (w instanceof alfresco.xforms.Group)
this.loadWidgets(modelNode.childNodes[i], w);
this.loadWidgets(xformsNode.childNodes[i], w);
}
}
}
},
getModel: function()
{
return _getElementsByTagNameNS(this.node,
return _getElementsByTagNameNS(this.xformsNode,
XFORMS_NS,
XFORMS_NS_PREFIX,
"model")[0];
@@ -1214,7 +1224,7 @@ dojo.declare("alfresco.xforms.XForm",
},
getBody: function()
{
var b = _getElementsByTagNameNS(this.node,
var b = _getElementsByTagNameNS(this.xformsNode,
XHTML_NS,
XHTML_NS_PREFIX,
"body");