mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
upgrading to chiba-1.3.0. there are several significant bug fixes that customers will notice - and several that make my life easier so i figure might as well go for it. things seem reasonably stable at this point so i'm comfortable with taking the hit sooner rather than later.
- adding chiba-1.3.0.jar in lib rather than chiba dir (removing chiba dir since we really only use one jar from them at this point) - need to generate xform with unprefixed id attributes - using a bunch of constants now defined within chiba. - generating my own xpaths in js using binding nodesets since chiba remove the once useful chiba:xpath attribute. - better error handling for breakage when processing schema and xform fixing bug in create form details screen where form-name and form-title weren't being prefilled after uploading the schema. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4625 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -42,7 +42,6 @@
|
||||
<fileset dir="${dir.common.lib}/treecache" includes="*.jar" />
|
||||
<fileset dir="${dir.common.lib}/swarmcache" includes="*.jar" />
|
||||
<fileset dir="${dir.common.lib}/jbpm" includes="*.jar" />
|
||||
<fileset dir="${dir.common.lib}/chiba" includes="*.jar" />
|
||||
<fileset dir="${dir.common.lib}/fop" includes="*.jar"/>
|
||||
<fileset dir="${dir.project.core}/build/dist" includes="${dir.name.core}.jar" />
|
||||
<fileset dir="${dir.project.repository}/build/dist" includes="${dir.name.repository}.jar" />
|
||||
|
@@ -18,13 +18,7 @@ package org.alfresco.web.bean.wcm;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.*;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.event.ActionEvent;
|
||||
import javax.faces.event.ValueChangeEvent;
|
||||
@@ -76,6 +70,7 @@ public class CreateFormWizard
|
||||
* Simple wrapper class to represent a form data renderer
|
||||
*/
|
||||
public class RenderingEngineTemplateData
|
||||
implements Serializable
|
||||
{
|
||||
private final String fileName;
|
||||
private final File file;
|
||||
@@ -171,12 +166,13 @@ public class CreateFormWizard
|
||||
protected ContentService contentService;
|
||||
protected MimetypeService mimetypeService;
|
||||
protected WorkflowService workflowService;
|
||||
private DataModel renderingEngineTemplatesDataModel;
|
||||
private transient DataModel renderingEngineTemplatesDataModel;
|
||||
private List<RenderingEngineTemplateData> renderingEngineTemplates = null;
|
||||
private String outputPathPatternForFormInstanceData = null;
|
||||
private String outputPathPatternForRendition = null;
|
||||
private String mimetypeForRendition = null;
|
||||
private List<SelectItem> mimetypeChoices = null;
|
||||
private transient List<SelectItem> mimetypeChoices = null;
|
||||
private transient List<SelectItem> schemaRootElementNameChoices = null;
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Wizard implementation
|
||||
@@ -305,6 +301,7 @@ public class CreateFormWizard
|
||||
this.removeUploadedSchemaFile();
|
||||
this.removeUploadedRenderingEngineTemplateFile();
|
||||
this.schemaRootElementName = null;
|
||||
this.schemaRootElementNameChoices = null;
|
||||
this.formName = null;
|
||||
this.formTitle = null;
|
||||
this.formDescription = null;
|
||||
@@ -472,6 +469,7 @@ public class CreateFormWizard
|
||||
public String removeUploadedSchemaFile()
|
||||
{
|
||||
clearUpload(FILE_SCHEMA);
|
||||
this.schemaRootElementNameChoices = null;
|
||||
|
||||
// refresh the current page
|
||||
return null;
|
||||
@@ -488,7 +486,10 @@ public class CreateFormWizard
|
||||
return null;
|
||||
}
|
||||
|
||||
public String validateSchema()
|
||||
/**
|
||||
* Action handler called when the schema has been uploaded.
|
||||
*/
|
||||
public String schemaFileValueChanged(final ValueChangeEvent vce)
|
||||
{
|
||||
if (this.getSchemaFile() != null)
|
||||
{
|
||||
@@ -692,9 +693,13 @@ public class CreateFormWizard
|
||||
*/
|
||||
public List<SelectItem> getSchemaRootElementNameChoices()
|
||||
{
|
||||
final List<SelectItem> result = new LinkedList<SelectItem>();
|
||||
if (this.getSchemaFile() != null)
|
||||
if (this.getSchemaFile() == null)
|
||||
{
|
||||
return Collections.EMPTY_LIST;
|
||||
}
|
||||
if (this.schemaRootElementNameChoices == null)
|
||||
{
|
||||
this.schemaRootElementNameChoices = new LinkedList<SelectItem>();
|
||||
final FormsService ts = FormsService.getInstance();
|
||||
try
|
||||
{
|
||||
@@ -704,7 +709,7 @@ public class CreateFormWizard
|
||||
for (int i = 0; i < elementsMap.getLength(); i++)
|
||||
{
|
||||
final XSElementDeclaration e = (XSElementDeclaration)elementsMap.item(i);
|
||||
result.add(new SelectItem(e.getName(), e.getName()));
|
||||
this.schemaRootElementNameChoices.add(new SelectItem(e.getName(), e.getName()));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -714,7 +719,7 @@ public class CreateFormWizard
|
||||
Utils.addErrorMessage(msg, e);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return this.schemaRootElementNameChoices;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -722,7 +727,7 @@ public class CreateFormWizard
|
||||
*/
|
||||
public void setFormName(final String formName)
|
||||
{
|
||||
this.formName = formName;
|
||||
this.formName = formName != null && formName.length() != 0 ? formName : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -759,7 +764,7 @@ public class CreateFormWizard
|
||||
*/
|
||||
public void setFormTitle(final String formTitle)
|
||||
{
|
||||
this.formTitle = formTitle;
|
||||
this.formTitle = formTitle != null && formTitle.length() != 0 ? formTitle : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -80,7 +80,7 @@ public class CreateWebContentWizard extends BaseContentWizard
|
||||
|
||||
protected String content = null;
|
||||
protected String formName;
|
||||
protected List<SelectItem> createMimeTypes;
|
||||
protected transient List<SelectItem> createMimeTypes;
|
||||
protected String createdPath = null;
|
||||
protected List<Rendition> renditions = null;
|
||||
protected FormInstanceData formInstanceData = null;
|
||||
|
@@ -32,7 +32,6 @@ import org.alfresco.service.cmr.repository.NodeService;
|
||||
import org.alfresco.web.bean.wcm.AVMConstants;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.chiba.xml.util.DOMUtil;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Node;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -18,10 +18,14 @@ package org.alfresco.web.forms.xforms;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
import javax.faces.context.ExternalContext;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
|
||||
import javax.servlet.ServletContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.avm.AVMNodeConverter;
|
||||
import org.alfresco.repo.content.MimetypeMap;
|
||||
@@ -40,23 +44,29 @@ import org.alfresco.web.bean.wcm.AVMBrowseBean;
|
||||
import org.alfresco.web.bean.wcm.AVMConstants;
|
||||
import org.alfresco.web.forms.*;
|
||||
import org.alfresco.web.ui.common.Utils;
|
||||
|
||||
import org.apache.commons.fileupload.FileItem;
|
||||
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
|
||||
import org.apache.commons.fileupload.servlet.ServletFileUpload;
|
||||
import org.apache.commons.fileupload.servlet.ServletRequestContext;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.chiba.xml.events.ChibaEventNames;
|
||||
import org.chiba.xml.events.DOMEventNames;
|
||||
import org.chiba.xml.events.XFormsEventNames;
|
||||
import org.chiba.xml.events.XMLEvent;
|
||||
import org.chiba.xml.xforms.ChibaBean;
|
||||
import org.chiba.xml.xforms.Instance;
|
||||
import org.chiba.xml.xforms.XFormsElement;
|
||||
import org.chiba.xml.xforms.connector.http.AbstractHTTPConnector;
|
||||
import org.chiba.xml.xforms.core.Instance;
|
||||
import org.chiba.xml.xforms.core.ModelItem;
|
||||
import org.chiba.xml.xforms.events.XFormsEvent;
|
||||
import org.chiba.xml.xforms.events.XFormsEventFactory;
|
||||
import org.chiba.xml.xforms.exception.XFormsException;
|
||||
import org.chiba.xml.xforms.ui.BoundElement;
|
||||
import org.chiba.xml.xforms.ui.Upload;
|
||||
import org.chiba.xml.ns.NamespaceConstants;
|
||||
import org.springframework.util.FileCopyUtils;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
|
||||
import org.w3c.dom.events.Event;
|
||||
@@ -85,7 +95,7 @@ public class XFormsBean
|
||||
private ChibaBean chibaBean;
|
||||
private final SchemaFormBuilder schemaFormBuilder;
|
||||
private final HashMap<String, NodeRef> uploads = new HashMap<String, NodeRef>();
|
||||
private final List<XFormsEvent> eventLog = new LinkedList<XFormsEvent>();
|
||||
private final List<XMLEvent> eventLog = new LinkedList<XMLEvent>();
|
||||
|
||||
public XFormsSession(final Document formInstanceData,
|
||||
final Form form,
|
||||
@@ -95,7 +105,7 @@ public class XFormsBean
|
||||
this.form = form;
|
||||
this.schemaFormBuilder =
|
||||
new SchemaFormBuilder("/ajax/invoke/XFormsBean.handleAction",
|
||||
SchemaFormBuilder.SUBMIT_METHOD_POST,
|
||||
SchemaFormBuilder.SubmitMethod.POST,
|
||||
new XHTMLWrapperElementsBuilder(),
|
||||
baseUrl);
|
||||
}
|
||||
@@ -177,7 +187,8 @@ public class XFormsBean
|
||||
|
||||
/** @param xformsSession the current session */
|
||||
public void setXFormsSession(final XFormsSession xformsSession)
|
||||
throws XFormsException
|
||||
throws FormBuilderException,
|
||||
XFormsException
|
||||
{
|
||||
this.xformsSession = xformsSession;
|
||||
|
||||
@@ -185,41 +196,13 @@ public class XFormsBean
|
||||
final ExternalContext externalContext = facesContext.getExternalContext();
|
||||
final HttpServletRequest request = (HttpServletRequest)
|
||||
externalContext.getRequest();
|
||||
final ServletContext servletContext = (ServletContext)
|
||||
externalContext.getContext();
|
||||
|
||||
final ChibaBean chibaBean = new ChibaBean();
|
||||
chibaBean.setConfig(servletContext.getRealPath("/WEB-INF/chiba.xml"));
|
||||
XFormsBean.storeCookies(request.getCookies(), chibaBean);
|
||||
|
||||
final String cwdAVMPath = this.avmBrowseBean.getCurrentPath();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("building xform for schema " + this.xformsSession.form.getName() +
|
||||
" root element " + this.xformsSession.form.getSchemaRootElementName() +
|
||||
" avm cwd " + cwdAVMPath);
|
||||
}
|
||||
|
||||
final Locale locale = Application.getLanguage(facesContext);
|
||||
final ResourceBundle resourceBundle =
|
||||
this.schema2XFormsProperties.getResourceBundle(this.xformsSession.form,
|
||||
locale);
|
||||
|
||||
try
|
||||
{
|
||||
final Document schemaDocument = this.xformsSession.form.getSchema();
|
||||
XFormsBean.rewriteInlineURIs(schemaDocument, cwdAVMPath);
|
||||
final Document xformsDocument =
|
||||
this.xformsSession.schemaFormBuilder.buildXForm(this.xformsSession.formInstanceData,
|
||||
schemaDocument,
|
||||
this.xformsSession.form.getSchemaRootElementName(),
|
||||
resourceBundle);
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("generated xform: " +
|
||||
FormsService.getInstance().writeXMLToString(xformsDocument));
|
||||
}
|
||||
|
||||
chibaBean.setXMLContainer(xformsDocument);
|
||||
chibaBean.setXMLContainer(this.getXFormsDocument());
|
||||
|
||||
final EventTarget et = (EventTarget)
|
||||
chibaBean.getXMLContainer().getDocumentElement();
|
||||
@@ -228,44 +211,32 @@ public class XFormsBean
|
||||
public void handleEvent(final Event e)
|
||||
{
|
||||
XFormsBean.LOGGER.debug("received event " + e);
|
||||
XFormsBean.this.xformsSession.eventLog.add((XFormsEvent)e);
|
||||
XFormsBean.this.xformsSession.eventLog.add((XMLEvent)e);
|
||||
}
|
||||
};
|
||||
// interaction events my occur during init so we have to register before
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_LOAD_URI, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_RENDER_MESSAGE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_REPLACE_ALL, el, true);
|
||||
et.addEventListener(ChibaEventNames.LOAD_URI, el, true);
|
||||
et.addEventListener(ChibaEventNames.RENDER_MESSAGE, el, true);
|
||||
et.addEventListener(ChibaEventNames.REPLACE_ALL, el, true);
|
||||
|
||||
chibaBean.init();
|
||||
|
||||
// register for notification events
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_DONE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_ERROR, el, true);
|
||||
et.addEventListener(XFormsEventFactory.REQUIRED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.OPTIONAL, el, true);
|
||||
et.addEventListener(XFormsEventFactory.VALID, el, true);
|
||||
et.addEventListener(XFormsEventFactory.INVALID, el, true);
|
||||
et.addEventListener(XFormsEventFactory.OUT_OF_RANGE, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_STATE_CHANGED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_PROTOTYPE_CLONED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ID_GENERATED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ITEM_INSERTED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_ITEM_DELETED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_INDEX_CHANGED, el, true);
|
||||
et.addEventListener(XFormsEventFactory.CHIBA_SWITCH_TOGGLED, el, true);
|
||||
}
|
||||
catch (FormBuilderException fbe)
|
||||
{
|
||||
LOGGER.error(fbe);
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
LOGGER.error(ioe);
|
||||
}
|
||||
catch (SAXException saxe)
|
||||
{
|
||||
LOGGER.error(saxe);
|
||||
}
|
||||
et.addEventListener(XFormsEventNames.SUBMIT, el, true);
|
||||
et.addEventListener(XFormsEventNames.SUBMIT_DONE, el, true);
|
||||
et.addEventListener(XFormsEventNames.SUBMIT_ERROR, el, true);
|
||||
et.addEventListener(XFormsEventNames.REQUIRED, el, true);
|
||||
et.addEventListener(XFormsEventNames.OPTIONAL, el, true);
|
||||
et.addEventListener(XFormsEventNames.VALID, el, true);
|
||||
et.addEventListener(XFormsEventNames.INVALID, el, true);
|
||||
et.addEventListener(XFormsEventNames.OUT_OF_RANGE, el, true);
|
||||
et.addEventListener(ChibaEventNames.STATE_CHANGED, el, true);
|
||||
et.addEventListener(ChibaEventNames.PROTOTYPE_CLONED, el, true);
|
||||
et.addEventListener(ChibaEventNames.ID_GENERATED, el, true);
|
||||
et.addEventListener(ChibaEventNames.ITEM_INSERTED, el, true);
|
||||
et.addEventListener(ChibaEventNames.ITEM_DELETED, el, true);
|
||||
et.addEventListener(ChibaEventNames.INDEX_CHANGED, el, true);
|
||||
et.addEventListener(ChibaEventNames.SWITCH_TOGGLED, el, true);
|
||||
this.xformsSession.chibaBean = chibaBean;
|
||||
}
|
||||
|
||||
@@ -275,7 +246,6 @@ public class XFormsBean
|
||||
*/
|
||||
public static XFormsSession createSession(final Document formInstanceData,
|
||||
final Form form)
|
||||
throws XFormsException
|
||||
{
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
@@ -328,7 +298,7 @@ public class XFormsBean
|
||||
|
||||
LOGGER.debug(this + ".setXFormsValue(" + id + ", " + value + ")");
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
if (chibaBean.lookup(id) instanceof Upload)
|
||||
if (chibaBean.getContainer().lookup(id) instanceof Upload)
|
||||
{
|
||||
chibaBean.updateControlValue(id, null, value, value.getBytes());
|
||||
}
|
||||
@@ -380,7 +350,7 @@ public class XFormsBean
|
||||
|
||||
LOGGER.debug(this + ".fireAction(" + id + ")");
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
chibaBean.dispatch(id, XFormsEventFactory.DOM_ACTIVATE);
|
||||
chibaBean.dispatch(id, DOMEventNames.ACTIVATE);
|
||||
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
FormsService.getInstance().writeXML(this.getEventLog(), out);
|
||||
@@ -435,8 +405,8 @@ public class XFormsBean
|
||||
final String toItemId = (String)requestParameters.get("toItemId");
|
||||
LOGGER.debug(this + ".swapRepeatItems(" + fromItemId + ", " + toItemId + ")");
|
||||
final ChibaBean chibaBean = this.xformsSession.chibaBean;
|
||||
this.swapRepeatItems(chibaBean.lookup(fromItemId),
|
||||
chibaBean.lookup(toItemId));
|
||||
this.swapRepeatItems(chibaBean.getContainer().lookup(fromItemId),
|
||||
chibaBean.getContainer().lookup(toItemId));
|
||||
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
FormsService.getInstance().writeXML(this.getEventLog(), out);
|
||||
@@ -648,7 +618,7 @@ public class XFormsBean
|
||||
final String cwdAvmPath)
|
||||
{
|
||||
final NodeList includes =
|
||||
schemaDocument.getElementsByTagNameNS(SchemaFormBuilder.XMLSCHEMA_NS, "include");
|
||||
schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "include");
|
||||
LOGGER.debug("rewriting " + includes.getLength() + " includes");
|
||||
for (int i = 0; i < includes.getLength(); i++)
|
||||
{
|
||||
@@ -672,7 +642,7 @@ public class XFormsBean
|
||||
final Document result = formsService.newDocument();
|
||||
final Element eventsElement = result.createElement("events");
|
||||
result.appendChild(eventsElement);
|
||||
for (XFormsEvent xfe : this.xformsSession.eventLog)
|
||||
for (XMLEvent xfe : this.xformsSession.eventLog)
|
||||
{
|
||||
final String type = xfe.getType();
|
||||
if (LOGGER.isDebugEnabled())
|
||||
@@ -740,4 +710,48 @@ public class XFormsBean
|
||||
commonsCookies);
|
||||
}
|
||||
}
|
||||
|
||||
private Document getXFormsDocument()
|
||||
throws FormBuilderException
|
||||
{
|
||||
final String cwdAVMPath = this.avmBrowseBean.getCurrentPath();
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("building xform for schema " + this.xformsSession.form.getName() +
|
||||
" root element " + this.xformsSession.form.getSchemaRootElementName() +
|
||||
" avm cwd " + cwdAVMPath);
|
||||
}
|
||||
|
||||
final Locale locale =
|
||||
Application.getLanguage(FacesContext.getCurrentInstance());
|
||||
final ResourceBundle resourceBundle =
|
||||
this.schema2XFormsProperties.getResourceBundle(this.xformsSession.form,
|
||||
locale);
|
||||
try
|
||||
{
|
||||
final Document schemaDocument = this.xformsSession.form.getSchema();
|
||||
XFormsBean.rewriteInlineURIs(schemaDocument, cwdAVMPath);
|
||||
final String rootElementName = this.xformsSession.form.getSchemaRootElementName();
|
||||
final Document result =
|
||||
this.xformsSession.schemaFormBuilder.buildXForm(this.xformsSession.formInstanceData,
|
||||
schemaDocument,
|
||||
rootElementName,
|
||||
resourceBundle);
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("generated xform: " +
|
||||
FormsService.getInstance().writeXMLToString(result));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{
|
||||
throw new FormBuilderException(ioe);
|
||||
}
|
||||
catch (SAXException saxe)
|
||||
{
|
||||
throw new FormBuilderException(saxe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -19,10 +19,8 @@ package org.alfresco.web.forms.xforms;
|
||||
import java.io.*;
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.ServletContext;
|
||||
|
||||
import org.alfresco.web.forms.*;
|
||||
import org.chiba.xml.util.DOMUtil;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -46,20 +44,12 @@ public class XFormsProcessor
|
||||
final Form form,
|
||||
final Writer out)
|
||||
throws FormProcessor.ProcessingException
|
||||
{
|
||||
try
|
||||
{
|
||||
final Session result =
|
||||
XFormsBean.createSession(instanceDataDocument, form);
|
||||
this.process(result, out);
|
||||
return result;
|
||||
}
|
||||
catch (XFormsException xfe)
|
||||
{
|
||||
LOGGER.error(xfe);
|
||||
throw new FormProcessor.ProcessingException(xfe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates html text which bootstraps the JavaScript code that will
|
||||
@@ -77,6 +67,11 @@ public class XFormsProcessor
|
||||
{
|
||||
xforms.setXFormsSession((XFormsBean.XFormsSession)session);
|
||||
}
|
||||
catch (FormBuilderException fbe)
|
||||
{
|
||||
LOGGER.error(fbe);
|
||||
throw new ProcessingException(fbe);
|
||||
}
|
||||
catch (XFormsException xfe)
|
||||
{
|
||||
LOGGER.error(xfe);
|
||||
|
@@ -19,7 +19,7 @@ package org.alfresco.web.forms.xforms;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
import org.w3c.dom.Text;
|
||||
|
||||
import org.chiba.xml.ns.NamespaceConstants;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -70,10 +70,6 @@ public class XHTMLWrapperElementsBuilder
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
private final static String XHTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
private final static String XHTML_PREFIX = "xhtml";
|
||||
|
||||
|
||||
private String title;
|
||||
private final Collection<Link> links = new LinkedList<Link>();
|
||||
private final Collection<Meta> meta = new LinkedList<Meta>();
|
||||
@@ -147,18 +143,19 @@ public class XHTMLWrapperElementsBuilder
|
||||
*/
|
||||
public Element createEnvelope(Document doc)
|
||||
{
|
||||
Element html = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":html");
|
||||
final Element html = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":html");
|
||||
//set namespace attribute
|
||||
html.setAttributeNS(SchemaFormBuilder.XMLNS_NAMESPACE_URI,
|
||||
"xmlns:" + XHTML_PREFIX,
|
||||
XHTMLWrapperElementsBuilder.XHTML_NS);
|
||||
html.setAttributeNS(NamespaceConstants.XMLNS_NS,
|
||||
NamespaceConstants.XMLNS_PREFIX + ':' + NamespaceConstants.XHTML_PREFIX,
|
||||
NamespaceConstants.XHTML_NS);
|
||||
doc.appendChild(html);
|
||||
|
||||
//other namespaces
|
||||
for (String prefix : this.namespaces.keySet())
|
||||
{
|
||||
html.setAttributeNS(SchemaFormBuilder.XMLNS_NAMESPACE_URI,
|
||||
"xmlns:" + prefix,
|
||||
html.setAttributeNS(NamespaceConstants.XMLNS_NS,
|
||||
NamespaceConstants.XMLNS_PREFIX + ":" + prefix,
|
||||
this.namespaces.get(prefix));
|
||||
|
||||
}
|
||||
@@ -185,7 +182,7 @@ public class XHTMLWrapperElementsBuilder
|
||||
public Element createFormWrapper(Element enveloppeElement)
|
||||
{
|
||||
Document doc = enveloppeElement.getOwnerDocument();
|
||||
Element body = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":body");
|
||||
Element body = doc.createElementNS(NamespaceConstants.XHTML_NS, NamespaceConstants.XHTML_PREFIX + ":body");
|
||||
//body.appendChild(formElement);
|
||||
enveloppeElement.appendChild(body);
|
||||
return body;
|
||||
@@ -197,54 +194,81 @@ public class XHTMLWrapperElementsBuilder
|
||||
* @param modelElement the xforms:model element
|
||||
* @return the wrapper element, already containing the model
|
||||
*/
|
||||
public Element createModelWrapper(Element modelElement)
|
||||
public Element createModelWrapper(final Element modelElement)
|
||||
{
|
||||
Document doc = modelElement.getOwnerDocument();
|
||||
Element head = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":head");
|
||||
Element head = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":head");
|
||||
head.appendChild(modelElement);
|
||||
|
||||
//eventually add other info
|
||||
if (title != null && title.length() != 0)
|
||||
{
|
||||
Element title_el = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":title");
|
||||
Text title_text = doc.createTextNode(title);
|
||||
title_el.appendChild(title_text);
|
||||
final Element title_el = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":title");
|
||||
title_el.appendChild(doc.createTextNode(title));
|
||||
head.appendChild(title_el);
|
||||
}
|
||||
|
||||
for (Meta m : this.meta)
|
||||
{
|
||||
Element meta_el = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":META");
|
||||
final Element meta_el = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":META");
|
||||
head.appendChild(meta_el);
|
||||
|
||||
//attributes
|
||||
if (m.httpEquiv != null && m.httpEquiv.length() != 0)
|
||||
meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":http-equiv",
|
||||
{
|
||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":http-equiv",
|
||||
m.httpEquiv);
|
||||
}
|
||||
if (m.name != null && m.name.length() != 0)
|
||||
meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":name", m.name);
|
||||
|
||||
{
|
||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":name",
|
||||
m.name);
|
||||
}
|
||||
if (m.content != null && m.content.length() != 0)
|
||||
meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":content", m.content);
|
||||
|
||||
{
|
||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":content",
|
||||
m.content);
|
||||
}
|
||||
if (m.scheme != null && m.scheme.length() != 0)
|
||||
meta_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":scheme", m.scheme);
|
||||
{
|
||||
meta_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":scheme",
|
||||
m.scheme);
|
||||
}
|
||||
}
|
||||
|
||||
for (Link l : this.links)
|
||||
{
|
||||
Element link_el = doc.createElementNS(XHTML_NS, XHTML_PREFIX + ":LINK");
|
||||
final Element link_el = doc.createElementNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":LINK");
|
||||
head.appendChild(link_el);
|
||||
|
||||
//attributes
|
||||
if (l.href != null && l.href.length() != 0)
|
||||
link_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":href", l.href);
|
||||
|
||||
{
|
||||
link_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":href",
|
||||
l.href);
|
||||
}
|
||||
if (l.type != null && l.type.length() != 0)
|
||||
link_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":type", l.type);
|
||||
|
||||
{
|
||||
link_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":type",
|
||||
l.type);
|
||||
}
|
||||
if (l.rel != null && l.rel.length() != 0)
|
||||
link_el.setAttributeNS(XHTML_NS, XHTML_PREFIX + ":rel", l.rel);
|
||||
{
|
||||
link_el.setAttributeNS(NamespaceConstants.XHTML_NS,
|
||||
NamespaceConstants.XHTML_PREFIX + ":rel",
|
||||
l.rel);
|
||||
|
||||
}
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
@@ -109,9 +109,10 @@ public class UIFormProcessor extends SelfRenderingComponent
|
||||
out));
|
||||
}
|
||||
}
|
||||
catch (FormProcessor.ProcessingException fppe)
|
||||
catch (Throwable t)
|
||||
{
|
||||
Utils.addErrorMessage(fppe.getMessage(), fppe);
|
||||
Utils.addErrorMessage(t.getMessage(), t);
|
||||
out.write(t.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,71 +1,15 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!-- $Id: default.xml,v 1.2 2005/12/15 09:27:01 unl Exp $ -->
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- $Id: default.xml,v 1.40 2006/08/02 20:37:26 unl Exp $ -->
|
||||
<!-- Copyright 2005 Chibacon -->
|
||||
<chiba-config>
|
||||
<!-- PLEASE COMMENT YOUR ENTRIES -->
|
||||
<properties>
|
||||
<!--
|
||||
Language is not a config-property any more as soon as
|
||||
Chiba starts to support user-agents. Language may vary from
|
||||
instance to instance or even from request to request
|
||||
-->
|
||||
<property name="language" value="de"/>
|
||||
|
||||
<!--
|
||||
This property allows to switch the stylesheet compilation on.
|
||||
Because of the significant performance gain this option is turned on by default.
|
||||
|
||||
Note: If you extend stylesheets and use custom xpath extensions, compilation can become
|
||||
a problem cause XSLTC has limitations in this area.
|
||||
-->
|
||||
<property name="chiba.stylesheets.compiled" value="true"/>
|
||||
|
||||
<!-- ********* web adapter properties ********* -->
|
||||
<!--
|
||||
Normally there should be no reason to change the following prefixes unless they're
|
||||
in conflict with your application that uses Chiba.
|
||||
-->
|
||||
<!-- prefix used in http request param names to denote a data (value) parameter. -->
|
||||
<property name="chiba.web.dataPrefix" value="d_"/>
|
||||
<!-- prefix used in http request param names to denote the id of an action to be fired. -->
|
||||
<property name="chiba.web.triggerPrefix" value="t_"/>
|
||||
<!-- prefix used in http request param names to denote a selector parameter (used for repeats). -->
|
||||
<property name="chiba.web.selectorPrefix" value="s_"/>
|
||||
|
||||
<!-- ********* ui handler properties ********* -->
|
||||
<!--
|
||||
This option allows to steer the processor behaviour regarding the initialization of
|
||||
<case> elements which are not visible currently (unselected). If setting this option
|
||||
to false, only the current <case> will be initialized.
|
||||
|
||||
The default is to initialize all <case> elements.
|
||||
-->
|
||||
<property name="chiba.ui.initializeDeselectedCases" value="true"/>
|
||||
|
||||
<!-- generate default alert Elements for UI controls. default is false -->
|
||||
<!-- generate default alert elements if none present. -->
|
||||
<property name="chiba.ui.generateDefaultAlerts" value="false"/>
|
||||
|
||||
<!--
|
||||
allows the define the default error-message for automatically generated alert elements.
|
||||
-->
|
||||
<!-- define the default text for automatically generated alert elements. -->
|
||||
<property name="chiba.ui.defaultAlertText" value="The specified value is invalid"/>
|
||||
</properties>
|
||||
|
||||
<error-messages>
|
||||
<message id="session-invalid" value="Invalid session - You probably used the back button to visit an already finished form."/>
|
||||
</error-messages>
|
||||
|
||||
<stylesheets>
|
||||
<!--
|
||||
Maps internal names to external file-names.
|
||||
The internal name is used by the framework to identify
|
||||
entities and resolve these to the associated filenames.
|
||||
-->
|
||||
|
||||
<!-- Standard stylesheet used for simple HTML 3.2 compatible Browsers without Javascript support -->
|
||||
<stylesheet name="html-default" value="html4.xsl"/>
|
||||
</stylesheets>
|
||||
|
||||
<connectors>
|
||||
<!--
|
||||
For each of the connector types you can specifiy one connector to handle one URI scheme.
|
||||
@@ -75,36 +19,25 @@
|
||||
<uri-resolver scheme="class" class="org.chiba.util.ClassResourceLoader"/>
|
||||
<uri-resolver scheme="xmlrpc" class="org.chiba.connectors.xmlrpc.XMLRPCURIResolver"/>
|
||||
<uri-resolver scheme="context" class="org.chiba.xml.xforms.connector.context.ContextResolver"/>
|
||||
<uri-resolver scheme="contextobject" class="org.chiba.xml.xforms.connector.context.ContextObjectResolver"/>
|
||||
|
||||
<submission-handler scheme="context" class="org.chiba.xml.xforms.connector.context.ContextSubmissionHandler"/>
|
||||
<submission-handler scheme="file" class="org.chiba.xml.xforms.connector.file.FileSubmissionHandler"/>
|
||||
<submission-handler scheme="http" class="org.chiba.xml.xforms.connector.http.HTTPSubmissionHandler"/>
|
||||
<submission-handler scheme="mailto" class="org.chiba.connectors.smtp.SMTPSubmissionHandler"/>
|
||||
<submission-handler scheme="xmlrpc" class="org.chiba.connectors.xmlrpc.XMLRPCSubmissionHandler"/>
|
||||
<!-- <submission-handler scheme="jms" class="org.chiba.connectors.jms.JMSSubmissionHandler"/>-->
|
||||
<!--
|
||||
These connector types are deprecated. Their usage is strongly discouraged,
|
||||
since they may disappear without notice. Use custom extension functions instead.
|
||||
-->
|
||||
<!-- <modelitem-calculator scheme="http" class="org.chiba.xml.xforms.connector.http.HTTPModelItemCalculator"/>-->
|
||||
<!-- <modelitem-validator scheme="http" class="org.chiba.xml.xforms.connector.http.HTTPModelItemValidator"/>-->
|
||||
<submission-handler scheme="echo" class="org.chiba.xml.xforms.connector.echo.EchoSubmissionHandler"/>
|
||||
</connectors>
|
||||
<extension-functions>
|
||||
<!--
|
||||
Specifies external functions to be used in the XForms' XPath expressions. If the 'java-name' attribute
|
||||
is ommitted, the Java function name is considered to be the same as that of the XPath function.
|
||||
-->
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="declare" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="undeclare" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="context" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions" />
|
||||
|
||||
<!--<function namespace="http://exslt.org/regular-expressions" prefix="regexp" name="test" class="org.galasoft.util.xml.servlet.xforms.exslt.Regexp" java-name="test"/>-->
|
||||
<function namespace="http://exslt.org/regular-expressions" name="test" class="org.galasoft.util.xml.servlet.xforms.exslt.Regexp" java-name="test"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="formatDateString" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="fileDate" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="fileSize" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="match" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="validate" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
<function namespace="http://chiba.sourceforge.net/xforms" name="calculate" class="org.chiba.xml.xforms.xpath.ChibaExtensionFunctions"/>
|
||||
</extension-functions>
|
||||
|
||||
<custom-elements>
|
||||
|
@@ -34,7 +34,10 @@
|
||||
|
||||
function pageLoaded()
|
||||
{
|
||||
document.getElementById("wizard:wizard-body:file-input").focus();
|
||||
if (document.getElementById("wizard:wizard-body:file-input"))
|
||||
document.getElementById("wizard:wizard-body:file-input").focus()
|
||||
else
|
||||
document.getElementById("wizard:wizard-body:form-name").focus();
|
||||
document.getElementById("wizard").onsubmit = validate;
|
||||
document.getElementById("wizard:next-button").onclick = function() {finishButtonPressed = true; clear_wizard();}
|
||||
document.getElementById("wizard:finish-button").onclick = function() {finishButtonPressed = true; clear_wizard();}
|
||||
@@ -42,7 +45,14 @@
|
||||
|
||||
function validate()
|
||||
{
|
||||
if (!finishButtonPressed)
|
||||
return true;
|
||||
finishButtonPressed = false;
|
||||
var formName = document.getElementById("wizard:wizard-body:form-name");
|
||||
return validateMandatory(formName) &&
|
||||
validateName(formName,
|
||||
'</f:verbatim><a:outputText value="#{msg.validation_invalid_character}" /><f:verbatim>',
|
||||
true)
|
||||
}
|
||||
|
||||
function handle_upload(target)
|
||||
@@ -55,9 +65,10 @@
|
||||
|
||||
function upload_complete(id, path)
|
||||
{
|
||||
var validate_button =
|
||||
document.getElementById("wizard:wizard-body:command_button_validate_schema");
|
||||
validate_button.click();
|
||||
var schema_file_input =
|
||||
document.getElementById("wizard:wizard-body:schema-file");
|
||||
schema_file_input.value = path;
|
||||
schema_file_input.form.submit();
|
||||
}
|
||||
</script>
|
||||
</f:verbatim>
|
||||
@@ -96,12 +107,11 @@ if (upload == null || upload.getFile() == null)
|
||||
name="alfFileInput"
|
||||
onchange="javascript:handle_upload(this)"/>
|
||||
</f:verbatim>
|
||||
<h:commandButton id="command_button_validate_schema"
|
||||
value=""
|
||||
immediate="true"
|
||||
<h:inputText id="schema-file"
|
||||
value="#{WizardManager.bean.schemaFileName}"
|
||||
rendered="#{empty WizardManager.bean.schemaFileName}"
|
||||
style="display: none"
|
||||
action="#{WizardManager.bean.validateSchema}"/>
|
||||
|
||||
valueChangeListener="#{WizardManager.bean.schemaFileValueChanged}"/>
|
||||
<%
|
||||
} else {
|
||||
%>
|
||||
@@ -146,21 +156,21 @@ if (upload == null || upload.getFile() == null)
|
||||
value="/images/icons/required_field.gif"
|
||||
alt="Required Field" />
|
||||
<h:outputText id="output_text_name" value="#{msg.name}:"/>
|
||||
<h:inputText id="file-name"
|
||||
<h:inputText id="form-name"
|
||||
value="#{WizardManager.bean.formName}"
|
||||
maxlength="1024"
|
||||
size="35"/>
|
||||
|
||||
<h:outputText id="no_graphic_image_title" value=""/>
|
||||
<h:outputText id="output_text_title" value="#{msg.title}:"/>
|
||||
<h:inputText id="title"
|
||||
<h:inputText id="form-title"
|
||||
value="#{WizardManager.bean.formTitle}"
|
||||
maxlength="1024"
|
||||
size="35"/>
|
||||
|
||||
<h:outputText id="no_graphic_image_description" value=""/>
|
||||
<h:outputText id="output_text_description" value="#{msg.description}:"/>
|
||||
<h:inputText id="description"
|
||||
<h:inputText id="form-description"
|
||||
value="#{WizardManager.bean.formDescription}"
|
||||
maxlength="1024"
|
||||
style="width:100%"/>
|
||||
|
@@ -5,7 +5,7 @@ dojo.require("dojo.lfx.html");
|
||||
dojo.hostenv.writeIncludes();
|
||||
|
||||
var XFORMS_NS = "http://www.w3.org/2002/xforms";
|
||||
var XFORMS_NS_PREFIX = "xforms";
|
||||
var XFORMS_PREFIX = "xf";
|
||||
var XHTML_NS = "http://www.w3.org/1999/xhtml";
|
||||
var XHTML_NS_PREFIX = "xhtml";
|
||||
var CHIBA_NS = "http://chiba.sourceforge.net/xforms";
|
||||
@@ -134,20 +134,11 @@ dojo.declare("alfresco.xforms.Widget",
|
||||
{
|
||||
if (typeof this.initialValue != "undefined")
|
||||
return this.initialValue;
|
||||
var chibaData = _getElementsByTagNameNS(this.xformsNode,
|
||||
CHIBA_NS,
|
||||
CHIBA_NS_PREFIX,
|
||||
"data");
|
||||
if (chibaData.length == 0)
|
||||
return null;
|
||||
|
||||
chibaData = chibaData[chibaData.length - 1];
|
||||
var xpath = chibaData.getAttribute(CHIBA_NS_PREFIX + ":xpath");
|
||||
var xpath = this._getXPathInInstanceDocument();
|
||||
var d = this.xformsNode.ownerDocument;
|
||||
var contextNode = this.xform.getInstance();
|
||||
dojo.debug("locating " + xpath +
|
||||
" from " + chibaData.nodeName +
|
||||
" in " + contextNode.nodeName);
|
||||
dojo.debug("locating " + xpath + " in " + contextNode.nodeName);
|
||||
var result = _evaluateXPath("/" + xpath,
|
||||
this.xform.getInstance(),
|
||||
XPathResult.FIRST_ORDERED_NODE_TYPE);
|
||||
@@ -159,9 +150,29 @@ dojo.declare("alfresco.xforms.Widget",
|
||||
dojo.debug("resolved xpath " + xpath + " to " + result);
|
||||
return result;
|
||||
},
|
||||
_getXPathInInstanceDocument: function()
|
||||
{
|
||||
var binding = this.xform.getBinding(this.xformsNode);
|
||||
var xpath = '';
|
||||
do
|
||||
{
|
||||
var s = binding.nodeset;
|
||||
if (binding.nodeset == '.')
|
||||
{
|
||||
binding = binding.parent;
|
||||
var repeatIndices = this.getRepeatIndices();
|
||||
s = binding.nodeset.replace(/([^\[]+)\[.*/, "$1");
|
||||
s += '[' + (repeatIndices.pop().index + 1) + ']';
|
||||
}
|
||||
xpath = s + (xpath.length != 0 ? '/' + xpath : "");
|
||||
binding = binding.parent;
|
||||
}
|
||||
while (binding);
|
||||
return xpath;
|
||||
},
|
||||
_getLabelNode: function()
|
||||
{
|
||||
var labels = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_NS_PREFIX, "label");
|
||||
var labels = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_PREFIX, "label");
|
||||
for (var i = 0; i < labels.length; i++)
|
||||
{
|
||||
if (labels[i].parentNode == this.xformsNode)
|
||||
@@ -171,7 +182,7 @@ dojo.declare("alfresco.xforms.Widget",
|
||||
},
|
||||
_getAlertNode: function()
|
||||
{
|
||||
var labels = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_NS_PREFIX, "alert");
|
||||
var labels = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_PREFIX, "alert");
|
||||
for (var i = 0; i < labels.length; i++)
|
||||
{
|
||||
if (labels[i].parentNode == this.xformsNode)
|
||||
@@ -212,17 +223,27 @@ dojo.declare("alfresco.xforms.Widget",
|
||||
{
|
||||
dojo.debug("destroying " + this.id);
|
||||
},
|
||||
getParentRepeats: function()
|
||||
getRepeatIndices: function()
|
||||
{
|
||||
var result = [];
|
||||
var p = this.parent;
|
||||
while (p)
|
||||
function RepeatIndexData(repeat, index)
|
||||
{
|
||||
if (p instanceof alfresco.xforms.Repeat)
|
||||
this.repeat = repeat;
|
||||
this.index = index;
|
||||
this.toString = function()
|
||||
{
|
||||
result.push(p);
|
||||
return "{" + this.repeat.id + " = " + this.index + "}";
|
||||
};
|
||||
}
|
||||
p = p.parent;
|
||||
var result = [];
|
||||
var w = this;
|
||||
while (w.parent)
|
||||
{
|
||||
if (w.parent instanceof alfresco.xforms.Repeat)
|
||||
{
|
||||
result.push(new RepeatIndexData(w.parent,
|
||||
w.parent.getChildIndex(w)));
|
||||
}
|
||||
w = w.parent;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -449,12 +470,12 @@ dojo.declare("alfresco.xforms.AbstractSelectWidget",
|
||||
getValues: function()
|
||||
{
|
||||
var binding = this.xform.getBinding(this.xformsNode);
|
||||
var values = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_NS_PREFIX, "item");
|
||||
var values = _getElementsByTagNameNS(this.xformsNode, XFORMS_NS, XFORMS_PREFIX, "item");
|
||||
var result = [];
|
||||
for (var v = 0; v < values.length; v++)
|
||||
{
|
||||
var label = _getElementsByTagNameNS(values[v], XFORMS_NS, XFORMS_NS_PREFIX, "label")[0];
|
||||
var value = _getElementsByTagNameNS(values[v], XFORMS_NS, XFORMS_NS_PREFIX, "value")[0];
|
||||
var label = _getElementsByTagNameNS(values[v], XFORMS_NS, XFORMS_PREFIX, "label")[0];
|
||||
var value = _getElementsByTagNameNS(values[v], XFORMS_NS, XFORMS_PREFIX, "value")[0];
|
||||
var valid = true;
|
||||
if (binding.constraint)
|
||||
{
|
||||
@@ -1220,7 +1241,7 @@ dojo.declare("alfresco.xforms.Repeat",
|
||||
this.domNode = this.inherited("render", [ attach_point ]);
|
||||
this.domNode.style.border = "1px solid black";
|
||||
|
||||
var parentRepeats = this.getParentRepeats();
|
||||
var parentRepeats = this.getRepeatIndices();
|
||||
this.domNode.style.marginLeft = (parentRepeats.length * 10) + "px";
|
||||
this.domNode.style.marginRight = (parseInt(this.domNode.style.marginLeft) / 2) + "px";
|
||||
this.domNode.style.width = (this.domNode.offsetParent.offsetWidth -
|
||||
@@ -1344,8 +1365,8 @@ dojo.declare("alfresco.xforms.Trigger",
|
||||
var c = this.xformsNode.childNodes[i];
|
||||
if (c.nodeType != dojo.dom.ELEMENT_NODE)
|
||||
continue;
|
||||
if (c.nodeName == XFORMS_NS_PREFIX + ":label" ||
|
||||
c.nodeName == XFORMS_NS_PREFIX + ":alert")
|
||||
if (c.nodeName == XFORMS_PREFIX + ":label" ||
|
||||
c.nodeName == XFORMS_PREFIX + ":alert")
|
||||
continue;
|
||||
return new alfresco.xforms.XFormsAction(this.xform, c);
|
||||
}
|
||||
@@ -1413,16 +1434,16 @@ dojo.declare("alfresco.xforms.XFormsAction",
|
||||
for (var i = 0; i < this.xformsNode.attributes.length; i++)
|
||||
{
|
||||
var attr = this.xformsNode.attributes[i];
|
||||
if (attr.nodeName.match(/^xforms:/))
|
||||
if (attr.nodeName.match(new RegExp("^" + XFORMS_PREFIX + ":")))
|
||||
{
|
||||
this.properties[attr.nodeName.substring((XFORMS_NS_PREFIX + ":").length)] =
|
||||
this.properties[attr.nodeName.substring((XFORMS_PREFIX + ":").length)] =
|
||||
attr.nodeValue;
|
||||
}
|
||||
}
|
||||
},
|
||||
getType: function()
|
||||
{
|
||||
return this.xformsNode.nodeName.substring((XFORMS_NS_PREFIX + ":").length);
|
||||
return this.xformsNode.nodeName.substring((XFORMS_PREFIX + ":").length);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1490,15 +1511,15 @@ dojo.declare("alfresco.xforms.XForm",
|
||||
dojo.debug("creating node for " + node.nodeName.toLowerCase());
|
||||
switch (node.nodeName.toLowerCase())
|
||||
{
|
||||
case XFORMS_NS_PREFIX + ":group":
|
||||
case XFORMS_PREFIX + ":group":
|
||||
return new alfresco.xforms.Group(this, node);
|
||||
case XFORMS_NS_PREFIX + ":repeat":
|
||||
case XFORMS_PREFIX + ":repeat":
|
||||
return new alfresco.xforms.Repeat(this, node);
|
||||
case XFORMS_NS_PREFIX + ":textarea":
|
||||
case XFORMS_PREFIX + ":textarea":
|
||||
return new alfresco.xforms.TextArea(this, node);
|
||||
case XFORMS_NS_PREFIX + ":upload":
|
||||
case XFORMS_PREFIX + ":upload":
|
||||
return new alfresco.xforms.FilePicker(this, node);
|
||||
case XFORMS_NS_PREFIX + ":input":
|
||||
case XFORMS_PREFIX + ":input":
|
||||
var type = this.getType(node);
|
||||
switch (type)
|
||||
{
|
||||
@@ -1523,19 +1544,19 @@ dojo.declare("alfresco.xforms.XForm",
|
||||
default:
|
||||
return new alfresco.xforms.TextField(this, node);
|
||||
}
|
||||
case XFORMS_NS_PREFIX + ":select":
|
||||
case XFORMS_PREFIX + ":select":
|
||||
return new alfresco.xforms.Select(this, node);
|
||||
case XFORMS_NS_PREFIX + ":select1":
|
||||
case XFORMS_PREFIX + ":select1":
|
||||
return (this.getType(node) == "boolean"
|
||||
? new alfresco.xforms.Checkbox(this, node)
|
||||
: new alfresco.xforms.Select1(this, node));
|
||||
case XFORMS_NS_PREFIX + ":submit":
|
||||
case XFORMS_PREFIX + ":submit":
|
||||
return new alfresco.xforms.Submit(this, node);
|
||||
case XFORMS_NS_PREFIX + ":trigger":
|
||||
case XFORMS_PREFIX + ":trigger":
|
||||
return new alfresco.xforms.Trigger(this, node);
|
||||
case CHIBA_NS_PREFIX + ":data":
|
||||
case XFORMS_NS_PREFIX + ":label":
|
||||
case XFORMS_NS_PREFIX + ":alert":
|
||||
case XFORMS_PREFIX + ":label":
|
||||
case XFORMS_PREFIX + ":alert":
|
||||
dojo.debug("ignoring " + node.nodeName);
|
||||
return null;
|
||||
default:
|
||||
@@ -1571,7 +1592,7 @@ dojo.declare("alfresco.xforms.XForm",
|
||||
{
|
||||
return _getElementsByTagNameNS(this.xformsNode,
|
||||
XFORMS_NS,
|
||||
XFORMS_NS_PREFIX,
|
||||
XFORMS_PREFIX,
|
||||
"model")[0];
|
||||
},
|
||||
getInstance: function()
|
||||
@@ -1579,7 +1600,7 @@ dojo.declare("alfresco.xforms.XForm",
|
||||
var model = this.getModel();
|
||||
return _getElementsByTagNameNS(model,
|
||||
XFORMS_NS,
|
||||
XFORMS_NS_PREFIX,
|
||||
XFORMS_PREFIX,
|
||||
"instance")[0];
|
||||
},
|
||||
getBody: function()
|
||||
@@ -1596,7 +1617,7 @@ dojo.declare("alfresco.xforms.XForm",
|
||||
},
|
||||
getBinding: function(node)
|
||||
{
|
||||
return this._bindings[node.getAttribute(XFORMS_NS_PREFIX + ":bind")];
|
||||
return this._bindings[node.getAttribute(XFORMS_PREFIX + ":bind")];
|
||||
},
|
||||
getBindings: function()
|
||||
{
|
||||
@@ -1608,18 +1629,18 @@ dojo.declare("alfresco.xforms.XForm",
|
||||
dojo.debug("loading bindings for " + bind.nodeName);
|
||||
for (var i = 0; i < bind.childNodes.length; i++)
|
||||
{
|
||||
if (bind.childNodes[i].nodeName.toLowerCase() == XFORMS_NS_PREFIX + ":bind")
|
||||
if (bind.childNodes[i].nodeName.toLowerCase() == XFORMS_PREFIX + ":bind")
|
||||
{
|
||||
var id = bind.childNodes[i].getAttribute("id");
|
||||
dojo.debug("loading binding " + id);
|
||||
result[id] =
|
||||
{
|
||||
id: bind.childNodes[i].getAttribute("id"),
|
||||
readonly: bind.childNodes[i].getAttribute(XFORMS_NS_PREFIX + ":readonly"),
|
||||
required: bind.childNodes[i].getAttribute(XFORMS_NS_PREFIX + ":required"),
|
||||
nodeset: bind.childNodes[i].getAttribute(XFORMS_NS_PREFIX + ":nodeset"),
|
||||
type: bind.childNodes[i].getAttribute(XFORMS_NS_PREFIX + ":type"),
|
||||
constraint: bind.childNodes[i].getAttribute(XFORMS_NS_PREFIX + ":constraint"),
|
||||
readonly: bind.childNodes[i].getAttribute(XFORMS_PREFIX + ":readonly"),
|
||||
required: bind.childNodes[i].getAttribute(XFORMS_PREFIX + ":required"),
|
||||
nodeset: bind.childNodes[i].getAttribute(XFORMS_PREFIX + ":nodeset"),
|
||||
type: bind.childNodes[i].getAttribute(XFORMS_PREFIX + ":type"),
|
||||
constraint: bind.childNodes[i].getAttribute(XFORMS_PREFIX + ":constraint"),
|
||||
maximum: parseInt(bind.childNodes[i].getAttribute(ALFRESCO_NS_PREFIX + ":maximum")),
|
||||
minimum: parseInt(bind.childNodes[i].getAttribute(ALFRESCO_NS_PREFIX + ":minimum")),
|
||||
parent: parent,
|
||||
@@ -1728,8 +1749,8 @@ dojo.declare("alfresco.xforms.XForm",
|
||||
dojo.debug("cloning prototype " + originalId);
|
||||
var prototypeNode = _findElementById(this.xformsNode, originalId);
|
||||
clone = prototypeNode.cloneNode(true);
|
||||
var clone = prototypeNode.ownerDocument.createElement("xforms:group");
|
||||
clone.setAttribute("xforms:appearance", "repeated");
|
||||
var clone = prototypeNode.ownerDocument.createElement(XFORMS_PREFIX + ":group");
|
||||
clone.setAttribute(XFORMS_PREFIX + ":appearance", "repeated");
|
||||
for (var j = 0; j < prototypeNode.childNodes.length; j++)
|
||||
{
|
||||
clone.appendChild(prototypeNode.childNodes[j].cloneNode(true));
|
||||
|
Reference in New Issue
Block a user