mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
first pass at edit form wizard
- modified evaluators to only show Create Form when in the Content Forms directory - edit form evaluator which only shows the edit form action when inside of a form directory git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4627 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -239,6 +239,7 @@ create_space=Create Space
|
||||
add_content=Add Content
|
||||
create_content=Create Content
|
||||
create_form=Create Form
|
||||
edit_form=Edit Form
|
||||
add_multiple_files=Add Multiple Files
|
||||
import_directory=Import Directory
|
||||
advanced_space_wizard=Advanced Space Wizard
|
||||
@@ -649,7 +650,9 @@ text_content=Plain Text Content
|
||||
html_content=HTML Content
|
||||
xml_content=XML Content
|
||||
create_form_title=Create Form Wizard
|
||||
edit_form_title=Edit Form Wizard
|
||||
create_form_desc=This wizard helps you create a new form.
|
||||
edit_form_desc=This wizard helps you edit a form.
|
||||
create_form_form_details_title=Step One - Specify details
|
||||
create_form_form_details_desc=Enter information about the web form you want to create.
|
||||
create_form_form_details_step1_desc=Select XML schema to use
|
||||
|
@@ -376,10 +376,24 @@
|
||||
<action id="create_form">
|
||||
<evaluator>org.alfresco.web.action.evaluator.CreateFormEvaluator</evaluator>
|
||||
<label-id>create_form</label-id>
|
||||
<image>/images/icons/new_content.gif</image>
|
||||
<image>/images/icons/new_form.gif</image>
|
||||
<action>wizard:createForm</action>
|
||||
</action>
|
||||
|
||||
<action id="edit_form">
|
||||
<evaluator>org.alfresco.web.action.evaluator.EditFormEvaluator</evaluator>
|
||||
<permissions>
|
||||
<permission allow="true">Write,CreateChildren</permission>
|
||||
</permissions>
|
||||
<label-id>edit_form</label-id>
|
||||
<image>/images/icons/edit_form.gif</image>
|
||||
<action>wizard:editForm</action>
|
||||
<action-listener>#{BrowseBean.setupSpaceAction}</action-listener>
|
||||
<params>
|
||||
<param name="id">#{actionContext.id}</param>
|
||||
</params>
|
||||
</action>
|
||||
|
||||
<!-- Create space -->
|
||||
<action id="create_space">
|
||||
<permissions>
|
||||
@@ -641,6 +655,7 @@
|
||||
|
||||
<!-- Actions Menu for More Actions in Browse screen -->
|
||||
<action-group id="browse_actions_menu">
|
||||
<action idref="edit_form" />
|
||||
<action idref="details_space" />
|
||||
<action idref="delete_space" />
|
||||
<action idref="cut_node" />
|
||||
|
@@ -345,7 +345,7 @@
|
||||
</step>
|
||||
</wizard>
|
||||
|
||||
<!-- Definition of the Create XML Type wizard -->
|
||||
<!-- Definition of the create form wizard -->
|
||||
<wizard name="createForm" managed-bean="CreateFormWizard"
|
||||
title-id="create_form_title" description-id="create_form_desc"
|
||||
icon="/images/icons/new_content_large.gif">
|
||||
@@ -380,6 +380,41 @@
|
||||
</step>
|
||||
</wizard>
|
||||
|
||||
<!-- Definition of the edit form wizard -->
|
||||
<wizard name="editForm" managed-bean="EditFormWizard"
|
||||
title-id="edit_form_title" description-id="edit_form_desc"
|
||||
icon="/images/icons/new_content_large.gif">
|
||||
<step name="form_details" title-id="create_form_form_details_title"
|
||||
description-id="create_form_form_details_desc">
|
||||
<page path="/jsp/wcm/create-form-wizard/details.jsp"
|
||||
title-id="create_form_form_details_title"
|
||||
description-id="create_form_form_details_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="configure_rendering_engine_templates"
|
||||
title-id="create_form_configure_rendering_engine_templates_title"
|
||||
description-id="create_form_configure_rendering_engine_templates_desc">
|
||||
<page path="/jsp/wcm/create-form-wizard/configure-rendering-engines.jsp"
|
||||
title-id="create_form_configure_rendering_engine_templates_title"
|
||||
description-id="create_form_configure_rendering_engine_templates_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="select_default_workflow"
|
||||
title-id="create_form_select_default_workflow_title"
|
||||
description-id="create_form_select_default_workflow_desc">
|
||||
<page path="/jsp/wcm/create-form-wizard/select-default-workflow.jsp"
|
||||
title-id="create_form_select_default_workflow_title"
|
||||
description-id="create_form_select_default_workflow_desc"
|
||||
instruction-id="default_instruction" />
|
||||
</step>
|
||||
<step name="summary" title-id="summary" description-id="summary_step_description">
|
||||
<page path="/jsp/wcm/create-form-wizard/summary.jsp"
|
||||
title-id="summary"
|
||||
description-id="summary_desc"
|
||||
instruction-id="content_finish_instruction" />
|
||||
</step>
|
||||
</wizard>
|
||||
|
||||
<!-- Definition of the Dashboard Layout wizard -->
|
||||
<wizard name="configureDashboard" managed-bean="DashboardWizard"
|
||||
title-id="configure_dashboard_title" description-id="configure_dashboard_desc"
|
||||
|
@@ -18,12 +18,16 @@ package org.alfresco.web.action.evaluator;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.security.AccessStatus;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.NavigationBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
import org.alfresco.web.forms.FormsService;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Create Web Form in the Forms DataDictionary folder
|
||||
@@ -37,10 +41,15 @@ public class CreateFormEvaluator implements ActionEvaluator
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
PermissionService service =
|
||||
Repository.getServiceRegistry(FacesContext.getCurrentInstance()).getPermissionService();
|
||||
return service.hasPermission(
|
||||
FormsService.getInstance().getContentFormsNodeRef(),
|
||||
PermissionService.ADD_CHILDREN) == AccessStatus.ALLOWED;
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
final ServiceRegistry services = Repository.getServiceRegistry(fc);
|
||||
final NavigationBean navigator = (NavigationBean)FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME);
|
||||
// get the path to the current name - compare last element with the Website folder assoc name
|
||||
final Path path = services.getNodeService().getPath(navigator.getCurrentNode().getNodeRef());
|
||||
final Path.Element element = path.get(path.size() - 1);
|
||||
final String endPath = element.getPrefixedString(services.getNamespaceService());
|
||||
// check we have the permission to create nodes in that Website folder
|
||||
return (Application.getContentFormsFolderName(fc).equals(endPath) &&
|
||||
navigator.getCurrentNode().hasPermission(PermissionService.ADD_CHILDREN));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* 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.action.evaluator;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.security.PermissionService;
|
||||
import org.alfresco.web.action.ActionEvaluator;
|
||||
import org.alfresco.web.app.Application;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.alfresco.web.bean.NavigationBean;
|
||||
import org.alfresco.web.bean.repository.Node;
|
||||
import org.alfresco.web.bean.repository.Repository;
|
||||
|
||||
/**
|
||||
* UI Action Evaluator - Edit Web Form in the Forms DataDictionary folder
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class EditFormEvaluator implements ActionEvaluator
|
||||
{
|
||||
/**
|
||||
* @see org.alfresco.web.action.ActionEvaluator#evaluate(org.alfresco.web.bean.repository.Node)
|
||||
*/
|
||||
public boolean evaluate(Node node)
|
||||
{
|
||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
||||
final ServiceRegistry services = Repository.getServiceRegistry(fc);
|
||||
final NavigationBean navigator = (NavigationBean)
|
||||
FacesHelper.getManagedBean(fc, NavigationBean.BEAN_NAME);
|
||||
// get the path to the current name - compare last element with the Website folder assoc name
|
||||
final Node currentNode = navigator.getCurrentNode();
|
||||
return (currentNode.hasAspect(WCMAppModel.ASPECT_FORM) &&
|
||||
currentNode.hasPermission(PermissionService.ADD_CHILDREN));
|
||||
}
|
||||
}
|
@@ -73,6 +73,7 @@ public class CreateFormWizard
|
||||
implements Serializable
|
||||
{
|
||||
private final String fileName;
|
||||
private final NodeRef nodeRef;
|
||||
private final File file;
|
||||
private final String title;
|
||||
private final String description;
|
||||
@@ -80,6 +81,18 @@ public class CreateFormWizard
|
||||
private final String outputPathPatternForRendition;
|
||||
private final RenderingEngine renderingEngine;
|
||||
|
||||
public RenderingEngineTemplateData(final RenderingEngineTemplate ret)
|
||||
{
|
||||
this.file = null;
|
||||
this.nodeRef = ret.getNodeRef();
|
||||
this.fileName = ret.getName();
|
||||
this.title = ret.getTitle();
|
||||
this.description = ret.getDescription();
|
||||
this.outputPathPatternForRendition = ret.getOutputPathPattern();
|
||||
this.mimetypeForRendition = ret.getMimetypeForRendition();
|
||||
this.renderingEngine = ret.getRenderingEngine();
|
||||
}
|
||||
|
||||
public RenderingEngineTemplateData(final String fileName,
|
||||
final File file,
|
||||
final String title,
|
||||
@@ -88,6 +101,7 @@ public class CreateFormWizard
|
||||
final String mimetypeForRendition,
|
||||
final RenderingEngine renderingEngine)
|
||||
{
|
||||
this.nodeRef = null;
|
||||
this.fileName = fileName;
|
||||
this.file = file;
|
||||
this.title = title;
|
||||
@@ -117,6 +131,11 @@ public class CreateFormWizard
|
||||
return this.file;
|
||||
}
|
||||
|
||||
public NodeRef getNodeRef()
|
||||
{
|
||||
return this.nodeRef;
|
||||
}
|
||||
|
||||
public String getTitle()
|
||||
{
|
||||
return this.title;
|
||||
@@ -155,20 +174,25 @@ public class CreateFormWizard
|
||||
|
||||
private final static Log LOGGER = LogFactory.getLog(CreateFormWizard.class);
|
||||
|
||||
protected String defaultWorkflowName = null;
|
||||
protected List<RenderingEngineTemplateData> renderingEngineTemplates = null;
|
||||
protected transient XSModel schema;
|
||||
protected String schemaFileName;
|
||||
protected ContentService contentService;
|
||||
protected MimetypeService mimetypeService;
|
||||
protected WorkflowService workflowService;
|
||||
|
||||
private String schemaRootElementName = null;
|
||||
private String formName = null;
|
||||
private String formTitle = null;
|
||||
private String formDescription = null;
|
||||
private String outputPathPatternForFormInstanceData = null;
|
||||
private String renderingEngineTemplateTitle = null;
|
||||
private String renderingEngineTemplateDescription = null;
|
||||
private String defaultWorkflowName = null;
|
||||
|
||||
private RenderingEngine renderingEngine = null;
|
||||
protected ContentService contentService;
|
||||
protected MimetypeService mimetypeService;
|
||||
protected WorkflowService workflowService;
|
||||
private transient DataModel renderingEngineTemplatesDataModel;
|
||||
private List<RenderingEngineTemplateData> renderingEngineTemplates = null;
|
||||
private String outputPathPatternForFormInstanceData = null;
|
||||
protected transient DataModel renderingEngineTemplatesDataModel;
|
||||
|
||||
private String outputPathPatternForRendition = null;
|
||||
private String mimetypeForRendition = null;
|
||||
private transient List<SelectItem> mimetypeChoices = null;
|
||||
@@ -180,8 +204,11 @@ public class CreateFormWizard
|
||||
@Override
|
||||
protected String finishImpl(final FacesContext context, final String outcome)
|
||||
throws Exception
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("creating form " + this.getFormName());
|
||||
}
|
||||
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
// get the node ref of the node that will contain the content
|
||||
@@ -223,17 +250,27 @@ public class CreateFormWizard
|
||||
this.nodeService.addAspect(folderInfo.getNodeRef(), WCMAppModel.ASPECT_FORM, props);
|
||||
|
||||
for (RenderingEngineTemplateData retd : this.renderingEngineTemplates)
|
||||
{
|
||||
this.saveRenderingEngineTemplate(retd, folderInfo.getNodeRef());
|
||||
}
|
||||
// return the default outcome
|
||||
return outcome;
|
||||
}
|
||||
|
||||
protected void saveRenderingEngineTemplate(final RenderingEngineTemplateData retd,
|
||||
final NodeRef formNodeRef)
|
||||
{
|
||||
LOGGER.debug("adding rendering engine template " + retd +
|
||||
" to form " + this.getFormName());
|
||||
|
||||
NodeRef renderingEngineTemplateNodeRef =
|
||||
this.fileFolderService.searchSimple(folderInfo.getNodeRef(), retd.getFileName());
|
||||
this.fileFolderService.searchSimple(formNodeRef, retd.getFileName());
|
||||
HashMap<QName, Serializable> props;
|
||||
if (renderingEngineTemplateNodeRef == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fileInfo = this.fileFolderService.create(folderInfo.getNodeRef(),
|
||||
final FileInfo fileInfo = this.fileFolderService.create(formNodeRef,
|
||||
retd.getFileName(),
|
||||
ContentModel.TYPE_CONTENT);
|
||||
if (LOGGER.isDebugEnabled())
|
||||
@@ -248,7 +285,7 @@ public class CreateFormWizard
|
||||
}
|
||||
|
||||
// get a writer for the content and put the file
|
||||
writer = this.contentService.getWriter(renderingEngineTemplateNodeRef,
|
||||
final ContentWriter writer = this.contentService.getWriter(renderingEngineTemplateNodeRef,
|
||||
ContentModel.PROP_CONTENT,
|
||||
true);
|
||||
// set the mimetype and encoding
|
||||
@@ -257,13 +294,13 @@ public class CreateFormWizard
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(retd.getFile());
|
||||
|
||||
this.nodeService.createAssociation(folderInfo.getNodeRef(),
|
||||
this.nodeService.createAssociation(formNodeRef,
|
||||
renderingEngineTemplateNodeRef,
|
||||
WCMAppModel.ASSOC_RENDERING_ENGINE_TEMPLATES);
|
||||
props = new HashMap<QName, Serializable>(2, 1.0f);
|
||||
props.put(WCMAppModel.PROP_PARENT_RENDERING_ENGINE_NAME,
|
||||
retd.getRenderingEngine().getName());
|
||||
props.put(WCMAppModel.PROP_FORM_SOURCE, folderInfo.getNodeRef());
|
||||
props.put(WCMAppModel.PROP_FORM_SOURCE, formNodeRef);
|
||||
this.nodeService.addAspect(renderingEngineTemplateNodeRef,
|
||||
WCMAppModel.ASPECT_RENDERING_ENGINE_TEMPLATE,
|
||||
props);
|
||||
@@ -289,9 +326,6 @@ public class CreateFormWizard
|
||||
WCMAppModel.TYPE_RENDITION_PROPERTIES,
|
||||
props);
|
||||
}
|
||||
// return the default outcome
|
||||
return outcome;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
@@ -300,6 +334,8 @@ public class CreateFormWizard
|
||||
|
||||
this.removeUploadedSchemaFile();
|
||||
this.removeUploadedRenderingEngineTemplateFile();
|
||||
this.schema = null;
|
||||
this.schemaFileName = null;
|
||||
this.schemaRootElementName = null;
|
||||
this.schemaRootElementNameChoices = null;
|
||||
this.formName = null;
|
||||
@@ -331,7 +367,7 @@ public class CreateFormWizard
|
||||
// checking step numbers
|
||||
|
||||
boolean disabled = false;
|
||||
int step = Application.getWizardManager().getCurrentStep();
|
||||
final int step = Application.getWizardManager().getCurrentStep();
|
||||
switch(step)
|
||||
{
|
||||
case 1:
|
||||
@@ -468,8 +504,10 @@ public class CreateFormWizard
|
||||
*/
|
||||
public String removeUploadedSchemaFile()
|
||||
{
|
||||
clearUpload(FILE_SCHEMA);
|
||||
this.clearUpload(FILE_SCHEMA);
|
||||
this.schemaRootElementNameChoices = null;
|
||||
this.schema = null;
|
||||
this.schemaFileName = null;
|
||||
|
||||
// refresh the current page
|
||||
return null;
|
||||
@@ -491,13 +529,17 @@ public class CreateFormWizard
|
||||
*/
|
||||
public String schemaFileValueChanged(final ValueChangeEvent vce)
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("schemaFileValueChanged(" + this.getSchemaFile() + ")");
|
||||
}
|
||||
if (this.getSchemaFile() != null)
|
||||
{
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
try
|
||||
{
|
||||
final Document d = ts.parseXML(this.getSchemaFile());
|
||||
final XSModel xsm = SchemaUtil.loadSchema(d);
|
||||
final FormsService formsService = FormsService.getInstance();
|
||||
final Document d = formsService.parseXML(this.getSchemaFile());
|
||||
this.schema = SchemaUtil.parseSchema(d);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -512,6 +554,12 @@ public class CreateFormWizard
|
||||
// ------------------------------------------------------------------------------
|
||||
// Bean Getters and Setters
|
||||
|
||||
/** Indicates whether or not the wizard is currently in edit mode */
|
||||
public boolean getEditMode()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the properties for current configured output methods JSF DataModel
|
||||
*
|
||||
@@ -645,14 +693,22 @@ public class CreateFormWizard
|
||||
return this.getFile(FILE_SCHEMA);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the schema file name
|
||||
*/
|
||||
public void setSchemaFileName(final String schemaFileName)
|
||||
{
|
||||
this.schemaFileName = (schemaFileName != null && schemaFileName.length() != 0
|
||||
? schemaFileName
|
||||
: null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Returns the schema file or <tt>null</tt>
|
||||
*/
|
||||
public String getSchemaFileName()
|
||||
{
|
||||
// try and retrieve the file and filename from the file upload bean
|
||||
// representing the file we previously uploaded.
|
||||
return this.getFileName(FILE_SCHEMA);
|
||||
return this.schemaFileName;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -693,33 +749,27 @@ public class CreateFormWizard
|
||||
*/
|
||||
public List<SelectItem> getSchemaRootElementNameChoices()
|
||||
{
|
||||
if (this.getSchemaFile() == null)
|
||||
List<SelectItem> result = Collections.EMPTY_LIST;
|
||||
if (this.schema != null)
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
if (this.schemaRootElementNameChoices == null)
|
||||
{
|
||||
this.schemaRootElementNameChoices = new LinkedList<SelectItem>();
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
try
|
||||
{
|
||||
final Document d = ts.parseXML(this.getSchemaFile());
|
||||
final XSModel xsm = SchemaUtil.loadSchema(d);
|
||||
final XSNamedMap elementsMap = xsm.getComponents(XSConstants.ELEMENT_DECLARATION);
|
||||
final XSNamedMap elementsMap = this.schema.getComponents(XSConstants.ELEMENT_DECLARATION);
|
||||
for (int i = 0; i < elementsMap.getLength(); i++)
|
||||
{
|
||||
final XSElementDeclaration e = (XSElementDeclaration)elementsMap.item(i);
|
||||
this.schemaRootElementNameChoices.add(new SelectItem(e.getName(), e.getName()));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
result = this.schemaRootElementNameChoices;
|
||||
}
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
final String msg = "unable to parse " + this.getSchemaFileName();
|
||||
this.removeUploadedSchemaFile();
|
||||
Utils.addErrorMessage(msg, e);
|
||||
LOGGER.debug("getSchemaRootElementNameChoices(" + this.schema +
|
||||
") = " + result.size());
|
||||
}
|
||||
}
|
||||
return this.schemaRootElementNameChoices;
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
196
source/java/org/alfresco/web/bean/wcm/EditFormWizard.java
Normal file
196
source/java/org/alfresco/web/bean/wcm/EditFormWizard.java
Normal file
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* 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.bean.wcm;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.model.WCMAppModel;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
import org.alfresco.service.cmr.model.FileInfo;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.ContentWriter;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.workflow.WorkflowDefinition;
|
||||
import org.alfresco.service.namespace.QName;
|
||||
import org.alfresco.service.namespace.RegexQNamePattern;
|
||||
import org.alfresco.web.app.AlfrescoNavigationHandler;
|
||||
import org.alfresco.web.forms.xforms.SchemaUtil;
|
||||
import org.alfresco.web.forms.Form;
|
||||
import org.alfresco.web.forms.FormsService;
|
||||
import org.alfresco.web.forms.RenderingEngineTemplate;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
/**
|
||||
* Backing bean for the Edit Form wizard.
|
||||
*
|
||||
* @author Ariel Backenroth
|
||||
*/
|
||||
public class EditFormWizard
|
||||
extends CreateFormWizard
|
||||
{
|
||||
|
||||
private List<RenderingEngineTemplateData> removedRenderingEngineTemplates;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
|
||||
/**
|
||||
* Initialises the wizard
|
||||
*/
|
||||
@Override
|
||||
public void init(final Map<String, String> parameters)
|
||||
{
|
||||
super.init(parameters);
|
||||
|
||||
// the editMode flag is used to disabled some wizard fields
|
||||
// this.editMode = true;
|
||||
|
||||
final NodeRef formNodeRef = this.browseBean.getActionSpace().getNodeRef();
|
||||
if (formNodeRef == null)
|
||||
{
|
||||
throw new IllegalArgumentException("Edit Form wizard requires action node context.");
|
||||
}
|
||||
|
||||
final Form form = FormsService.getInstance().getForm(formNodeRef);
|
||||
// simple properties
|
||||
this.setFormName(form.getName());
|
||||
this.setFormTitle(form.getTitle());
|
||||
this.setFormDescription(form.getDescription());
|
||||
this.setSchemaRootElementName(form.getSchemaRootElementName());
|
||||
final NodeRef schemaNodeRef = (NodeRef)
|
||||
this.nodeService.getProperty(formNodeRef, WCMAppModel.PROP_XML_SCHEMA);
|
||||
this.setSchemaFileName((String)this.nodeService.getProperty(schemaNodeRef,
|
||||
ContentModel.PROP_NAME));
|
||||
try
|
||||
{
|
||||
this.schema = SchemaUtil.parseSchema(form.getSchema());
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
final String msg = "unable to parse " + form.getName();
|
||||
Utils.addErrorMessage(msg, t);
|
||||
}
|
||||
final WorkflowDefinition wf = form.getDefaultWorkflow();
|
||||
if (wf != null)
|
||||
{
|
||||
this.defaultWorkflowName = wf.getName();
|
||||
}
|
||||
this.setOutputPathPatternForFormInstanceData(form.getOutputPathPattern());
|
||||
|
||||
for (RenderingEngineTemplate ret : form.getRenderingEngineTemplates())
|
||||
{
|
||||
final RenderingEngineTemplateData data =
|
||||
this.new RenderingEngineTemplateData(ret);
|
||||
this.renderingEngineTemplates.add(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.alfresco.web.bean.dialog.BaseDialogBean#finishImpl(javax.faces.context.FacesContext, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected String finishImpl(FacesContext context, String outcome)
|
||||
throws Exception
|
||||
{
|
||||
final NodeRef formNodeRef = this.browseBean.getActionSpace().getNodeRef();
|
||||
|
||||
// apply the name, title and description props
|
||||
this.nodeService.setProperty(formNodeRef, ContentModel.PROP_NAME, this.getFormName());
|
||||
this.nodeService.setProperty(formNodeRef, ContentModel.PROP_TITLE, this.getFormTitle());
|
||||
this.nodeService.setProperty(formNodeRef, ContentModel.PROP_DESCRIPTION, this.getFormDescription());
|
||||
this.nodeService.setProperty(formNodeRef,
|
||||
WCMAppModel.PROP_OUTPUT_PATH_PATTERN_FORM_INSTANCE_DATA,
|
||||
this.getOutputPathPatternForFormInstanceData());
|
||||
this.nodeService.setProperty(formNodeRef,
|
||||
WCMAppModel.PROP_XML_SCHEMA_ROOT_ELEMENT_NAME,
|
||||
this.getSchemaRootElementName());
|
||||
final WorkflowDefinition wd = this.getDefaultWorkflowDefinition();
|
||||
if (wd != null)
|
||||
{
|
||||
this.nodeService.setProperty(formNodeRef,
|
||||
WCMAppModel.PROP_DEFAULT_WORKFLOW_NAME,
|
||||
wd.getName());
|
||||
}
|
||||
|
||||
if (this.getSchemaFile() != null)
|
||||
{
|
||||
FileInfo fileInfo =
|
||||
this.fileFolderService.create(formNodeRef,
|
||||
this.getSchemaFileName(),
|
||||
ContentModel.TYPE_CONTENT);
|
||||
// get a writer for the content and put the file
|
||||
final ContentWriter writer = this.contentService.getWriter(fileInfo.getNodeRef(),
|
||||
ContentModel.PROP_CONTENT,
|
||||
true);
|
||||
// set the mimetype and encoding
|
||||
writer.setMimetype(MimetypeMap.MIMETYPE_XML);
|
||||
writer.setEncoding("UTF-8");
|
||||
writer.putContent(this.getSchemaFile());
|
||||
this.nodeService.setProperty(formNodeRef,
|
||||
WCMAppModel.PROP_XML_SCHEMA,
|
||||
fileInfo.getNodeRef());
|
||||
}
|
||||
|
||||
for (RenderingEngineTemplateData retd : this.removedRenderingEngineTemplates)
|
||||
{
|
||||
this.nodeService.removeChild(formNodeRef, retd.getNodeRef());
|
||||
}
|
||||
|
||||
for (RenderingEngineTemplateData retd : this.renderingEngineTemplates)
|
||||
{
|
||||
if (retd.getFile() != null)
|
||||
{
|
||||
this.saveRenderingEngineTemplate(retd, formNodeRef);
|
||||
}
|
||||
}
|
||||
return AlfrescoNavigationHandler.CLOSE_WIZARD_OUTCOME;
|
||||
}
|
||||
|
||||
/**
|
||||
* Action handler called when the Remove button is pressed to remove a
|
||||
* rendering engine
|
||||
*/
|
||||
@Override
|
||||
public void removeSelectedRenderingEngineTemplate(final ActionEvent event)
|
||||
{
|
||||
final RenderingEngineTemplateData wrapper = (RenderingEngineTemplateData)
|
||||
this.renderingEngineTemplatesDataModel.getRowData();
|
||||
if (wrapper != null)
|
||||
{
|
||||
if (this.removedRenderingEngineTemplates == null)
|
||||
{
|
||||
this.removedRenderingEngineTemplates = new LinkedList<RenderingEngineTemplateData>();
|
||||
}
|
||||
this.removedRenderingEngineTemplates.add(wrapper);
|
||||
}
|
||||
super.removeSelectedRenderingEngineTemplate(event);
|
||||
}
|
||||
|
||||
|
||||
/** Indicates whether or not the wizard is currently in edit mode */
|
||||
public boolean getEditMode()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -255,7 +255,7 @@ public class SchemaFormBuilder
|
||||
final ResourceBundle resourceBundle)
|
||||
throws FormBuilderException
|
||||
{
|
||||
final XSModel schema = SchemaUtil.loadSchema(schemaDocument);
|
||||
final XSModel schema = SchemaUtil.parseSchema(schemaDocument);
|
||||
this.typeTree = SchemaUtil.buildTypeTree(schema);
|
||||
|
||||
//refCounter = 0;
|
||||
|
@@ -202,7 +202,7 @@ public class SchemaUtil
|
||||
return SchemaUtil.DATA_TYPE_TO_NAME.get(type);
|
||||
}
|
||||
|
||||
public static XSModel loadSchema(final Document schemaDocument)
|
||||
public static XSModel parseSchema(final Document schemaDocument)
|
||||
throws FormBuilderException
|
||||
{
|
||||
try
|
||||
|
@@ -2085,6 +2085,51 @@
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<description>
|
||||
The bean that backs up the Edit Form Wizard
|
||||
</description>
|
||||
<managed-bean-name>EditFormWizard</managed-bean-name>
|
||||
<managed-bean-class>org.alfresco.web.bean.wcm.EditFormWizard</managed-bean-class>
|
||||
<managed-bean-scope>session</managed-bean-scope>
|
||||
<managed-property>
|
||||
<property-name>nodeService</property-name>
|
||||
<value>#{NodeService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>fileFolderService</property-name>
|
||||
<value>#{FileFolderService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>searchService</property-name>
|
||||
<value>#{SearchService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>namespaceService</property-name>
|
||||
<value>#{NamespaceService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>navigator</property-name>
|
||||
<value>#{NavigationBean}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>browseBean</property-name>
|
||||
<value>#{BrowseBean}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>contentService</property-name>
|
||||
<value>#{ContentService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>mimetypeService</property-name>
|
||||
<value>#{MimetypeService}</value>
|
||||
</managed-property>
|
||||
<managed-property>
|
||||
<property-name>workflowService</property-name>
|
||||
<value>#{WorkflowService}</value>
|
||||
</managed-property>
|
||||
</managed-bean>
|
||||
|
||||
<managed-bean>
|
||||
<description>
|
||||
The bean that backs up the Create Web Content Wizard
|
||||
|
@@ -18,7 +18,6 @@
|
||||
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
|
||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||
<%@ page import="org.alfresco.web.bean.FileUploadBean" %>
|
||||
<%@ page import="org.alfresco.web.bean.wcm.CreateFormWizard" %>
|
||||
<f:verbatim>
|
||||
<script type="text/javascript"
|
||||
@@ -63,18 +62,26 @@
|
||||
"<%= request.getContextPath() %>")
|
||||
}
|
||||
|
||||
function upload_complete(id, path)
|
||||
function upload_complete(id, path, filename)
|
||||
{
|
||||
var schema_file_input =
|
||||
document.getElementById("wizard:wizard-body:schema-file");
|
||||
schema_file_input.value = path;
|
||||
schema_file_input.value = filename;
|
||||
schema_file_input.form.submit();
|
||||
}
|
||||
</script>
|
||||
|
||||
</f:verbatim>
|
||||
|
||||
<h:inputText id="schema-file"
|
||||
value="#{WizardManager.bean.schemaFileName}"
|
||||
immediate="true"
|
||||
style="display:none;"
|
||||
valueChangeListener="#{WizardManager.bean.schemaFileValueChanged}"/>
|
||||
|
||||
<h:panelGrid id="panel_grid_1"
|
||||
columns="1" cellpadding="2" style="padding-top: 4px; padding-bottom: 4px;"
|
||||
columns="1" cellpadding="2"
|
||||
style="padding-top: 4px; padding-bottom: 4px;"
|
||||
width="100%" rowClasses="wizardSectionHeading">
|
||||
<h:outputText id="panel_grid_1_output_text_1"
|
||||
value=" #{msg.general_properties}" escape="false" />
|
||||
@@ -93,13 +100,8 @@
|
||||
value="/images/icons/required_field.gif" alt="Required Field" />
|
||||
<h:outputText id="output_text_schema"
|
||||
value="#{msg.schema}:"/>
|
||||
<h:column id="column_schema">
|
||||
<%
|
||||
FileUploadBean upload = (FileUploadBean)
|
||||
session.getAttribute(FileUploadBean.getKey(CreateFormWizard.FILE_SCHEMA));
|
||||
if (upload == null || upload.getFile() == null)
|
||||
{
|
||||
%>
|
||||
<h:column id="column_schema_empty"
|
||||
rendered="#{empty WizardManager.bean.schemaFileName}">
|
||||
<f:verbatim>
|
||||
<input id="wizard:wizard-body:file-input"
|
||||
type="file"
|
||||
@@ -107,14 +109,9 @@ if (upload == null || upload.getFile() == null)
|
||||
name="alfFileInput"
|
||||
onchange="javascript:handle_upload(this)"/>
|
||||
</f:verbatim>
|
||||
<h:inputText id="schema-file"
|
||||
value="#{WizardManager.bean.schemaFileName}"
|
||||
rendered="#{empty WizardManager.bean.schemaFileName}"
|
||||
style="display: none"
|
||||
valueChangeListener="#{WizardManager.bean.schemaFileValueChanged}"/>
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
</h:column>
|
||||
<h:column id="column_schema_not_empty"
|
||||
rendered="#{!empty WizardManager.bean.schemaFileName}">
|
||||
<h:outputText id="output_text_schema_name"
|
||||
value="#{WizardManager.bean.schemaFileName}"/>
|
||||
<h:outputText id="output_text_schema_space"
|
||||
@@ -126,9 +123,6 @@ if (upload == null || upload.getFile() == null)
|
||||
action="#{WizardManager.bean.removeUploadedSchemaFile}"
|
||||
showLink="false"
|
||||
target="top"/>
|
||||
<%
|
||||
}
|
||||
%>
|
||||
</h:column>
|
||||
|
||||
<h:outputText id="no_graphic_image_root_element_name"
|
||||
|
@@ -46,5 +46,5 @@ function handle_upload_helper(fileInputElement,
|
||||
function upload_complete_helper(id)
|
||||
{
|
||||
var upload = _uploads[id];
|
||||
upload.callback(id, upload.path);
|
||||
upload.callback(id, upload.path, upload.path.replace(/.*[\/\\]([^\/\\]+)/, "$1"));
|
||||
}
|
||||
|
Reference in New Issue
Block a user