Merged V3.2 to HEAD

16725: Merged V3.1 to V3.2
      16721: Merged DEV/BELARUS/V3.1 to V3.1 
         16483: Fix for ETHREEOH-2728 : WCM - Forms rendering issue using IE6
   16889: Merged V3.1 to V3.2
      16888: Merged V2.2 to V3.1 
         16694: Fix for ETHREEOH-1384/ACT 11135: Poor performance when using webscript based web forms 
         16787: Fixed Web-Client Eclipse project after recent chiba JAR file name change 
         16840: Resolution to issue in ETHREEOH-2633: Change to Common.js function implemented in CHK-5134 causes problems with missing icons in Navigator panel. Implemented configuration approach so that both modes can be supported. 
         16870: Fix for ETWOTWO-119 & ALFCOM-332: WCM config override issues where the OOTB web-client-config-wcm.xml file needed to be changed and the ability to define custom scripts to load to avoid the need to edit xforms.js or XFormsProcessor.java

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@16913 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Gavin Cornwell
2009-10-14 11:37:27 +00:00
parent ba3f9629b5
commit b1e86e69f2
21 changed files with 1103 additions and 100 deletions

View File

@@ -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<Document, XSModel> 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<Document, XSModel>(xformsDocument, schema);
}
/**

View File

@@ -668,7 +668,7 @@ public class Schema2XFormsTest
{
return new Vector<String>().elements();
}
});
}).getFirst();
}
private static SchemaUtil.Occurrence occuranceFromBind(final Element bindElement)

View File

@@ -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<Document, XSModel> 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<Document, XSModel> 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<Document, XSModel> 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;
}

View File

@@ -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);
}