mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
- adding in the structure for an XSL FO rendering engine
- terminology cleanups to model and screens - extracting company-footer back into its own xsd; no reason to shove that feature in everyone's face. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@4227 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -646,13 +646,14 @@ create_form_title=Create Form Wizard
|
|||||||
create_form_desc=Create an XML Form definition from XML Schema and Rendering Engines
|
create_form_desc=Create an XML Form definition from XML Schema and Rendering Engines
|
||||||
create_form_step1_title=Upload an XML Schema
|
create_form_step1_title=Upload an XML Schema
|
||||||
create_form_step1_desc=Upload an XML Schema
|
create_form_step1_desc=Upload an XML Schema
|
||||||
create_form_step2_title=Edit the XML Schema
|
create_form_step2_title=Configure Rendering Engines
|
||||||
create_form_step2_desc=This is the generated XForm based on the schema provided.
|
create_form_step2_desc=Select rendering engines and rendering engine template to render form instance data processed by the form.
|
||||||
selected_rendering_engines=Selected Rendering Engines
|
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.
|
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_file=Rendering Engine Template File
|
||||||
rendering_engine_type=Rendering Engine Type
|
rendering_engine_type=Rendering Engine Type
|
||||||
extension_for_generated_assets=Extension For Generated Assets
|
extension_for_generated_assets=Extension For Generated Assets
|
||||||
|
mimetype_for_generated_assets=Mimetype For Generated Assets
|
||||||
file_extension=Extension
|
file_extension=Extension
|
||||||
schema=Schema
|
schema=Schema
|
||||||
schema_root_element_name=Root Element
|
schema_root_element_name=Root Element
|
||||||
|
@@ -36,11 +36,14 @@ import org.alfresco.model.WCMModel;
|
|||||||
import org.alfresco.service.cmr.model.FileInfo;
|
import org.alfresco.service.cmr.model.FileInfo;
|
||||||
import org.alfresco.service.cmr.repository.ContentService;
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||||
|
import org.alfresco.service.cmr.repository.MimetypeService;
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import org.alfresco.service.namespace.QName;
|
import org.alfresco.service.namespace.QName;
|
||||||
import org.alfresco.web.app.Application;
|
import org.alfresco.web.app.Application;
|
||||||
import org.alfresco.web.bean.FileUploadBean;
|
import org.alfresco.web.bean.FileUploadBean;
|
||||||
import org.alfresco.web.bean.wizard.BaseWizardBean;
|
import org.alfresco.web.bean.wizard.BaseWizardBean;
|
||||||
|
import org.alfresco.web.data.IDataContainer;
|
||||||
|
import org.alfresco.web.data.QuickSort;
|
||||||
import org.alfresco.web.forms.*;
|
import org.alfresco.web.forms.*;
|
||||||
import org.alfresco.web.forms.xforms.SchemaFormBuilder;
|
import org.alfresco.web.forms.xforms.SchemaFormBuilder;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
@@ -66,16 +69,19 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
private final String fileName;
|
private final String fileName;
|
||||||
private final File file;
|
private final File file;
|
||||||
private final String fileExtension;
|
private final String fileExtension;
|
||||||
|
private final String mimetype;
|
||||||
private final Class renderingEngineType;
|
private final Class renderingEngineType;
|
||||||
|
|
||||||
public RenderingEngineData(final String fileName,
|
public RenderingEngineData(final String fileName,
|
||||||
final File file,
|
final File file,
|
||||||
final String fileExtension,
|
final String fileExtension,
|
||||||
final Class renderingEngineType)
|
final String mimetype,
|
||||||
|
final Class renderingEngineType)
|
||||||
{
|
{
|
||||||
this.fileName = fileName;
|
this.fileName = fileName;
|
||||||
this.file = file;
|
this.file = file;
|
||||||
this.fileExtension = fileExtension;
|
this.fileExtension = fileExtension;
|
||||||
|
this.mimetype = mimetype;
|
||||||
this.renderingEngineType = renderingEngineType;
|
this.renderingEngineType = renderingEngineType;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -83,6 +89,11 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
{
|
{
|
||||||
return this.fileExtension;
|
return this.fileExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getMimetype()
|
||||||
|
{
|
||||||
|
return this.mimetype;
|
||||||
|
}
|
||||||
|
|
||||||
public String getFileName()
|
public String getFileName()
|
||||||
{
|
{
|
||||||
@@ -118,9 +129,12 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
private String formDescription;
|
private String formDescription;
|
||||||
private Class renderingEngineType = null;
|
private Class renderingEngineType = null;
|
||||||
protected ContentService contentService;
|
protected ContentService contentService;
|
||||||
|
protected MimetypeService mimetypeService;
|
||||||
private DataModel renderingEnginesDataModel;
|
private DataModel renderingEnginesDataModel;
|
||||||
private List<RenderingEngineData> renderingEngines = null;
|
private List<RenderingEngineData> renderingEngines = null;
|
||||||
private String fileExtension = null;
|
private String fileExtension = null;
|
||||||
|
private String mimetype = null;
|
||||||
|
private List<SelectItem> mimetypeChoices = null;
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Wizard implementation
|
// Wizard implementation
|
||||||
@@ -195,6 +209,8 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
props.put(WCMModel.PROP_FORM_SOURCE, schemaNodeRef);
|
props.put(WCMModel.PROP_FORM_SOURCE, schemaNodeRef);
|
||||||
props.put(WCMModel.PROP_FILE_EXTENSION_FOR_RENDITION,
|
props.put(WCMModel.PROP_FILE_EXTENSION_FOR_RENDITION,
|
||||||
tomd.getFileExtension());
|
tomd.getFileExtension());
|
||||||
|
props.put(WCMModel.PROP_MIMETYPE_FOR_RENDITION,
|
||||||
|
tomd.getMimetype());
|
||||||
this.nodeService.addAspect(renderingEngineNodeRef,
|
this.nodeService.addAspect(renderingEngineNodeRef,
|
||||||
WCMModel.ASPECT_RENDERING_ENGINE,
|
WCMModel.ASPECT_RENDERING_ENGINE,
|
||||||
props);
|
props);
|
||||||
@@ -216,6 +232,7 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
this.renderingEngineType = null;
|
this.renderingEngineType = null;
|
||||||
this.renderingEngines = new ArrayList<RenderingEngineData>();
|
this.renderingEngines = new ArrayList<RenderingEngineData>();
|
||||||
this.fileExtension = null;
|
this.fileExtension = null;
|
||||||
|
this.mimetype = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -262,6 +279,10 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
*/
|
*/
|
||||||
public String getFileExtension()
|
public String getFileExtension()
|
||||||
{
|
{
|
||||||
|
if (this.fileExtension == null && this.mimetype != null)
|
||||||
|
{
|
||||||
|
this.fileExtension = this.mimetypeService.getExtension(this.mimetype);
|
||||||
|
}
|
||||||
return this.fileExtension;
|
return this.fileExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -273,6 +294,26 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
this.fileExtension = fileExtension;
|
this.fileExtension = fileExtension;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the mimetype.
|
||||||
|
*/
|
||||||
|
public String getMimetype()
|
||||||
|
{
|
||||||
|
if (this.mimetype == null && this.fileExtension != null)
|
||||||
|
{
|
||||||
|
this.mimetype = this.mimetypeService.guessMimetype(this.fileExtension);
|
||||||
|
}
|
||||||
|
return this.mimetype;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mimetype The mimetype to set.
|
||||||
|
*/
|
||||||
|
public void setMimetype(String mimetype)
|
||||||
|
{
|
||||||
|
this.mimetype = mimetype;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add the selected rendering engine to the list
|
* Add the selected rendering engine to the list
|
||||||
*/
|
*/
|
||||||
@@ -289,13 +330,15 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
|
|
||||||
final RenderingEngineData data =
|
final RenderingEngineData data =
|
||||||
this.new RenderingEngineData(this.getRenderingEngineFileName(),
|
this.new RenderingEngineData(this.getRenderingEngineFileName(),
|
||||||
this.getRenderingEngineFile(),
|
this.getRenderingEngineFile(),
|
||||||
this.fileExtension,
|
this.getFileExtension(),
|
||||||
this.renderingEngineType);
|
this.getMimetype(),
|
||||||
|
this.renderingEngineType);
|
||||||
this.renderingEngines.add(data);
|
this.renderingEngines.add(data);
|
||||||
this.removeUploadedRenderingEngineFile();
|
this.removeUploadedRenderingEngineFile();
|
||||||
this.renderingEngineType = null;
|
this.renderingEngineType = null;
|
||||||
this.fileExtension = null;
|
this.fileExtension = null;
|
||||||
|
this.mimetype = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -368,7 +411,9 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
? XSLTRenderingEngine.class
|
? XSLTRenderingEngine.class
|
||||||
: (this.getRenderingEngineFileName().endsWith(".ftl")
|
: (this.getRenderingEngineFileName().endsWith(".ftl")
|
||||||
? FreeMarkerRenderingEngine.class
|
? FreeMarkerRenderingEngine.class
|
||||||
: null));
|
: (this.getRenderingEngineFileName().endsWith(".fo")
|
||||||
|
? XSLFORenderingEngine.class
|
||||||
|
: null)));
|
||||||
}
|
}
|
||||||
return (this.renderingEngineType == null
|
return (this.renderingEngineType == null
|
||||||
? null
|
? null
|
||||||
@@ -396,9 +441,40 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
new SelectItem(FreeMarkerRenderingEngine.class.getName(),
|
new SelectItem(FreeMarkerRenderingEngine.class.getName(),
|
||||||
getRenderingEngineTypeName(FreeMarkerRenderingEngine.class)),
|
getRenderingEngineTypeName(FreeMarkerRenderingEngine.class)),
|
||||||
new SelectItem(XSLTRenderingEngine.class.getName(),
|
new SelectItem(XSLTRenderingEngine.class.getName(),
|
||||||
getRenderingEngineTypeName(XSLTRenderingEngine.class))
|
getRenderingEngineTypeName(XSLTRenderingEngine.class)),
|
||||||
|
new SelectItem(XSLFORenderingEngine.class.getName(),
|
||||||
|
getRenderingEngineTypeName(XSLFORenderingEngine.class))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a list of mime types in the system
|
||||||
|
*
|
||||||
|
* @return List of mime types
|
||||||
|
*/
|
||||||
|
public List<SelectItem> getMimeTypeChoices()
|
||||||
|
{
|
||||||
|
if (this.mimetypeChoices == null)
|
||||||
|
{
|
||||||
|
this.mimetypeChoices = new ArrayList<SelectItem>(50);
|
||||||
|
|
||||||
|
final Map<String, String> mimetypes = this.mimetypeService.getDisplaysByMimetype();
|
||||||
|
for (String mimetype : mimetypes.keySet())
|
||||||
|
{
|
||||||
|
this.mimetypeChoices.add(new SelectItem(mimetype,
|
||||||
|
mimetypes.get(mimetype)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// make sure the list is sorted by the values
|
||||||
|
final QuickSort sorter = new QuickSort(this.mimetypeChoices,
|
||||||
|
"label",
|
||||||
|
true,
|
||||||
|
IDataContainer.SORT_CASEINSENSITIVE);
|
||||||
|
sorter.sort();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.mimetypeChoices;
|
||||||
|
}
|
||||||
|
|
||||||
private String getRenderingEngineTypeName(Class type)
|
private String getRenderingEngineTypeName(Class type)
|
||||||
{
|
{
|
||||||
@@ -406,7 +482,9 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
? "FreeMarker"
|
? "FreeMarker"
|
||||||
: (XSLTRenderingEngine.class.equals(type)
|
: (XSLTRenderingEngine.class.equals(type)
|
||||||
? "XSLT"
|
? "XSLT"
|
||||||
: null));
|
: (XSLFORenderingEngine.class.equals(type)
|
||||||
|
? "XSL-FO"
|
||||||
|
: null)));
|
||||||
}
|
}
|
||||||
|
|
||||||
private FileUploadBean getFileUploadBean(final String id)
|
private FileUploadBean getFileUploadBean(final String id)
|
||||||
@@ -566,7 +644,8 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
for (int i = 0; i < this.renderingEngines.size(); i++)
|
for (int i = 0; i < this.renderingEngines.size(); i++)
|
||||||
{
|
{
|
||||||
final RenderingEngineData tomd = this.renderingEngines.get(i);
|
final RenderingEngineData tomd = this.renderingEngines.get(i);
|
||||||
labels[1 + i] = "Form Data Renderer for " + tomd.getFileExtension();
|
labels[1 + i] = ("RenderingEngine for " + tomd.getFileExtension() +
|
||||||
|
" mimetype " + tomd.getMimetype());
|
||||||
values[1 + i] = tomd.getFileName();
|
values[1 + i] = tomd.getFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -584,7 +663,14 @@ public class CreateFormWizard extends BaseWizardBean
|
|||||||
{
|
{
|
||||||
this.contentService = contentService;
|
this.contentService = contentService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mimetypeService The mimetypeService to set.
|
||||||
|
*/
|
||||||
|
public void setMimetypeService(MimetypeService mimetypeService)
|
||||||
|
{
|
||||||
|
this.mimetypeService = mimetypeService;
|
||||||
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Helper Methods
|
// Helper Methods
|
||||||
|
@@ -69,13 +69,25 @@ public abstract class AbstractRenderingEngine
|
|||||||
*
|
*
|
||||||
* @return the file extension to use for generated assets.
|
* @return the file extension to use for generated assets.
|
||||||
*/
|
*/
|
||||||
public String getFileExtension()
|
public String getFileExtensionForRendition()
|
||||||
{
|
{
|
||||||
return (String)
|
return (String)
|
||||||
this.nodeService.getProperty(this.nodeRef,
|
this.nodeService.getProperty(this.nodeRef,
|
||||||
WCMModel.PROP_FILE_EXTENSION_FOR_RENDITION);
|
WCMModel.PROP_FILE_EXTENSION_FOR_RENDITION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the file extension to use for generated assets.
|
||||||
|
*
|
||||||
|
* @return the file extension to use for generated assets.
|
||||||
|
*/
|
||||||
|
public String getMimetypeForRendition()
|
||||||
|
{
|
||||||
|
return (String)
|
||||||
|
this.nodeService.getProperty(this.nodeRef,
|
||||||
|
WCMModel.PROP_MIMETYPE_FOR_RENDITION);
|
||||||
|
}
|
||||||
|
|
||||||
protected static AVMRemote getAVMRemote()
|
protected static AVMRemote getAVMRemote()
|
||||||
{
|
{
|
||||||
final FacesContext fc =
|
final FacesContext fc =
|
||||||
|
@@ -43,13 +43,13 @@ public interface FormProcessor
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates a user interface for inputing data into a form.
|
* Processes a user interface for inputing data into a form.
|
||||||
*
|
*
|
||||||
* @param instanceData provides the xml instance data if available.
|
* @param instanceData provides the xml instance data if available.
|
||||||
* @param form the form to generate for
|
* @param form the form to generate for
|
||||||
* @param out the writer to write the output to.
|
* @param out the writer to write the output to.
|
||||||
*/
|
*/
|
||||||
public void generate(final FormProcessor.InstanceData instanceData,
|
public void process(final FormProcessor.InstanceData instanceData,
|
||||||
final Form form,
|
final Form form,
|
||||||
final Writer out);
|
final Writer out);
|
||||||
}
|
}
|
||||||
|
@@ -238,7 +238,8 @@ public final class FormsService
|
|||||||
final RenderingEngine tom = (RenderingEngine)
|
final RenderingEngine tom = (RenderingEngine)
|
||||||
c.newInstance(tomNodeRef, this.nodeService, this.contentService);
|
c.newInstance(tomNodeRef, this.nodeService, this.contentService);
|
||||||
LOGGER.debug("loaded form data renderer type " + tom.getClass().getName() +
|
LOGGER.debug("loaded form data renderer type " + tom.getClass().getName() +
|
||||||
" for extension " + tom.getFileExtension() + ", " + tomNodeRef);
|
" for extension " + tom.getFileExtensionForRendition() +
|
||||||
|
", " + tomNodeRef);
|
||||||
tt.addRenderingEngine(tom);
|
tt.addRenderingEngine(tom);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
@@ -271,19 +272,19 @@ public final class FormsService
|
|||||||
{
|
{
|
||||||
// get the node ref of the node that will contain the content
|
// get the node ref of the node that will contain the content
|
||||||
final String renditionFileName =
|
final String renditionFileName =
|
||||||
this.stripExtension(formInstanceDataFileName) + "." + re.getFileExtension();
|
(this.stripExtension(formInstanceDataFileName) +
|
||||||
final OutputStream fileOut = this.avmService.createFile(parentPath, renditionFileName);
|
"." + re.getFileExtensionForRendition());
|
||||||
|
final OutputStream out = this.avmService.createFile(parentPath, renditionFileName);
|
||||||
final String renditionAvmPath = parentPath + '/' + renditionFileName;
|
final String renditionAvmPath = parentPath + '/' + renditionFileName;
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
LOGGER.debug("Created file node for file: " + renditionAvmPath);
|
LOGGER.debug("Created file node for file: " + renditionAvmPath);
|
||||||
final OutputStreamWriter out = new OutputStreamWriter(fileOut);
|
|
||||||
|
|
||||||
final HashMap<String, String> parameters =
|
final HashMap<String, String> parameters =
|
||||||
this.getRenderingEngineParameters(formInstanceDataFileName,
|
this.getRenderingEngineParameters(formInstanceDataFileName,
|
||||||
renditionFileName,
|
renditionFileName,
|
||||||
parentPath);
|
parentPath);
|
||||||
re.generate(formInstanceData, parameters, out);
|
re.render(formInstanceData, parameters, out);
|
||||||
out.close();
|
out.close();
|
||||||
|
|
||||||
final NodeRef renditionNodeRef =
|
final NodeRef renditionNodeRef =
|
||||||
@@ -335,7 +336,8 @@ public final class FormsService
|
|||||||
for (RenderingEngine re : form.getRenderingEngines())
|
for (RenderingEngine re : form.getRenderingEngines())
|
||||||
{
|
{
|
||||||
final String renditionFileName =
|
final String renditionFileName =
|
||||||
this.stripExtension(formInstanceDataFileName) + "." + re.getFileExtension();
|
(this.stripExtension(formInstanceDataFileName) + "." +
|
||||||
|
re.getFileExtensionForRendition());
|
||||||
|
|
||||||
if (LOGGER.isDebugEnabled())
|
if (LOGGER.isDebugEnabled())
|
||||||
LOGGER.debug("regenerating file node for : " + formInstanceDataFileName +
|
LOGGER.debug("regenerating file node for : " + formInstanceDataFileName +
|
||||||
@@ -354,13 +356,12 @@ public final class FormsService
|
|||||||
out = this.avmService.createFile(parentPath, renditionFileName);
|
out = this.avmService.createFile(parentPath, renditionFileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
final OutputStreamWriter writer = new OutputStreamWriter(out);
|
|
||||||
final HashMap<String, String> parameters =
|
final HashMap<String, String> parameters =
|
||||||
this.getRenderingEngineParameters(formInstanceDataFileName,
|
this.getRenderingEngineParameters(formInstanceDataFileName,
|
||||||
renditionFileName,
|
renditionFileName,
|
||||||
parentPath);
|
parentPath);
|
||||||
re.generate(formInstanceData, parameters, writer);
|
re.render(formInstanceData, parameters, out);
|
||||||
writer.close();
|
out.close();
|
||||||
|
|
||||||
LOGGER.debug("generated " + renditionFileName + " using " + re);
|
LOGGER.debug("generated " + renditionFileName + " using " + re);
|
||||||
}
|
}
|
||||||
|
@@ -56,14 +56,14 @@ public class FreeMarkerRenderingEngine
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the rendition using the configured freemarker template. This
|
* Renders the rendition using the configured freemarker template. This
|
||||||
* provides a root map to the freemarker template which places the xml document, and
|
* provides a root map to the freemarker template which places the xml document, and
|
||||||
* a variable named alfresco at the root. the alfresco variable contains a hash of
|
* a variable named alfresco at the root. the alfresco variable contains a hash of
|
||||||
* all parameters and all extension functions.
|
* all parameters and all extension functions.
|
||||||
*/
|
*/
|
||||||
public void generate(final Document xmlContent,
|
public void render(final Document xmlContent,
|
||||||
final Map<String, String> parameters,
|
final Map<String, String> parameters,
|
||||||
final Writer out)
|
final OutputStream out)
|
||||||
throws IOException,
|
throws IOException,
|
||||||
RenderingEngine.RenderingException
|
RenderingEngine.RenderingException
|
||||||
{
|
{
|
||||||
@@ -200,9 +200,10 @@ public class FreeMarkerRenderingEngine
|
|||||||
};
|
};
|
||||||
|
|
||||||
// process the form
|
// process the form
|
||||||
|
final Writer writer = new OutputStreamWriter(out);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
t.process(rootModel, out);
|
t.process(rootModel, writer);
|
||||||
}
|
}
|
||||||
catch (final TemplateException te)
|
catch (final TemplateException te)
|
||||||
{
|
{
|
||||||
@@ -211,7 +212,7 @@ public class FreeMarkerRenderingEngine
|
|||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
out.flush();
|
writer.flush();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -18,8 +18,8 @@ package org.alfresco.web.forms;
|
|||||||
|
|
||||||
import org.alfresco.service.cmr.repository.NodeRef;
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.OutputStream;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.io.Writer;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
@@ -50,20 +50,25 @@ public interface RenderingEngine
|
|||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/** the noderef associated with this output method */
|
/**
|
||||||
|
* XXXarielb this shouldn't be in the interface... i'll figure out a
|
||||||
|
* different id scheme once i make rendering engines configurable.
|
||||||
|
*
|
||||||
|
* the noderef associated with this output method
|
||||||
|
*/
|
||||||
public NodeRef getNodeRef();
|
public NodeRef getNodeRef();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Serializes the xml data in to a presentation format.
|
* Renders the xml data in to a presentation format.
|
||||||
*
|
*
|
||||||
* @param xmlContent the xml content to serialize
|
* @param formInstanceData the xml content to serialize
|
||||||
* @param form the form that collected the xml content.
|
* @param form the form that collected the xml content.
|
||||||
* @param sandBoxUrl the url of the current sandbox
|
* @param parameters the set of parameters to the rendering engine
|
||||||
* @param out the writer to serialize to.
|
* @param out the output stream to serialize to.
|
||||||
*/
|
*/
|
||||||
public void generate(final Document xmlContent,
|
public void render(final Document formInstanceData,
|
||||||
final Map<String, String> parameters,
|
final Map<String, String> parameters,
|
||||||
final Writer out)
|
final OutputStream out)
|
||||||
throws IOException, RenderingException;
|
throws IOException, RenderingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -71,7 +76,16 @@ public interface RenderingEngine
|
|||||||
* output method.
|
* output method.
|
||||||
*
|
*
|
||||||
* @return the file extension to use when generating content for this
|
* @return the file extension to use when generating content for this
|
||||||
* output method, such as html, rss, pdf.
|
* output method, such as html, xml, pdf.
|
||||||
*/
|
*/
|
||||||
public String getFileExtension();
|
public String getFileExtensionForRendition();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the mimetype to use when generating content for this
|
||||||
|
* output method.
|
||||||
|
*
|
||||||
|
* @return the mimetype to use when generating content for this
|
||||||
|
* output method, such as text/html, text/xml, application/pdf.
|
||||||
|
*/
|
||||||
|
public String getMimetypeForRendition();
|
||||||
}
|
}
|
||||||
|
93
source/java/org/alfresco/web/forms/XSLFORenderingEngine.java
Normal file
93
source/java/org/alfresco/web/forms/XSLFORenderingEngine.java
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2005 Alfresco, Inc.
|
||||||
|
*
|
||||||
|
* Licensed under the Mozilla Public License version 1.1
|
||||||
|
* with a permitted attribution clause. You may obtain a
|
||||||
|
* copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.alfresco.org/legal/license.txt
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
|
||||||
|
* either express or implied. See the License for the specific
|
||||||
|
* language governing permissions and limitations under the
|
||||||
|
* License.
|
||||||
|
*/
|
||||||
|
package org.alfresco.web.forms;
|
||||||
|
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
import javax.xml.transform.Result;
|
||||||
|
import javax.xml.transform.Source;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.sax.SAXResult;
|
||||||
|
import org.alfresco.service.cmr.repository.ContentService;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeRef;
|
||||||
|
import org.alfresco.service.cmr.repository.NodeService;
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.w3c.dom.*;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import org.apache.fop.apps.FOUserAgent;
|
||||||
|
import org.apache.fop.apps.Fop;
|
||||||
|
import org.apache.fop.apps.FOPException;
|
||||||
|
import org.apache.fop.apps.FopFactory;
|
||||||
|
import org.apache.fop.apps.FormattingResults;
|
||||||
|
import org.apache.fop.apps.MimeConstants;
|
||||||
|
import org.apache.fop.apps.PageSequenceResults;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A rendering engine which uses xsl-fo templates to generate renditions of
|
||||||
|
* form instance data.
|
||||||
|
*
|
||||||
|
* @author Ariel Backenroth
|
||||||
|
*/
|
||||||
|
public class XSLFORenderingEngine
|
||||||
|
extends XSLTRenderingEngine
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final Log LOGGER = LogFactory.getLog(XSLFORenderingEngine.class);
|
||||||
|
|
||||||
|
public XSLFORenderingEngine(final NodeRef nodeRef,
|
||||||
|
final NodeService nodeService,
|
||||||
|
final ContentService contentService)
|
||||||
|
{
|
||||||
|
super(nodeRef, nodeService, contentService);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void generate(final Document xmlContent,
|
||||||
|
final Map<String, String> parameters,
|
||||||
|
final OutputStream out)
|
||||||
|
throws IOException,
|
||||||
|
RenderingEngine.RenderingException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final FopFactory fopFactory = FopFactory.newInstance();
|
||||||
|
final FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
|
||||||
|
final Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);
|
||||||
|
|
||||||
|
// Resulting SAX events (the generated FO) must be piped through to FOP
|
||||||
|
final Result result = new SAXResult(fop.getDefaultHandler());
|
||||||
|
|
||||||
|
super.render(new DOMSource(xmlContent), parameters, result);
|
||||||
|
|
||||||
|
// Result processing
|
||||||
|
FormattingResults foResults = fop.getResults();
|
||||||
|
java.util.List pageSequences = foResults.getPageSequences();
|
||||||
|
for (java.util.Iterator it = pageSequences.iterator(); it.hasNext();)
|
||||||
|
{
|
||||||
|
PageSequenceResults pageSequenceResults = (PageSequenceResults)it.next();
|
||||||
|
System.out.println("PageSequence "
|
||||||
|
+ (String.valueOf(pageSequenceResults.getID()).length() > 0
|
||||||
|
? pageSequenceResults.getID() : "<no id>")
|
||||||
|
+ " generated " + pageSequenceResults.getPageCount() + " pages.");
|
||||||
|
}
|
||||||
|
System.out.println("Generated " + foResults.getPageCount() + " pages in total.");
|
||||||
|
}
|
||||||
|
catch (FOPException fope)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -45,9 +45,9 @@ public class XFormsProcessor
|
|||||||
* Generates html text which bootstraps the JavaScript code that will
|
* Generates html text which bootstraps the JavaScript code that will
|
||||||
* call back into the XFormsBean and get the xform and build the ui.
|
* call back into the XFormsBean and get the xform and build the ui.
|
||||||
*/
|
*/
|
||||||
public void generate(final InstanceData instanceData,
|
public void process(final InstanceData instanceData,
|
||||||
final Form tt,
|
final Form tt,
|
||||||
final Writer out)
|
final Writer out)
|
||||||
{
|
{
|
||||||
final FormsService ts = FormsService.getInstance();
|
final FormsService ts = FormsService.getInstance();
|
||||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||||
|
@@ -88,7 +88,7 @@ public class UIFormProcessor extends SelfRenderingComponent
|
|||||||
final Form form = this.getForm();
|
final Form form = this.getForm();
|
||||||
final FormProcessor.InstanceData formInstanceData = this.getFormInstanceData();
|
final FormProcessor.InstanceData formInstanceData = this.getFormInstanceData();
|
||||||
final FormProcessor tim = form.getFormProcessors().get(0);
|
final FormProcessor tim = form.getFormProcessors().get(0);
|
||||||
tim.generate(formInstanceData, form, out);
|
tim.process(formInstanceData, form, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
|
@@ -35,16 +35,6 @@ Describes a press release and related assets.
|
|||||||
</xs:restriction>
|
</xs:restriction>
|
||||||
</xs:simpleType>
|
</xs:simpleType>
|
||||||
|
|
||||||
<!-- defines the form for creating a company footer -->
|
|
||||||
<xs:element name="company_footer">
|
|
||||||
<xs:complexType>
|
|
||||||
<xs:sequence>
|
|
||||||
<xs:element name="name" type="xs:string"/>
|
|
||||||
<xs:element name="body" type="xs:anyType" minOccurs="1" maxOccurs="unbounded"/>
|
|
||||||
</xs:sequence>
|
|
||||||
</xs:complexType>
|
|
||||||
</xs:element>
|
|
||||||
|
|
||||||
<!-- defines the form for creating a press release -->
|
<!-- defines the form for creating a press release -->
|
||||||
<xs:element name="press_release">
|
<xs:element name="press_release">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
|
@@ -2054,6 +2054,10 @@
|
|||||||
<property-name>contentService</property-name>
|
<property-name>contentService</property-name>
|
||||||
<value>#{ContentService}</value>
|
<value>#{ContentService}</value>
|
||||||
</managed-property>
|
</managed-property>
|
||||||
|
<managed-property>
|
||||||
|
<property-name>mimetypeService</property-name>
|
||||||
|
<value>#{MimetypeService}</value>
|
||||||
|
</managed-property>
|
||||||
</managed-bean>
|
</managed-bean>
|
||||||
|
|
||||||
<managed-bean>
|
<managed-bean>
|
||||||
|
@@ -84,19 +84,32 @@ else
|
|||||||
value="#{WizardManager.bean.renderingEngineTypeChoices}"/>
|
value="#{WizardManager.bean.renderingEngineTypeChoices}"/>
|
||||||
</h:selectOneRadio>
|
</h:selectOneRadio>
|
||||||
|
|
||||||
|
<h:graphicImage id="required-image-mimetype"
|
||||||
|
value="/images/icons/required_field.gif" alt="Required Field" />
|
||||||
|
<h:outputText id="mimetype-output-text"
|
||||||
|
value="#{msg.mimetype_for_generated_assets}:"/>
|
||||||
|
<h:selectOneMenu id="mimetype"
|
||||||
|
value="#{WizardManager.bean.mimetype}">
|
||||||
|
<f:selectItems id="mimetype-choices"
|
||||||
|
value="#{WizardManager.bean.mimeTypeChoices}" />
|
||||||
|
</h:selectOneMenu>
|
||||||
|
|
||||||
<h:graphicImage id="required-image-file-extension"
|
<h:graphicImage id="required-image-file-extension"
|
||||||
value="/images/icons/required_field.gif" alt="Required Field" />
|
value="/images/icons/required_field.gif" alt="Required Field" />
|
||||||
<h:outputText id="file-extension-output-text"
|
<h:outputText id="file-extension-output-text"
|
||||||
value="#{msg.extension_for_generated_assets}:"/>
|
value="#{msg.extension_for_generated_assets}:"/>
|
||||||
<h:inputText id="file-extension" value="#{WizardManager.bean.fileExtension}"
|
<h:inputText id="file-extension"
|
||||||
|
value="#{WizardManager.bean.fileExtension}"
|
||||||
maxlength="10" size="10"/>
|
maxlength="10" size="10"/>
|
||||||
</h:panelGrid>
|
</h:panelGrid>
|
||||||
|
|
||||||
<h:panelGroup id="step-2-panel-group" styleClass="mainSubText">
|
<h:panelGroup id="step-2-panel-group" styleClass="mainSubText">
|
||||||
<h:outputText id="step-2-output-text" value="2." />
|
<h:outputText id="step-2-output-text" value="2." />
|
||||||
<h:commandButton id="add-to-list-button" value="#{msg.add_to_list_button}"
|
<h:commandButton id="add-to-list-button"
|
||||||
|
value="#{msg.add_to_list_button}"
|
||||||
actionListener="#{WizardManager.bean.addSelectedRenderingEngine}"
|
actionListener="#{WizardManager.bean.addSelectedRenderingEngine}"
|
||||||
styleClass="wizardButton" disabled="#{WizardManager.bean.addToListDisabled}" />
|
styleClass="wizardButton"
|
||||||
|
disabled="#{WizardManager.bean.addToListDisabled}" />
|
||||||
</h:panelGroup>
|
</h:panelGroup>
|
||||||
<h:outputText id="selected-rendering-engines-output-text"
|
<h:outputText id="selected-rendering-engines-output-text"
|
||||||
styleClass="mainSubText"
|
styleClass="mainSubText"
|
||||||
@@ -130,6 +143,12 @@ else
|
|||||||
<h:outputText id="data-table-value-3" value="#{row.fileExtension}" />
|
<h:outputText id="data-table-value-3" value="#{row.fileExtension}" />
|
||||||
</h:column>
|
</h:column>
|
||||||
<h:column id="data-table-column-4">
|
<h:column id="data-table-column-4">
|
||||||
|
<f:facet name="header">
|
||||||
|
<h:outputText id="data-table-name-4" value="#{msg.mimetype}" />
|
||||||
|
</f:facet>
|
||||||
|
<h:outputText id="data-table-value-4" value="#{row.mimetype}" />
|
||||||
|
</h:column>
|
||||||
|
<h:column id="data-table-column-5">
|
||||||
<a:actionLink id="remove-select-rendering-engine-action-link"
|
<a:actionLink id="remove-select-rendering-engine-action-link"
|
||||||
actionListener="#{WizardManager.bean.removeSelectedRenderingEngine}"
|
actionListener="#{WizardManager.bean.removeSelectedRenderingEngine}"
|
||||||
image="/images/icons/delete.gif"
|
image="/images/icons/delete.gif"
|
||||||
|
Reference in New Issue
Block a user