diff --git a/config/alfresco/messages/webclient.properties b/config/alfresco/messages/webclient.properties index 930f3de082..b31aa088ba 100644 --- a/config/alfresco/messages/webclient.properties +++ b/config/alfresco/messages/webclient.properties @@ -651,10 +651,11 @@ create_form_step2_desc=This is the generated XForm based on the schema provided. selected_rendering_engines=Selected Rendering Engines configure_rendering_engines_step1_desc=Upload rendering engine template and specify the extension to use for its generated assets. rendering_engine_file=Rendering Engine Template File +rendering_engine_type=Rendering Engine Type extension_for_generated_assets=Extension For Generated Assets file_extension=Extension schema=Schema -schema_root_tag_name=Root Tag +schema_root_element_name=Root Element edit_xml_schema=Edit XML Schema form=Form configure_rendering_engines=Configure Rendering Engines diff --git a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java index 2730459e77..0528ff8047 100644 --- a/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java +++ b/source/java/org/alfresco/web/bean/wcm/CreateFormWizard.java @@ -113,7 +113,7 @@ public class CreateFormWizard extends BaseWizardBean private final static Log LOGGER = LogFactory.getLog(CreateFormWizard.class); - private String schemaRootTagName; + private String schemaRootElementName; private String formName; private String formDescription; private Class renderingEngineType = null; @@ -163,7 +163,7 @@ public class CreateFormWizard extends BaseWizardBean this.nodeService.addAspect(schemaNodeRef, ContentModel.ASPECT_TITLED, props); props = new HashMap(1, 1.0f); - props.put(WCMModel.PROP_SCHEMA_ROOT_TAG_NAME, this.getSchemaRootTagName()); + props.put(WCMModel.PROP_SCHEMA_ROOT_ELEMENT_NAME, this.getSchemaRootElementName()); this.nodeService.addAspect(schemaNodeRef, WCMModel.ASPECT_FORM, props); for (RenderingEngineData tomd : this.renderingEngines) @@ -210,7 +210,7 @@ public class CreateFormWizard extends BaseWizardBean this.removeUploadedSchemaFile(); this.removeUploadedRenderingEngineFile(); - this.schemaRootTagName = null; + this.schemaRootElementName = null; this.formName = null; this.formDescription = null; this.renderingEngineType = null; @@ -473,26 +473,26 @@ public class CreateFormWizard extends BaseWizardBean } /** - * Sets the root tag name to use when processing the schema. + * Sets the root element name to use when processing the schema. */ - public void setSchemaRootTagName(final String schemaRootTagName) + public void setSchemaRootElementName(final String schemaRootElementName) { - this.schemaRootTagName = schemaRootTagName; + this.schemaRootElementName = schemaRootElementName; } /** - * Returns the root tag name to use when processing the schema. + * Returns the root element name to use when processing the schema. */ - public String getSchemaRootTagName() + public String getSchemaRootElementName() { - return this.schemaRootTagName; + return this.schemaRootElementName; } /** - * @return the possible root tag names for use with the schema based on + * @return the possible root element names for use with the schema based on * the element declarations it defines. */ - public List getSchemaRootTagNameChoices() + public List getSchemaRootElementNameChoices() { final List result = new LinkedList(); if (this.getSchemaFile() != null) diff --git a/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java b/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java index a85faff8f6..6b514e25f4 100644 --- a/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java +++ b/source/java/org/alfresco/web/forms/AbstractRenderingEngine.java @@ -16,6 +16,8 @@ */ package org.alfresco.web.forms; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import javax.faces.context.FacesContext; import org.alfresco.model.WCMModel; import org.alfresco.repo.avm.AVMRemote; @@ -91,17 +93,23 @@ public abstract class AbstractRenderingEngine return parentAVMPath; } + if (path.charAt(0) == '/') { - //XXXarielb this doesn't work with context paths for the website - parent = parentAVMPath.substring(0, - parentAVMPath.indexOf(':') + - ('/' + AVMConstants.DIR_APPBASE + - '/' + AVMConstants.DIR_WEBAPPS).length()); + final Pattern p = Pattern.compile("([^:]+:/" + AVMConstants.DIR_APPBASE + + "/[^/]+/[^/]+).*"); + final Matcher m = p.matcher(parentAVMPath); + if (m.matches()) + { + parent = m.group(1); + } + } + else if (parentAVMPath.charAt(parentAVMPath.length() - 1) != '/') + { + parent = parent + '/'; } - final String result = - parent + (parent.endsWith("/") || path.startsWith("/") ? path : '/' + path); + final String result = parent + path; LOGGER.debug("built full avmPath " + result + " for parent " + parentAVMPath + " and request path " + path); diff --git a/source/java/org/alfresco/web/forms/FormsService.java b/source/java/org/alfresco/web/forms/FormsService.java index 401fb93a14..9d35e4f5d2 100644 --- a/source/java/org/alfresco/web/forms/FormsService.java +++ b/source/java/org/alfresco/web/forms/FormsService.java @@ -221,7 +221,7 @@ public final class FormsService this.nodeService.getProperty(schemaNodeRef, ContentModel.PROP_TITLE); LOGGER.debug("title is " + title); final String schemaRootTagName = (String) - this.nodeService.getProperty(schemaNodeRef, WCMModel.PROP_SCHEMA_ROOT_TAG_NAME); + this.nodeService.getProperty(schemaNodeRef, WCMModel.PROP_SCHEMA_ROOT_ELEMENT_NAME); LOGGER.debug("root tag name is " + schemaRootTagName); final Form tt = new FormImpl(title, schemaNodeRef, schemaRootTagName); for (AssociationRef assoc : this.nodeService.getTargetAssocs(schemaNodeRef, diff --git a/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java b/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java index 2e94caad45..f03dbf5f61 100644 --- a/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java +++ b/source/java/org/alfresco/web/forms/FreeMarkerRenderingEngine.java @@ -79,7 +79,9 @@ public class FreeMarkerRenderingEngine final TemplateHashModel instanceDataModel = NodeModel.wrap(xmlContent); // build models for each of the extension functions - final TemplateModel parseXMLDocumentModel = new TemplateMethodModel() + final HashMap methodModels = + new HashMap(3, 1.0f); + methodModels.put("parseXMLDocument", new TemplateMethodModel() { public Object exec(final List args) throws TemplateModelException @@ -97,8 +99,9 @@ public class FreeMarkerRenderingEngine throw new TemplateModelException(e); } } - }; - final TemplateModel parseXMLDocumentsModel = new TemplateMethodModel() + }); + + methodModels.put("parseXMLDocuments", new TemplateMethodModel() { public Object exec(final List args) throws TemplateModelException @@ -143,24 +146,37 @@ public class FreeMarkerRenderingEngine throw new TemplateModelException(e); } } - }; + }); + + // for debugging + methodModels.put("_getAVMPath", new TemplateMethodModel() + { + public Object exec(final List args) + throws TemplateModelException + { + try + { + return FreeMarkerRenderingEngine.toAVMPath(parameters.get("parent_path"), + (String)args.get(0)); + } + catch (Exception e) + { + throw new TemplateModelException(e); + } + } + }); // build a wrapper for the parameters. this also wraps the extension functions // so they appear in the namespace alfresco. final TemplateHashModel parameterModel = new SimpleHash(parameters) { + public TemplateModel get(final String key) throws TemplateModelException { - if ("parseXMLDocument".equals(key)) - { - return parseXMLDocumentModel; - } - if ("parseXMLDocuments".equals(key)) - { - return parseXMLDocumentsModel; - } - return super.get(key); + return (methodModels.containsKey(key) + ? methodModels.get(key) + : super.get(key)); } }; @@ -172,7 +188,9 @@ public class FreeMarkerRenderingEngine public TemplateModel get(final String key) throws TemplateModelException { - return ALFRESCO_NS_PREFIX.equals(key) ? parameterModel : instanceDataModel.get(key); + return (ALFRESCO_NS_PREFIX.equals(key) + ? parameterModel + : instanceDataModel.get(key)); } public boolean isEmpty() diff --git a/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java b/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java index 3e2925404d..f75ae06f52 100644 --- a/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java +++ b/source/java/org/alfresco/web/forms/XSLTRenderingEngine.java @@ -194,6 +194,17 @@ public class XSLTRenderingEngine }; } + // for debugging + public static String _getAVMPath(final ExpressionContext ec, + final String path) + throws TransformerException, + IOException, + SAXException + { + final FormDataFunctions ef = XSLTRenderingEngine.getFormDataFunctions(); + return XSLTRenderingEngine.toAVMPath(ec, path); + } + private void addScript(final Document d) { final Element docEl = d.getDocumentElement(); diff --git a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl index 35e2b395bd..25ae73889c 100644 --- a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl +++ b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.ftl @@ -37,6 +37,12 @@
<#noparse>${alfresco.request_context_path}
${alfresco.request_context_path} +
<#noparse>${alfresco._getAVMPath('foo')}
+ ${alfresco._getAVMPath('foo')} + +
<#noparse>${alfresco._getAVMPath('/foo')}
+ ${alfresco._getAVMPath('/foo')} +
My value accessed using <#noparse>${simple.string}:
${simple.string} diff --git a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl index ff747f3271..96dac2782d 100644 --- a/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl +++ b/source/test-resources/xforms/unit-tests/output-method-callout-test/output-method-callout.xsl @@ -32,27 +32,42 @@ body
Generated by output-method-callout.xsl
+
<xsl:value-of select="$alfresco:avm_sandbox_url"/>
+
<xsl:value-of select="$alfresco:form_instance_data_file_name"/>
+
<xsl:value-of select="$alfresco:rendition_file_name"/>
+
<xsl:value-of select="$alfresco:parent_path"/>
+
<xsl:value-of select="$alfresco:request_context_path"/>
+
+ <xsl:value-of select="alfresco:_getAVMPath('foo')"/> +
+ + +
+ <xsl:value-of select="alfresco:_getAVMPath('/foo')"/> +
+ +
My value accessed using /simple/string:
My value accessed using alfresco:parseXMLDocument($alfresco:form_instance_data_file_name):
diff --git a/source/web/jsp/wcm/create-form-wizard/configure-rendering-engines.jsp b/source/web/jsp/wcm/create-form-wizard/configure-rendering-engines.jsp index 8e85c7224a..7d0c387574 100644 --- a/source/web/jsp/wcm/create-form-wizard/configure-rendering-engines.jsp +++ b/source/web/jsp/wcm/create-form-wizard/configure-rendering-engines.jsp @@ -77,7 +77,7 @@ else + value="#{msg.rendering_engine_type}:"/> - - - - + + +