- changing terminology from root tag name to root element name

- fixing form data functions calls with absolute paths - making them webapp relative - and adding test cases

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4218 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-10-24 23:40:05 +00:00
parent 3d6221f39e
commit 5b6772ac2c
10 changed files with 99 additions and 40 deletions

View File

@@ -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

View File

@@ -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<QName, Serializable>(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<SelectItem> getSchemaRootTagNameChoices()
public List<SelectItem> getSchemaRootElementNameChoices()
{
final List<SelectItem> result = new LinkedList<SelectItem>();
if (this.getSchemaFile() != null)

View File

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

View File

@@ -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,

View File

@@ -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<String, TemplateMethodModel> methodModels =
new HashMap<String, TemplateMethodModel>(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()

View File

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

View File

@@ -37,6 +37,12 @@
<div class="name"><#noparse>${alfresco.request_context_path}</#noparse></div>
<span>${alfresco.request_context_path}</span>
<div class="name"><#noparse>${alfresco._getAVMPath('foo')}</#noparse></div>
<span>${alfresco._getAVMPath('foo')}</span>
<div class="name"><#noparse>${alfresco._getAVMPath('/foo')}</#noparse></div>
<span>${alfresco._getAVMPath('/foo')}</span>
<div class="name">My value accessed using <#noparse>${simple.string}</#noparse>:</div>
<span>${simple.string}</span>

View File

@@ -32,27 +32,42 @@ body
</head>
<body>
<div>Generated by output-method-callout.xsl</div>
<div class="name">
&lt;xsl:value-of select="$alfresco:avm_sandbox_url"/&gt;
</div>
<span><xsl:value-of select="$alfresco:avm_sandbox_url"/></span>
<div class="name">
&lt;xsl:value-of select="$alfresco:form_instance_data_file_name"/&gt;
</div>
<span><xsl:value-of select="$alfresco:form_instance_data_file_name"/></span>
<div class="name">
&lt;xsl:value-of select="$alfresco:rendition_file_name"/&gt;
</div>
<span><xsl:value-of select="$alfresco:rendition_file_name"/></span>
<div class="name">
&lt;xsl:value-of select="$alfresco:parent_path"/&gt;
</div>
<span><xsl:value-of select="$alfresco:parent_path"/></span>
<div class="name">
&lt;xsl:value-of select="$alfresco:request_context_path"/&gt;
</div>
<span><xsl:value-of select="$alfresco:request_context_path"/></span>
<div class="name">
&lt;xsl:value-of select="alfresco:_getAVMPath('foo')"/&gt;
</div>
<span><xsl:value-of select="alfresco:_getAVMPath('foo')"/></span>
<div class="name">
&lt;xsl:value-of select="alfresco:_getAVMPath('/foo')"/&gt;
</div>
<span><xsl:value-of select="alfresco:_getAVMPath('/foo')"/></span>
<div class="name">My value accessed using /simple/string:</div>
<span><xsl:value-of select="/simple/string"/></span>
<div class="name">My value accessed using alfresco:parseXMLDocument($alfresco:form_instance_data_file_name):</div>

View File

@@ -77,7 +77,7 @@ else
<h:graphicImage id="required-image-rendering-engine-type"
value="/images/icons/required_field.gif" alt="Required Field" />
<h:outputText id="rendering-engine-type-output-text"
value="#{msg.type}:"/>
value="#{msg.rendering_engine_type}:"/>
<h:selectOneRadio id="rendering-engine-type"
value="#{WizardManager.bean.renderingEngineType}">
<f:selectItems id="rendering-engine-type-choices"

View File

@@ -96,12 +96,12 @@ if (upload == null || upload.getFile() == null)
%>
</h:column>
<h:graphicImage id="graphic_image_root_tag_name"
<h:graphicImage id="graphic_image_root_element_name"
value="/images/icons/required_field.gif" alt="Required Field" />
<h:outputText id="output_text_root_tag_name" value="#{msg.schema_root_tag_name}:"/>
<h:selectOneMenu id="schema-root-tag-name"
value="#{WizardManager.bean.schemaRootTagName}">
<f:selectItems value="#{WizardManager.bean.schemaRootTagNameChoices}"/>
<h:outputText id="output_text_root_element_name" value="#{msg.schema_root_element_name}:"/>
<h:selectOneMenu id="schema-root-element-name"
value="#{WizardManager.bean.schemaRootElementName}">
<f:selectItems value="#{WizardManager.bean.schemaRootElementNameChoices}"/>
</h:selectOneMenu>
<h:graphicImage id="graphic_image_name" value="/images/icons/required_field.gif" alt="Required Field" />