diff --git a/.classpath b/.classpath
index 2aafa5616c..838b3ef526 100644
--- a/.classpath
+++ b/.classpath
@@ -15,11 +15,11 @@
-
+
diff --git a/config/alfresco/web-client-config-wcm.xml b/config/alfresco/web-client-config-wcm.xml
index c3306553f3..4761eb58d3 100644
--- a/config/alfresco/web-client-config-wcm.xml
+++ b/config/alfresco/web-client-config-wcm.xml
@@ -80,6 +80,7 @@
wcm:avmcontent,wcm:avmfolder
+ table
+
@@ -117,6 +118,13 @@
2
+
+
+
+
+
+
+ false
diff --git a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java
index c49c41352b..4614ff0402 100644
--- a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java
@@ -23,6 +23,11 @@
*/
package org.alfresco.web.bean.wcm;
+import static org.alfresco.web.bean.wcm.DescriptionAttributeHelper.getDescriptionNotEmpty;
+import static org.alfresco.web.bean.wcm.DescriptionAttributeHelper.getTableBegin;
+import static org.alfresco.web.bean.wcm.DescriptionAttributeHelper.getTableEnd;
+import static org.alfresco.web.bean.wcm.DescriptionAttributeHelper.getTableLine;
+
import java.io.File;
import java.io.Serializable;
import java.text.MessageFormat;
@@ -65,8 +70,6 @@ import org.alfresco.web.forms.RenderingEngine;
import org.alfresco.web.forms.RenderingEngineTemplate;
import org.alfresco.web.forms.RenderingEngineTemplateImpl;
import org.alfresco.web.forms.XMLUtil;
-import org.alfresco.web.forms.xforms.FormBuilderException;
-import org.alfresco.web.forms.xforms.SchemaUtil;
import org.alfresco.web.ui.common.Utils;
import org.alfresco.web.ui.common.component.UIListItem;
import org.alfresco.web.ui.wcm.WebResources;
@@ -74,11 +77,10 @@ import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.xerces.xs.XSConstants;
-import org.apache.xerces.xs.XSElementDeclaration;
-import org.apache.xerces.xs.XSModel;
-import org.apache.xerces.xs.XSNamedMap;
+import org.chiba.xml.ns.NamespaceConstants;
import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
/**
* Bean implementation for the "Create XML Form" dialog
@@ -238,7 +240,7 @@ public class CreateFormWizard extends BaseWizardBean
protected String defaultWorkflowName = null;
protected boolean applyDefaultWorkflow = true;
protected List renderingEngineTemplates = null;
- protected transient XSModel schema;
+ transient protected Document schema;
protected String schemaFileName;
protected transient ContentService contentService;
protected transient MimetypeService mimetypeService;
@@ -773,17 +775,7 @@ public class CreateFormWizard extends BaseWizardBean
{
try
{
- final Document d = XMLUtil.parse(this.getSchemaFile());
- try
- {
- this.schema = SchemaUtil.parseSchema(d, true);
- }
- catch (FormBuilderException fbe)
- {
- this.schema = SchemaUtil.parseSchema(d, false);
- LOGGER.warn("non fatal errors encountered parsing schema " + this.getFileName(FILE_SCHEMA) +
- "\n " + fbe.getMessage());
- }
+ this.schema = XMLUtil.parse(this.getSchemaFile());
}
catch (Exception e)
{
@@ -999,11 +991,16 @@ public class CreateFormWizard extends BaseWizardBean
if (this.schemaRootElementNameChoices == null)
{
this.schemaRootElementNameChoices = new LinkedList();
- final XSNamedMap elementsMap = this.schema.getComponents(XSConstants.ELEMENT_DECLARATION);
- for (int i = 0; i < elementsMap.getLength(); i++)
+ NodeList elements = this.schema.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "element");
+
+ for (int i = 0; i < elements.getLength(); i++)
{
- final XSElementDeclaration e = (XSElementDeclaration)elementsMap.item(i);
- this.schemaRootElementNameChoices.add(new SelectItem(e.getName(), e.getName()));
+ Node current = elements.item(i);
+ if (current.getParentNode().equals(this.schema.getDocumentElement()))
+ {
+ this.schemaRootElementNameChoices.add(new SelectItem(current.getAttributes().getNamedItem("name").getNodeValue(),
+ current.getAttributes().getNamedItem("name").getNodeValue()));
+ }
}
}
result = this.schemaRootElementNameChoices;
diff --git a/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java b/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java
index d95d5785d2..4e8c82f7c5 100644
--- a/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java
+++ b/source/java/org/alfresco/web/bean/wcm/EditFormWizard.java
@@ -48,7 +48,6 @@ import org.alfresco.service.namespace.RegexQNamePattern;
import org.alfresco.web.bean.repository.Repository;
import org.alfresco.web.forms.Form;
import org.alfresco.web.forms.RenderingEngineTemplate;
-import org.alfresco.web.forms.xforms.SchemaUtil;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -122,7 +121,7 @@ public class EditFormWizard
ContentModel.PROP_NAME));
try
{
- this.schema = SchemaUtil.parseSchema(form.getSchema(), false);
+ this.schema = form.getSchema();
}
catch (Throwable t)
{
diff --git a/source/java/org/alfresco/web/config/ClientConfigElement.java b/source/java/org/alfresco/web/config/ClientConfigElement.java
index 5f3c757f61..9ab75027e7 100644
--- a/source/java/org/alfresco/web/config/ClientConfigElement.java
+++ b/source/java/org/alfresco/web/config/ClientConfigElement.java
@@ -88,6 +88,7 @@ public class ClientConfigElement extends ConfigElementAdapter
private boolean userGroupAdmin = true;
private boolean allowUserConfig = true;
private int pickerSearchMinimum = 2;
+ private boolean checkContextAgainstPath = false;
/**
@@ -313,7 +314,12 @@ public class ClientConfigElement extends ConfigElementAdapter
{
combinedElement.setPickerSearchMinimum(newElement.getPickerSearchMinimum());
}
-
+
+ if (newElement.getCheckContextAgainstPath() != combinedElement.getCheckContextAgainstPath())
+ {
+ combinedElement.setCheckContextAgainstPath(newElement.getCheckContextAgainstPath());
+ }
+
return combinedElement;
}
@@ -875,4 +881,20 @@ public class ClientConfigElement extends ConfigElementAdapter
{
this.pickerSearchMinimum = searchMinimum;
}
+
+ /**
+ * @return true if the context path should be checked against the path in the current URL
+ */
+ public boolean getCheckContextAgainstPath()
+ {
+ return this.checkContextAgainstPath;
+ }
+
+ /**
+ * @param checkContextAgainstPath true to check the context path against the path in the current URL
+ */
+ /*package*/ void setCheckContextAgainstPath(boolean checkContextAgainstPath)
+ {
+ this.checkContextAgainstPath = checkContextAgainstPath;
+ }
}
diff --git a/source/java/org/alfresco/web/config/ClientElementReader.java b/source/java/org/alfresco/web/config/ClientElementReader.java
index 520a5f9c09..8997740722 100644
--- a/source/java/org/alfresco/web/config/ClientElementReader.java
+++ b/source/java/org/alfresco/web/config/ClientElementReader.java
@@ -72,6 +72,7 @@ public class ClientElementReader implements ConfigElementReader
public static final String ELEMENT_USERGROUPADMIN = "user-group-admin";
public static final String ELEMENT_ALLOWUSERCONFIG = "allow-user-config";
public static final String ELEMENT_PICKERSEARCHMINIMUM = "picker-search-minimum";
+ public static final String ELEMENT_CHECKCONTEXTPATH = "check-context-against-path";
/**
@@ -323,6 +324,14 @@ public class ClientElementReader implements ConfigElementReader
{
configElement.setPickerSearchMinimum(Integer.parseInt(pickerSearchMin.getTextTrim()));
}
+
+ // determine whether the JavaScript setContextPath method should
+ // check the path of the current URL
+ Element checkContextAgainstPath = element.element(ELEMENT_CHECKCONTEXTPATH);
+ if (checkContextAgainstPath != null)
+ {
+ configElement.setCheckContextAgainstPath(Boolean.parseBoolean(checkContextAgainstPath.getTextTrim()));
+ }
}
return configElement;
diff --git a/source/java/org/alfresco/web/config/WCMConfigElement.java b/source/java/org/alfresco/web/config/WCMConfigElement.java
new file mode 100644
index 0000000000..0b3dd846d2
--- /dev/null
+++ b/source/java/org/alfresco/web/config/WCMConfigElement.java
@@ -0,0 +1,148 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.web.config;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.alfresco.config.ConfigElement;
+import org.alfresco.config.element.GenericConfigElement;
+
+/**
+ * Custom config element that represents the config data for WCM
+ *
+ * @author gavinc
+ */
+public class WCMConfigElement extends GenericConfigElement
+{
+ private static final long serialVersionUID = -4906603037550877971L;
+
+ protected Map childrenMap;
+
+ public static final String CONFIG_ELEMENT_ID = "wcm";
+
+ /**
+ * Default constructor
+ */
+ public WCMConfigElement()
+ {
+ super(CONFIG_ELEMENT_ID);
+ }
+
+ /**
+ * Constructor
+ *
+ * @param name Name of the element this config element represents
+ */
+ public WCMConfigElement(String name)
+ {
+ super(name);
+
+ this.childrenMap = new HashMap(8);
+ }
+
+ @Override
+ public ConfigElement combine(ConfigElement configElement)
+ {
+ WCMConfigElement combined = new WCMConfigElement(this.name);
+ WCMConfigElement toCombineElement = (WCMConfigElement)configElement;
+
+ // work out which child element to add
+ Map toCombineKids = toCombineElement.getChildrenAsMap();
+ List kids = this.getChildren();
+ if (kids != null)
+ {
+ for (ConfigElement child : kids)
+ {
+ String childName = child.getName();
+ if (toCombineKids.containsKey(childName))
+ {
+ // check for the 'xforms' child element
+ if (childName.equals("xforms"))
+ {
+ // add the widgets from the 'to combine' element to
+ // this one and then add to the new combined element
+ for (ConfigElement widget : toCombineKids.get("xforms").getChildren())
+ {
+ ((GenericConfigElement)child).addChild(widget);
+ }
+
+ // add the current child to the combined one
+ combined.addChild(child);
+ }
+ else
+ {
+ // use the overridden child element
+ combined.addChild(toCombineKids.get(childName));
+ }
+ }
+ else
+ {
+ // the current child has not be overridden so
+ // just add the current child
+ combined.addChild(child);
+ }
+ }
+ }
+
+ // make sure any children only present in the 'to combine' element
+ // are added
+ kids = toCombineElement.getChildren();
+ if (kids != null)
+ {
+ Map combinedKids = combined.getChildrenAsMap();
+ for (ConfigElement child : kids)
+ {
+ if (!combinedKids.containsKey(child.getName()))
+ {
+ combined.addChild(child);
+ }
+ }
+ }
+
+
+ return combined;
+ }
+
+ @Override
+ public void addChild(ConfigElement configElement)
+ {
+ super.addChild(configElement);
+
+ // also add the child element to our map
+ this.childrenMap.put(configElement.getName(), (GenericConfigElement)configElement);
+ }
+
+ /**
+ * Returns the children in a Map
+ *
+ * @return Child elements as a Map
+ */
+ public Map getChildrenAsMap()
+ {
+ return this.childrenMap;
+ }
+}
diff --git a/source/java/org/alfresco/web/config/WCMElementReader.java b/source/java/org/alfresco/web/config/WCMElementReader.java
new file mode 100644
index 0000000000..0306b2be13
--- /dev/null
+++ b/source/java/org/alfresco/web/config/WCMElementReader.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2005-2007 Alfresco Software Limited.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+ * As a special exception to the terms and conditions of version 2.0 of
+ * the GPL, you may redistribute this Program in connection with Free/Libre
+ * and Open Source Software ("FLOSS") applications as described in Alfresco's
+ * FLOSS exception. You should have recieved a copy of the text describing
+ * the FLOSS exception, and it is also available here:
+ * http://www.alfresco.com/legal/licensing"
+ */
+package org.alfresco.web.config;
+
+import org.alfresco.config.ConfigElement;
+import org.alfresco.config.xml.elementreader.GenericElementReader;
+import org.dom4j.Element;
+
+/**
+ * Custom element reader to parse config for WCM
+ *
+ * @author gavinc
+ */
+public class WCMElementReader extends GenericElementReader
+{
+ public static final String ELEMENT_WCM = "wcm";
+
+ /**
+ * Default constructor
+ */
+ public WCMElementReader()
+ {
+ super(null);
+ }
+
+ /**
+ * @see org.alfresco.config.xml.elementreader.ConfigElementReader#parse(org.dom4j.Element)
+ */
+ public ConfigElement parse(Element element)
+ {
+ WCMConfigElement wcmConfigElement = null;
+
+ if (element != null)
+ {
+ // create the config element object
+ wcmConfigElement = new WCMConfigElement(ELEMENT_WCM);
+
+ // we know there are no attributes or values for the root element
+ // so just process the children
+ processChildren(element, wcmConfigElement);
+ }
+
+ return wcmConfigElement;
+ }
+}
diff --git a/source/java/org/alfresco/web/config/WebClientConfigTest.java b/source/java/org/alfresco/web/config/WebClientConfigTest.java
index 730d32516d..bc2e635592 100644
--- a/source/java/org/alfresco/web/config/WebClientConfigTest.java
+++ b/source/java/org/alfresco/web/config/WebClientConfigTest.java
@@ -26,8 +26,11 @@ package org.alfresco.web.config;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.StringTokenizer;
import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement;
@@ -842,7 +845,7 @@ public class WebClientConfigTest extends BaseTest
public void testActionsOverriding()
{
- XMLConfigService svc = initXMLConfigService("test-config.xml", "test-config-override.xml");
+ XMLConfigService svc = initXMLConfigService("test-config.xml", "test-config-override.xml");
// get the "Actions" config
Config cfg = svc.getConfig("Actions Override");
@@ -921,4 +924,142 @@ public class WebClientConfigTest extends BaseTest
assertNotNull("Expecting a list of search attributes", attrs);
assertEquals("Expecting 2 search attributes", 2, attrs.size());
}
+
+ public void testWCM()
+ {
+ // setup the config service
+ XMLConfigService svc = initXMLConfigService("test-config.xml");
+
+ // get the global config object
+ Config global = svc.getGlobalConfig();
+ assertNotNull(global);
+
+ // get the wcm config
+ ConfigElement wcmConfig = global.getConfigElement("wcm");
+ assertNotNull(wcmConfig);
+
+ // get the workflows config
+ ConfigElement workflows = wcmConfig.getChild("workflows");
+ assertNotNull(workflows);
+ assertEquals("wcmwf:submit", workflows.getValue());
+
+ // get the admin workflows config
+ ConfigElement adminWorkflows = wcmConfig.getChild("admin-workflows");
+ assertNotNull(adminWorkflows);
+ assertEquals("wcmwf:changerequest", adminWorkflows.getValue());
+
+ // get the browse page size config
+ ConfigElement viewsConfig = wcmConfig.getChild("views");
+ assertNotNull(viewsConfig);
+ ConfigElement browsePageSizeConfig = viewsConfig.getChild("browse-page-size");
+ assertNotNull(browsePageSizeConfig);
+ assertEquals("25", browsePageSizeConfig.getValue());
+
+ // get the deployment polling frequency
+ ConfigElement deploymentConfig = wcmConfig.getChild("deployment");
+ assertNotNull(deploymentConfig);
+ ConfigElement pollingConfig = deploymentConfig.getChild("progress-polling-frequency");
+ assertNotNull(pollingConfig);
+ assertEquals("2", pollingConfig.getValue());
+
+ // get the link validation polling frequency
+ ConfigElement linksConfig = wcmConfig.getChild("links-management");
+ assertNotNull(linksConfig);
+ pollingConfig = linksConfig.getChild("progress-polling-frequency");
+ assertNotNull(pollingConfig);
+ assertEquals("2", pollingConfig.getValue());
+
+ // get the widget config
+ ConfigElement xformsConfig = wcmConfig.getChild("xforms");
+ assertNotNull(xformsConfig);
+ List widgetConfig = xformsConfig.getChildren("widget");
+ assertEquals(2, widgetConfig.size());
+
+ // make sure the xforms-scripts config is NOT present
+ ConfigElement scriptsConfig = wcmConfig.getChild("xforms-scripts");
+ assertNull(scriptsConfig);
+
+ // make sure the custom config element is NOT present
+ ConfigElement customConfig = wcmConfig.getChild("custom-config");
+ assertNull(customConfig);
+ }
+
+ public void testWCMOverride()
+ {
+ // setup the config service
+ XMLConfigService svc = initXMLConfigService("test-config.xml", "test-config-override.xml");
+
+ // get the global config object
+ Config global = svc.getGlobalConfig();
+ assertNotNull(global);
+
+ // get the wcm config
+ ConfigElement wcmConfig = global.getConfigElement("wcm");
+ assertNotNull(wcmConfig);
+
+ // get the workflows config
+ ConfigElement workflows = wcmConfig.getChild("workflows");
+ assertNotNull(workflows);
+ assertEquals("custom:submit", workflows.getValue().trim());
+
+ StringTokenizer t = new StringTokenizer(workflows.getValue().trim(), ", ");
+ while (t.hasMoreTokens())
+ {
+ System.out.println("workflow = '" + t.nextToken() + "'");
+ }
+
+ // get the admin workflows config
+ ConfigElement adminWorkflows = wcmConfig.getChild("admin-workflows");
+ assertNotNull(adminWorkflows);
+ assertEquals("custom:changerequest, custom:somejob", adminWorkflows.getValue());
+
+ t = new StringTokenizer(adminWorkflows.getValue().trim(), ", ");
+ while (t.hasMoreTokens())
+ {
+ System.out.println("admin workflow = '" + t.nextToken() + "'");
+ }
+
+ // get the browse page size config
+ ConfigElement viewsConfig = wcmConfig.getChild("views");
+ assertNotNull(viewsConfig);
+ ConfigElement browsePageSizeConfig = viewsConfig.getChild("browse-page-size");
+ assertNotNull(browsePageSizeConfig);
+ assertEquals("50", browsePageSizeConfig.getValue());
+
+ // get the deployment polling frequency
+ ConfigElement deploymentConfig = wcmConfig.getChild("deployment");
+ assertNotNull(deploymentConfig);
+ ConfigElement pollingConfig = deploymentConfig.getChild("progress-polling-frequency");
+ assertNotNull(pollingConfig);
+ assertEquals("10", pollingConfig.getValue());
+
+ // get the link validation polling frequency
+ ConfigElement linksConfig = wcmConfig.getChild("links-management");
+ assertNotNull(linksConfig);
+ pollingConfig = linksConfig.getChild("progress-polling-frequency");
+ assertNotNull(pollingConfig);
+ assertEquals("15", pollingConfig.getValue());
+
+ // get the widget config
+ ConfigElement xformsConfig = wcmConfig.getChild("xforms");
+ assertNotNull(xformsConfig);
+ List widgetConfig = xformsConfig.getChildren("widget");
+ assertEquals(3, widgetConfig.size());
+
+ // make sure the xforms-scripts config is present
+ ConfigElement scriptsConfig = wcmConfig.getChild("xforms-scripts");
+ assertNotNull(scriptsConfig);
+ assertEquals("/custom/custom-xforms.js, /custom/another-custom-xforms.js", scriptsConfig.getValue());
+
+ t = new StringTokenizer(scriptsConfig.getValue().trim(), ", ");
+ while (t.hasMoreTokens())
+ {
+ System.out.println("custom script = '" + t.nextToken() + "'");
+ }
+
+ // make sure the custom config element is present
+ ConfigElement customConfig = wcmConfig.getChild("custom-config");
+ assertNotNull(customConfig);
+ assertEquals("50", customConfig.getValue());
+ }
}
diff --git a/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java b/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java
index 1a3c9cd9fd..ab8ffecf47 100644
--- a/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java
+++ b/source/java/org/alfresco/web/forms/xforms/Schema2XForms.java
@@ -32,6 +32,7 @@ import java.text.SimpleDateFormat;
import java.util.*;
import javax.xml.transform.*;
import org.alfresco.service.namespace.NamespaceService;
+import org.alfresco.util.Pair;
import org.alfresco.web.forms.XMLUtil;
import org.apache.commons.jxpath.JXPathContext;
import org.apache.commons.jxpath.Pointer;
@@ -139,7 +140,7 @@ public class Schema2XForms implements Serializable
* @throws org.chiba.tools.schemabuilder.FormBuilderException
* If an error occurs building the XForm.
*/
- public Document buildXForm(final Document instanceDocument,
+ public Pair buildXForm(final Document instanceDocument,
final Document schemaDocument,
String rootElementName,
final ResourceBundle resourceBundle)
@@ -160,12 +161,26 @@ public class Schema2XForms implements Serializable
xformsDocument.getDocumentElement().getElementsByTagNameNS(NamespaceConstants.XFORMS_NS,
"model").item(0);
- //add XMLSchema if we use schema types
- modelSection.setAttributeNS(NamespaceConstants.XFORMS_NS, "schema", "#schema-1");
+ //add XMLSchema if we use schema types
final Element importedSchemaDocumentElement = (Element)
xformsDocument.importNode(schemaDocument.getDocumentElement(), true);
importedSchemaDocumentElement.setAttributeNS(null, "id", "schema-1");
+ NodeList nl = importedSchemaDocumentElement.getChildNodes();
+
+ for (int i = 0; i < nl.getLength(); i++)
+ {
+ Node current = nl.item(i);
+ if (current.getNamespaceURI() != null && current.getNamespaceURI().equals(NamespaceConstants.XMLSCHEMA_NS))
+ {
+ String localName = current.getLocalName();
+ if (localName.equals("include") || localName.equals("import"))
+ {
+ importedSchemaDocumentElement.removeChild(current);
+ }
+ }
+ }
+
modelSection.appendChild(importedSchemaDocumentElement);
//check if target namespace
@@ -312,7 +327,7 @@ public class Schema2XForms implements Serializable
xformsDocument.getDocumentElement().insertBefore(comment,
xformsDocument.getDocumentElement().getFirstChild());
xformsDocument.normalizeDocument();
- return xformsDocument;
+ return new Pair(xformsDocument, schema);
}
/**
diff --git a/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java b/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java
index 31f22eef42..dfa5758dca 100644
--- a/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java
+++ b/source/java/org/alfresco/web/forms/xforms/Schema2XFormsTest.java
@@ -668,7 +668,7 @@ public class Schema2XFormsTest
{
return new Vector().elements();
}
- });
+ }).getFirst();
}
private static SchemaUtil.Occurrence occuranceFromBind(final Element bindElement)
diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java
index 3ed199e25b..aff1c2c9ef 100644
--- a/source/java/org/alfresco/web/forms/xforms/XFormsBean.java
+++ b/source/java/org/alfresco/web/forms/xforms/XFormsBean.java
@@ -41,6 +41,7 @@ import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import org.alfresco.repo.avm.AVMNodeConverter;
+import org.alfresco.util.Pair;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.NavigationBean;
@@ -52,6 +53,7 @@ import org.alfresco.web.forms.FormProcessor;
import org.alfresco.web.forms.XMLUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.xerces.xs.XSModel;
import org.chiba.xml.events.ChibaEventNames;
import org.chiba.xml.events.DOMEventNames;
import org.chiba.xml.events.XFormsEventNames;
@@ -226,7 +228,8 @@ public class XFormsBean implements Serializable
final ChibaBean chibaBean = new ChibaBean();
chibaBean.setConfig(servletContext.getRealPath("/WEB-INF/chiba.xml"));
- chibaBean.setXMLContainer(this.getXFormsDocument());
+ Pair chibaPair = this.getXFormsDocument();
+ chibaBean.setXMLContainer(chibaPair.getFirst(), chibaPair.getSecond());
final EventTarget et = (EventTarget)
chibaBean.getXMLContainer().getDocumentElement();
@@ -726,7 +729,7 @@ public class XFormsBean implements Serializable
// }
// }
- private Document getXFormsDocument()
+ private Pair getXFormsDocument()
throws FormBuilderException
{
String path = null;
@@ -756,14 +759,14 @@ public class XFormsBean implements Serializable
final Document schemaDocument = this.xformsSession.form.getSchema();
XFormsBean.rewriteInlineURIs(schemaDocument, path);
final String rootElementName = this.xformsSession.form.getSchemaRootElementName();
- final Document result =
+ final Pair result =
this.xformsSession.schema2XForms.buildXForm(this.xformsSession.formInstanceData,
schemaDocument,
rootElementName,
resourceBundle);
if (LOGGER.isDebugEnabled())
{
- LOGGER.debug("generated xform: " + XMLUtil.toString(result));
+ LOGGER.debug("generated xform: " + XMLUtil.toString(result.getFirst()));
}
return result;
}
diff --git a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java b/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java
index 3980926b24..cc4f1fa209 100644
--- a/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java
+++ b/source/java/org/alfresco/web/forms/xforms/XFormsProcessor.java
@@ -25,6 +25,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
+import java.util.StringTokenizer;
import java.util.TreeSet;
import javax.faces.context.FacesContext;
@@ -297,6 +298,26 @@ public class XFormsProcessor implements FormProcessor
e.appendChild(result.createTextNode("\n"));
div.appendChild(e);
}
+
+ // output any custom scripts
+ ConfigElement config = Application.getConfigService(fc).getGlobalConfig().getConfigElement("wcm");
+ if (config != null)
+ {
+ // get the custom scripts to include
+ ConfigElement xformsScriptsConfig = config.getChild("xforms-scripts");
+ if (xformsScriptsConfig != null)
+ {
+ StringTokenizer t = new StringTokenizer(xformsScriptsConfig.getValue().trim(), ", ");
+ while (t.hasMoreTokens())
+ {
+ e = result.createElement("script");
+ e.setAttribute("type", "text/javascript");
+ e.setAttribute("src", contextPath + t.nextToken());
+ e.appendChild(result.createTextNode("\n"));
+ div.appendChild(e);
+ }
+ }
+ }
XMLUtil.print(result, out);
}
diff --git a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java
index 1827a82d7f..a1a9c874a8 100644
--- a/source/java/org/alfresco/web/ui/repo/tag/PageTag.java
+++ b/source/java/org/alfresco/web/ui/repo/tag/PageTag.java
@@ -35,6 +35,7 @@ import javax.servlet.jsp.tagext.TagSupport;
import org.alfresco.web.app.Application;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.web.bean.coci.CCProperties;
+import org.alfresco.web.config.ClientConfigElement;
import org.alfresco.web.ui.common.Utils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -255,7 +256,14 @@ public class PageTag extends TagSupport
out.write("