mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +00:00
- preliminary support for callouts using xsd:include. rewriting links in the schema now to point at the virtualization server. not the best solution. but i couldn't get LSResourceResolver to work (would have been the elegant solution) since i don't have access to the DOMConfiguration object within chiba - works great in the schemaformbuilder.
- sample implementation of a callout in the alfresco sample website; using a jsp to produce an included xsd that lists all available company_footer.xmls - moving stuff around. XFormsbean is now in the xforms package rather than ajax package - more relevant to that codebase. - consolidating SchemaFormBuilder into one class since the inheritance hierarchy made very little sense. - refactored some of the sample website to reduce java code in the jsps and begining to think about a generic utility library for callouts and jsps that want to access templating generated data. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3957 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -67,7 +67,7 @@
|
|||||||
<from-email-address>alfresco@alfresco.org</from-email-address>
|
<from-email-address>alfresco@alfresco.org</from-email-address>
|
||||||
|
|
||||||
<!-- WCM domain and port for virtualisation server -->
|
<!-- WCM domain and port for virtualisation server -->
|
||||||
<wcm-domain>alfresco.dyndns.org</wcm-domain>
|
<wcm-domain>arielbackenroth.dyndns.org</wcm-domain>
|
||||||
<wcm-port>8180</wcm-port>
|
<wcm-port>8180</wcm-port>
|
||||||
</client>
|
</client>
|
||||||
</config>
|
</config>
|
||||||
|
@@ -104,6 +104,13 @@
|
|||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="sample-website" depends="init">
|
<target name="sample-website" depends="init">
|
||||||
|
<javac srcdir="source/test-resources/websites/alfresco/ROOT/WEB-INF/classes"
|
||||||
|
classpathref="classpath.compile"/>
|
||||||
|
<mkdir dir="source/test-resources/websites/alfresco/ROOT/WEB-INF/lib"/>
|
||||||
|
<jar basedir="source/test-resources/websites/alfresco/ROOT/WEB-INF/classes"
|
||||||
|
destfile="source/test-resources/websites/alfresco/ROOT/WEB-INF/lib/alfresco-sample-website.jar"
|
||||||
|
includes="**/*.class"/>
|
||||||
|
<mkdir dir="${dir.dist}"/>
|
||||||
<zip destfile="${dir.dist}/alfresco-sample-website.zip"
|
<zip destfile="${dir.dist}/alfresco-sample-website.zip"
|
||||||
basedir="source/test-resources/websites/alfresco/"
|
basedir="source/test-resources/websites/alfresco/"
|
||||||
excludes="**/.svn"/>
|
excludes="**/.svn"/>
|
||||||
|
@@ -67,16 +67,31 @@ public final class AVMConstants
|
|||||||
|
|
||||||
public static String buildAVMStoreUrl(String store)
|
public static String buildAVMStoreUrl(String store)
|
||||||
{
|
{
|
||||||
|
if (store.indexOf(":") > 0)
|
||||||
|
store = store.substring(0, store.indexOf(':'));
|
||||||
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
|
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
|
||||||
return MessageFormat.format(PREVIEW_SANDBOX_URL, lookupStoreDNS(store), config.getWCMDomain(), config.getWCMPort());
|
return MessageFormat.format(PREVIEW_SANDBOX_URL, lookupStoreDNS(store), config.getWCMDomain(), config.getWCMPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String buildAVMAssetUrl(String store, String assetPath)
|
public static String buildAVMAssetUrl(String store, String assetPath)
|
||||||
{
|
{
|
||||||
|
if (assetPath.startsWith('/' + DIR_APPBASE + '/' + DIR_WEBAPPS))
|
||||||
|
assetPath = assetPath.substring(('/' + DIR_APPBASE + '/' + DIR_WEBAPPS).length());
|
||||||
|
if (assetPath.length() == 0 || assetPath.charAt(0) != '/')
|
||||||
|
assetPath = '/' + assetPath;
|
||||||
|
|
||||||
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
|
ClientConfigElement config = Application.getClientConfig(FacesContext.getCurrentInstance());
|
||||||
return MessageFormat.format(PREVIEW_ASSET_URL, lookupStoreDNS(store), config.getWCMDomain(), config.getWCMPort(), assetPath);
|
return MessageFormat.format(PREVIEW_ASSET_URL, lookupStoreDNS(store), config.getWCMDomain(), config.getWCMPort(), assetPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String buildAVMAssetUrl(final String avmPath)
|
||||||
|
{
|
||||||
|
final String[] s = avmPath.split(":");
|
||||||
|
if (s.length != 2)
|
||||||
|
throw new IllegalArgumentException("expected exactly one ':' in " + avmPath);
|
||||||
|
return AVMConstants.buildAVMAssetUrl(s[0], s[1]);
|
||||||
|
}
|
||||||
|
|
||||||
public static String lookupStoreDNS(String store)
|
public static String lookupStoreDNS(String store)
|
||||||
{
|
{
|
||||||
String dns = null;
|
String dns = null;
|
||||||
@@ -113,5 +128,5 @@ public final class AVMConstants
|
|||||||
|
|
||||||
// URLs for preview of sandboxes and assets
|
// URLs for preview of sandboxes and assets
|
||||||
public final static String PREVIEW_SANDBOX_URL = "http://www-{0}.avm.{1}:{2}";
|
public final static String PREVIEW_SANDBOX_URL = "http://www-{0}.avm.{1}:{2}";
|
||||||
public final static String PREVIEW_ASSET_URL = "http://www-{0}.avm.{1}:{2}/{3}";
|
public final static String PREVIEW_ASSET_URL = "http://www-{0}.avm.{1}:{2}{3}";
|
||||||
}
|
}
|
||||||
|
@@ -81,7 +81,6 @@ public class CreateWebContentWizard extends BaseContentWizard
|
|||||||
this.avmBrowseBean = avmBrowseBean;
|
this.avmBrowseBean = avmBrowseBean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------------
|
// ------------------------------------------------------------------------------
|
||||||
// Wizard implementation
|
// Wizard implementation
|
||||||
|
|
||||||
|
@@ -35,7 +35,7 @@ public interface TemplateType
|
|||||||
/** the xml schema for this template type */
|
/** the xml schema for this template type */
|
||||||
public Document getSchema();
|
public Document getSchema();
|
||||||
|
|
||||||
public String /* URI */ getSchemaURI();
|
// public String /* URI */ getSchemaURI();
|
||||||
|
|
||||||
// public void setSchemaNodeRef(final NodeRef nodeRef);
|
// public void setSchemaNodeRef(final NodeRef nodeRef);
|
||||||
//
|
//
|
||||||
|
@@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* 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.templating.xforms;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This exception is thrown when implementations of <code>SchemaFormBuilder</code>
|
||||||
|
* encounters an error building a form.
|
||||||
|
*
|
||||||
|
* @author Brian Dueck
|
||||||
|
*/
|
||||||
|
public class FormBuilderException
|
||||||
|
extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new instance of <code>FormBuilderException</code> without detail message.
|
||||||
|
*/
|
||||||
|
public FormBuilderException() { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance of <code>FormBuilderException</code> with the specified detail message.
|
||||||
|
*
|
||||||
|
* @param msg the detail message.
|
||||||
|
*/
|
||||||
|
public FormBuilderException(String msg)
|
||||||
|
{
|
||||||
|
super(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs an instance of <code>FormBuilderException</code> with the specified root exception.
|
||||||
|
*
|
||||||
|
* @param x The root exception.
|
||||||
|
*/
|
||||||
|
public FormBuilderException(Exception x)
|
||||||
|
{
|
||||||
|
super(x);
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
@@ -80,7 +80,8 @@ public class TemplateTypeImpl
|
|||||||
final TemplatingService ts = TemplatingService.getInstance();
|
final TemplatingService ts = TemplatingService.getInstance();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
this.schema = ts.parseXML(this.schemaNodeRef);
|
//XXXarielb maybe cloneNode instead?
|
||||||
|
return /* this.schema = */ ts.parseXML(this.schemaNodeRef);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.web.templating.xforms.schemabuilder;
|
package org.alfresco.web.templating.xforms;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
@@ -14,7 +14,7 @@
|
|||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.web.bean.ajax;
|
package org.alfresco.web.templating.xforms;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -27,14 +27,16 @@ import javax.faces.context.FacesContext;
|
|||||||
import javax.faces.context.ResponseWriter;
|
import javax.faces.context.ResponseWriter;
|
||||||
import javax.faces.context.ExternalContext;
|
import javax.faces.context.ExternalContext;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.alfresco.web.bean.wcm.AVMConstants;
|
||||||
import org.alfresco.web.templating.*;
|
import org.alfresco.web.templating.*;
|
||||||
import org.alfresco.web.templating.xforms.*;
|
import org.alfresco.web.templating.xforms.*;
|
||||||
import org.alfresco.web.templating.xforms.schemabuilder.FormBuilderException;
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Node;
|
import org.w3c.dom.Node;
|
||||||
|
import org.alfresco.web.bean.wcm.AVMBrowseBean;
|
||||||
import org.alfresco.web.app.servlet.FacesHelper;
|
import org.alfresco.web.app.servlet.FacesHelper;
|
||||||
import org.chiba.xml.xforms.ChibaBean;
|
import org.chiba.xml.xforms.ChibaBean;
|
||||||
import org.chiba.xml.xforms.exception.XFormsException;
|
import org.chiba.xml.xforms.exception.XFormsException;
|
||||||
@@ -42,6 +44,8 @@ import org.chiba.xml.xforms.events.XFormsEvent;
|
|||||||
import org.chiba.xml.xforms.events.XFormsEventFactory;
|
import org.chiba.xml.xforms.events.XFormsEventFactory;
|
||||||
|
|
||||||
import org.w3c.dom.*;
|
import org.w3c.dom.*;
|
||||||
|
import org.w3c.dom.bootstrap.DOMImplementationRegistry;
|
||||||
|
import org.w3c.dom.ls.*;
|
||||||
import org.w3c.dom.events.Event;
|
import org.w3c.dom.events.Event;
|
||||||
import org.w3c.dom.events.EventListener;
|
import org.w3c.dom.events.EventListener;
|
||||||
import org.w3c.dom.events.EventTarget;
|
import org.w3c.dom.events.EventTarget;
|
||||||
@@ -85,20 +89,26 @@ public class XFormsBean
|
|||||||
public void init()
|
public void init()
|
||||||
throws XFormsException
|
throws XFormsException
|
||||||
{
|
{
|
||||||
|
LOGGER.debug("initializing " + this + " with tt " + tt.getName());
|
||||||
this.chibaBean = new ChibaBean();
|
this.chibaBean = new ChibaBean();
|
||||||
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
final FacesContext facesContext = FacesContext.getCurrentInstance();
|
||||||
final ExternalContext externalContext = facesContext.getExternalContext();
|
final ExternalContext externalContext = facesContext.getExternalContext();
|
||||||
final HttpServletRequest request = (HttpServletRequest)
|
final HttpServletRequest request = (HttpServletRequest)
|
||||||
externalContext.getRequest();
|
externalContext.getRequest();
|
||||||
|
final HttpSession session = (HttpSession)
|
||||||
|
externalContext.getSession(true);
|
||||||
|
final AVMBrowseBean browseBean = (AVMBrowseBean)
|
||||||
|
session.getAttribute("AVMBrowseBean");
|
||||||
|
LOGGER.debug("avm cwd is " + browseBean.getCurrentPath());
|
||||||
|
|
||||||
XFormsBean.storeCookies(request.getCookies(), this.chibaBean);
|
XFormsBean.storeCookies(request.getCookies(), this.chibaBean);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
LOGGER.debug("initializing " + this +
|
final Document form = this.buildXForm(instanceData.getContent(),
|
||||||
" with tt " + tt.getName());
|
tt,
|
||||||
//XXXarielb generalize this
|
browseBean.getCurrentPath(),
|
||||||
final XFormsInputMethod tim = (XFormsInputMethod)
|
request);
|
||||||
tt.getInputMethods().get(0);
|
|
||||||
final Document form = tim.getXForm(instanceData.getContent(), tt);
|
|
||||||
this.chibaBean.setXMLContainer(form);
|
this.chibaBean.setXMLContainer(form);
|
||||||
|
|
||||||
final EventTarget et = (EventTarget)
|
final EventTarget et = (EventTarget)
|
||||||
@@ -244,6 +254,59 @@ public class XFormsBean
|
|||||||
out.close();
|
out.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void rewriteInlineURIs(final Document schemaDocument,
|
||||||
|
final String cwdAvmPath)
|
||||||
|
{
|
||||||
|
final NodeList includes =
|
||||||
|
schemaDocument.getElementsByTagNameNS(SchemaFormBuilder.XMLSCHEMA_NS, "include");
|
||||||
|
LOGGER.debug("rewriting " + includes.getLength() + " includes");
|
||||||
|
for (int i = 0; i < includes.getLength(); i++)
|
||||||
|
{
|
||||||
|
final Element includeEl = (Element)includes.item(i);
|
||||||
|
if (includeEl.hasAttribute("schemaLocation"))
|
||||||
|
{
|
||||||
|
String uri = includeEl.getAttribute("schemaLocation");
|
||||||
|
final String baseURI = (uri.charAt(0) == '/'
|
||||||
|
? AVMConstants.buildAVMStoreUrl(cwdAvmPath)
|
||||||
|
: AVMConstants.buildAVMAssetUrl(cwdAvmPath));
|
||||||
|
|
||||||
|
LOGGER.debug("rewriting " + uri + " as " + (baseURI + uri));
|
||||||
|
includeEl.setAttribute("schemaLocation", baseURI + uri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates the xforms based on the schema.
|
||||||
|
*/
|
||||||
|
private Document buildXForm(Document xmlContent,
|
||||||
|
final TemplateType tt,
|
||||||
|
final String cwdAvmPath,
|
||||||
|
final HttpServletRequest request)
|
||||||
|
throws FormBuilderException
|
||||||
|
{
|
||||||
|
final Document schemaDocument = tt.getSchema();
|
||||||
|
this.rewriteInlineURIs(schemaDocument, cwdAvmPath);
|
||||||
|
final String baseUrl = (request.getScheme() + "://" +
|
||||||
|
request.getServerName() + ':' +
|
||||||
|
request.getServerPort() +
|
||||||
|
request.getContextPath());
|
||||||
|
LOGGER.debug("using baseUrl " + baseUrl + " for schemaformbuilder");
|
||||||
|
final SchemaFormBuilder builder =
|
||||||
|
new SchemaFormBuilder("/ajax/invoke/XFormsBean.handleAction",
|
||||||
|
SchemaFormBuilder.SUBMIT_METHOD_POST,
|
||||||
|
new XHTMLWrapperElementsBuilder(),
|
||||||
|
baseUrl);
|
||||||
|
LOGGER.debug("building xform for schema " + tt.getName());
|
||||||
|
final Document result = builder.buildForm(xmlContent,
|
||||||
|
schemaDocument,
|
||||||
|
tt.getName());
|
||||||
|
LOGGER.debug("generated xform: " + result);
|
||||||
|
// LOGGER.debug(ts.writeXMLToString(result));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private Node getEventLog()
|
private Node getEventLog()
|
||||||
{
|
{
|
||||||
final TemplatingService ts = TemplatingService.getInstance();
|
final TemplatingService ts = TemplatingService.getInstance();
|
@@ -22,8 +22,6 @@ import javax.servlet.http.HttpServletRequest;
|
|||||||
import javax.servlet.ServletContext;
|
import javax.servlet.ServletContext;
|
||||||
|
|
||||||
import org.alfresco.web.templating.*;
|
import org.alfresco.web.templating.*;
|
||||||
import org.alfresco.web.templating.xforms.schemabuilder.*;
|
|
||||||
import org.alfresco.web.bean.ajax.XFormsBean;
|
|
||||||
import org.chiba.xml.util.DOMUtil;
|
import org.chiba.xml.util.DOMUtil;
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
@@ -101,44 +99,4 @@ public class XFormsInputMethod
|
|||||||
|
|
||||||
ts.writeXML(result, out);
|
ts.writeXML(result, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String getDocumentElementNameNoNS(final Document d)
|
|
||||||
{
|
|
||||||
final Node n = d.getDocumentElement();
|
|
||||||
String name = n.getNodeName();
|
|
||||||
return name;
|
|
||||||
// String prefix = n.getPrefix();
|
|
||||||
// String namespace = n.getNamespaceURI();
|
|
||||||
// System.out.println("name " + name + " prefix " + prefix + " ns uri " + namespace);
|
|
||||||
// return name.replaceAll(".+\\:", "");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generates the xforms based on the schema.
|
|
||||||
*/
|
|
||||||
public Document getXForm(Document xmlContent, final TemplateType tt)
|
|
||||||
throws FormBuilderException
|
|
||||||
{
|
|
||||||
final TemplatingService ts = TemplatingService.getInstance();
|
|
||||||
final FacesContext fc = FacesContext.getCurrentInstance();
|
|
||||||
final HttpServletRequest request = (HttpServletRequest)
|
|
||||||
fc.getExternalContext().getRequest();
|
|
||||||
final String baseUrl = (request.getScheme() + "://" +
|
|
||||||
request.getServerName() + ':' +
|
|
||||||
request.getServerPort() +
|
|
||||||
request.getContextPath());
|
|
||||||
LOGGER.debug("using baseUrl " + baseUrl + " for schemaformbuilder");
|
|
||||||
|
|
||||||
final SchemaFormBuilder builder =
|
|
||||||
new BaseSchemaFormBuilder(xmlContent,
|
|
||||||
"/ajax/invoke/XFormsBean.handleAction",
|
|
||||||
SchemaFormBuilder.SUBMIT_METHOD_POST,
|
|
||||||
new XHTMLWrapperElementsBuilder(),
|
|
||||||
baseUrl);
|
|
||||||
LOGGER.debug("building xform for schema " + tt.getName());
|
|
||||||
final Document result = builder.buildForm(tt);
|
|
||||||
LOGGER.debug("generated xform: " + result);
|
|
||||||
// LOGGER.debug(ts.writeXMLToString(result));
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@
|
|||||||
* language governing permissions and limitations under the
|
* language governing permissions and limitations under the
|
||||||
* License.
|
* License.
|
||||||
*/
|
*/
|
||||||
package org.alfresco.web.templating.xforms.schemabuilder;
|
package org.alfresco.web.templating.xforms;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
@@ -1,551 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.templating.xforms.schemabuilder;
|
|
||||||
|
|
||||||
import org.apache.xerces.xs.*;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
import org.w3c.dom.Text;
|
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Search for TODO for things remaining to-do in this implementation.
|
|
||||||
*
|
|
||||||
* TODO: i18n/l10n of messages, hints, captions. Possibly leverage org.chiba.i18n classes.
|
|
||||||
* TODO: When Chiba supports itemset, use schema keyref and key constraints for validation.
|
|
||||||
* TODO: Add support for default and fixed values.
|
|
||||||
* TODO: Add support for use=prohibited.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* A concrete base implementation of the SchemaFormBuilder interface allowing
|
|
||||||
* an XForm to be automatically generated for an XML Schema definition.
|
|
||||||
*
|
|
||||||
* @author Brian Dueck
|
|
||||||
* @version $Id: BaseSchemaFormBuilder.java,v 1.19 2005/03/29 14:24:34 unl Exp $
|
|
||||||
*/
|
|
||||||
public class BaseSchemaFormBuilder
|
|
||||||
extends AbstractSchemaFormBuilder
|
|
||||||
implements SchemaFormBuilder {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new BaseSchemaFormBuilder object.
|
|
||||||
*
|
|
||||||
* @param instanceSource __UNDOCUMENTED__
|
|
||||||
* @param action __UNDOCUMENTED__
|
|
||||||
* @param submitMethod __UNDOCUMENTED__
|
|
||||||
* @param wrapper __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public BaseSchemaFormBuilder(final Document instanceDocument,
|
|
||||||
final String action,
|
|
||||||
final String submitMethod,
|
|
||||||
final WrapperElementsBuilder wrapper,
|
|
||||||
final String base)
|
|
||||||
{
|
|
||||||
super(instanceDocument,
|
|
||||||
action,
|
|
||||||
submitMethod,
|
|
||||||
wrapper,
|
|
||||||
base);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param text __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public String createCaption(String text) {
|
|
||||||
// if the word is all upper case, then set to lower case and continue
|
|
||||||
if (text.equals(text.toUpperCase()))
|
|
||||||
text = text.toLowerCase();
|
|
||||||
String[] s = text.split("[-_\\ ]");
|
|
||||||
StringBuffer result = new StringBuffer();
|
|
||||||
for (int i = 0; i < s.length; i++)
|
|
||||||
{
|
|
||||||
if (i != 0)
|
|
||||||
result.append(' ');
|
|
||||||
if (s[i].length() > 1)
|
|
||||||
{
|
|
||||||
result.append(Character.toUpperCase(s[i].charAt(0)) +
|
|
||||||
s[i].substring(1, s[i].length()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result.append(s[i]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param attribute __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public String createCaption(XSAttributeDeclaration attribute) {
|
|
||||||
// TODO: Improve i18n/l10n of caption - may have to use
|
|
||||||
// a custom <appinfo> element in the XML Schema to do this.
|
|
||||||
//
|
|
||||||
return createCaption(attribute.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
public String createCaption(XSAttributeUse attribute) {
|
|
||||||
// TODO: Improve i18n/l10n of caption - may have to use
|
|
||||||
// a custom <appinfo> element in the XML Schema to do this.
|
|
||||||
//
|
|
||||||
return createCaption(attribute.getAttrDeclaration().getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param element __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public String createCaption(XSElementDeclaration element) {
|
|
||||||
// TODO: Improve i18n/l10n of caption - may have to use
|
|
||||||
// a custom <appinfo> element in the XML Schema to do this.
|
|
||||||
//
|
|
||||||
return createCaption(element.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param element __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public String createCaption(XSObject element) {
|
|
||||||
// TODO: Improve i18n/l10n of caption - may have to use
|
|
||||||
// a custom <appinfo> element in the XML Schema to do this.
|
|
||||||
//
|
|
||||||
if (element instanceof XSElementDeclaration) {
|
|
||||||
return createCaption(((XSElementDeclaration) element).getName());
|
|
||||||
} else if (element instanceof XSAttributeDeclaration) {
|
|
||||||
return createCaption(((XSAttributeDeclaration) element).getName());
|
|
||||||
} else if (element instanceof XSAttributeUse) {
|
|
||||||
return createCaption(((XSAttributeUse) element).getAttrDeclaration().getName());
|
|
||||||
} else
|
|
||||||
LOGGER.warn("WARNING: createCaption: element is not an attribute nor an element: "
|
|
||||||
+ element.getClass().getName());
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param xForm __UNDOCUMENTED__
|
|
||||||
* @param caption __UNDOCUMENTED__
|
|
||||||
* @param controlType __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element createControlForAnyType(Document xForm,
|
|
||||||
String caption,
|
|
||||||
XSTypeDefinition controlType) {
|
|
||||||
Element control = xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "textarea");
|
|
||||||
this.setXFormsId(control);
|
|
||||||
control.setAttributeNS(SchemaFormBuilder.CHIBA_NS,
|
|
||||||
SchemaFormBuilder.CHIBA_NS_PREFIX + "height",
|
|
||||||
"3");
|
|
||||||
|
|
||||||
//label
|
|
||||||
Element captionElement = (Element)
|
|
||||||
control.appendChild(xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label"));
|
|
||||||
this.setXFormsId(captionElement);
|
|
||||||
captionElement.appendChild(xForm.createTextNode(caption));
|
|
||||||
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param xForm __UNDOCUMENTED__
|
|
||||||
* @param caption __UNDOCUMENTED__
|
|
||||||
* @param controlType __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element createControlForAtomicType(Document xForm,
|
|
||||||
String caption,
|
|
||||||
XSSimpleTypeDefinition controlType) {
|
|
||||||
Element control;
|
|
||||||
|
|
||||||
//remove while select1 do not work correctly in repeats
|
|
||||||
if ("boolean".equals(controlType.getName()))
|
|
||||||
{
|
|
||||||
control = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "select1");
|
|
||||||
control.setAttributeNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
|
||||||
"full");
|
|
||||||
this.setXFormsId(control);
|
|
||||||
|
|
||||||
Element item_true =
|
|
||||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "item");
|
|
||||||
this.setXFormsId(item_true);
|
|
||||||
Element label_true =
|
|
||||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "label");
|
|
||||||
this.setXFormsId(label_true);
|
|
||||||
Text label_true_text = xForm.createTextNode("true");
|
|
||||||
label_true.appendChild(label_true_text);
|
|
||||||
item_true.appendChild(label_true);
|
|
||||||
|
|
||||||
Element value_true =
|
|
||||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "value");
|
|
||||||
this.setXFormsId(value_true);
|
|
||||||
Text value_true_text = xForm.createTextNode("true");
|
|
||||||
value_true.appendChild(value_true_text);
|
|
||||||
item_true.appendChild(value_true);
|
|
||||||
control.appendChild(item_true);
|
|
||||||
|
|
||||||
Element item_false =
|
|
||||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "item");
|
|
||||||
this.setXFormsId(item_false);
|
|
||||||
Element label_false =
|
|
||||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "label");
|
|
||||||
this.setXFormsId(label_false);
|
|
||||||
Text label_false_text = xForm.createTextNode("false");
|
|
||||||
label_false.appendChild(label_false_text);
|
|
||||||
item_false.appendChild(label_false);
|
|
||||||
|
|
||||||
Element value_false =
|
|
||||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "value");
|
|
||||||
this.setXFormsId(value_false);
|
|
||||||
Text value_false_text = xForm.createTextNode("false");
|
|
||||||
value_false.appendChild(value_false_text);
|
|
||||||
item_false.appendChild(value_false);
|
|
||||||
control.appendChild(item_false);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
control = xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "input");
|
|
||||||
this.setXFormsId(control);
|
|
||||||
}
|
|
||||||
|
|
||||||
//label
|
|
||||||
Element captionElement = (Element)
|
|
||||||
control.appendChild(xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label"));
|
|
||||||
this.setXFormsId(captionElement);
|
|
||||||
captionElement.appendChild(xForm.createTextNode(caption));
|
|
||||||
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param xForm __UNDOCUMENTED__
|
|
||||||
* @param controlType __UNDOCUMENTED__
|
|
||||||
* @param caption __UNDOCUMENTED__
|
|
||||||
* @param bindElement __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element createControlForEnumerationType(Document xForm,
|
|
||||||
XSSimpleTypeDefinition controlType,
|
|
||||||
String caption,
|
|
||||||
Element bindElement) {
|
|
||||||
// TODO: Figure out an intelligent or user determined way to decide between
|
|
||||||
// selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply)
|
|
||||||
// Possibly look for special appInfo section in the schema and if not present default to comboBox...
|
|
||||||
//
|
|
||||||
// For now, use radio if enumValues < DEFAULT_LONG_LIST_MAX_SIZE otherwise use combobox
|
|
||||||
//
|
|
||||||
final StringList enumFacets = controlType.getLexicalEnumeration();
|
|
||||||
if (enumFacets.getLength() <= 0)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
Element control = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "select1");
|
|
||||||
this.setXFormsId(control);
|
|
||||||
|
|
||||||
//label
|
|
||||||
Element captionElement1 = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label");
|
|
||||||
control.appendChild(captionElement1);
|
|
||||||
this.setXFormsId(captionElement1);
|
|
||||||
captionElement1.appendChild(xForm.createTextNode(caption));
|
|
||||||
|
|
||||||
Element choices = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "choices");
|
|
||||||
this.setXFormsId(choices);
|
|
||||||
|
|
||||||
final List<String> enumValues = new ArrayList(enumFacets.getLength());
|
|
||||||
for (int i = 0; i < enumFacets.getLength(); i++)
|
|
||||||
{
|
|
||||||
enumValues.add(enumFacets.item(i));
|
|
||||||
}
|
|
||||||
control.setAttributeNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
|
||||||
(enumFacets.getLength() < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))
|
|
||||||
? getProperty(SELECTONE_UI_CONTROL_SHORT_PROP)
|
|
||||||
: getProperty(SELECTONE_UI_CONTROL_LONG_PROP)));
|
|
||||||
|
|
||||||
if (enumFacets.getLength() >= Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP)))
|
|
||||||
{
|
|
||||||
// add the "Please select..." instruction item for the combobox
|
|
||||||
// and set the isValid attribute on the bind element to check for the "Please select..."
|
|
||||||
// item to indicate that is not a valid value
|
|
||||||
//
|
|
||||||
String pleaseSelect = "[Select1 " + caption + "]";
|
|
||||||
Element item = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "item");
|
|
||||||
this.setXFormsId(item);
|
|
||||||
choices.appendChild(item);
|
|
||||||
|
|
||||||
Element captionElement =
|
|
||||||
xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label");
|
|
||||||
this.setXFormsId(captionElement);
|
|
||||||
item.appendChild(captionElement);
|
|
||||||
captionElement.appendChild(xForm.createTextNode(pleaseSelect));
|
|
||||||
|
|
||||||
Element value =
|
|
||||||
xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "value");
|
|
||||||
this.setXFormsId(value);
|
|
||||||
item.appendChild(value);
|
|
||||||
value.appendChild(xForm.createTextNode(pleaseSelect));
|
|
||||||
|
|
||||||
// not(purchaseOrder/state = '[Choose State]')
|
|
||||||
//String isValidExpr = "not(" + bindElement.getAttributeNS(XFORMS_NS,"nodeset") + " = '" + pleaseSelect + "')";
|
|
||||||
// ->no, not(. = '[Choose State]')
|
|
||||||
String isValidExpr = "not( . = '" + pleaseSelect + "')";
|
|
||||||
|
|
||||||
//check if there was a constraint
|
|
||||||
String constraint = bindElement.getAttributeNS(XFORMS_NS, "constraint");
|
|
||||||
|
|
||||||
constraint = (constraint != null && constraint.length() != 0
|
|
||||||
? constraint + " and " + isValidExpr
|
|
||||||
: isValidExpr);
|
|
||||||
|
|
||||||
bindElement.setAttributeNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "constraint",
|
|
||||||
constraint);
|
|
||||||
}
|
|
||||||
|
|
||||||
control.appendChild(choices);
|
|
||||||
|
|
||||||
this.addChoicesForSelectControl(xForm, choices, enumValues);
|
|
||||||
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param xForm __UNDOCUMENTED__
|
|
||||||
* @param listType __UNDOCUMENTED__
|
|
||||||
* @param caption __UNDOCUMENTED__
|
|
||||||
* @param bindElement __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element createControlForListType(final Document xForm,
|
|
||||||
final XSSimpleTypeDefinition listType,
|
|
||||||
final String caption,
|
|
||||||
final Element bindElement) {
|
|
||||||
XSSimpleTypeDefinition controlType = listType.getItemType();
|
|
||||||
|
|
||||||
final StringList enumFacets = controlType.getLexicalEnumeration();
|
|
||||||
if (enumFacets.getLength() <= 0)
|
|
||||||
return null;
|
|
||||||
Element control = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "select");
|
|
||||||
this.setXFormsId(control);
|
|
||||||
|
|
||||||
//label
|
|
||||||
Element captionElement = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label");
|
|
||||||
control.appendChild(captionElement);
|
|
||||||
this.setXFormsId(captionElement);
|
|
||||||
captionElement.appendChild(xForm.createTextNode(caption));
|
|
||||||
|
|
||||||
List<String> enumValues = new ArrayList<String>(enumFacets.getLength());
|
|
||||||
for (int i = 0; i < enumFacets.getLength(); i++)
|
|
||||||
{
|
|
||||||
enumValues.add(enumFacets.item(i));
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO: Figure out an intelligent or user determined way to decide between
|
|
||||||
// selectUI style (listbox, menu, combobox, radio) (radio and listbox best apply)
|
|
||||||
// Possibly look for special appInfo section in the schema and if not present default to checkBox...
|
|
||||||
//
|
|
||||||
// For now, use checkbox if there are < DEFAULT_LONG_LIST_MAX_SIZE items, otherwise use long control
|
|
||||||
//
|
|
||||||
control.setAttributeNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
|
||||||
(enumValues.size() < Long.parseLong(getProperty(SELECTMANY_LONG_LIST_SIZE_PROP))
|
|
||||||
? getProperty(SELECTMANY_UI_CONTROL_SHORT_PROP)
|
|
||||||
: getProperty(SELECTMANY_UI_CONTROL_LONG_PROP)));
|
|
||||||
Element choices = xForm.createElementNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "choices");
|
|
||||||
this.setXFormsId(choices);
|
|
||||||
control.appendChild(choices);
|
|
||||||
|
|
||||||
this.addChoicesForSelectControl(xForm, choices, enumValues);
|
|
||||||
|
|
||||||
return control;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param xForm __UNDOCUMENTED__
|
|
||||||
* @param node __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element createHint(Document xForm, XSObject node)
|
|
||||||
{
|
|
||||||
XSAnnotation annotation = null;
|
|
||||||
if (node instanceof XSElementDeclaration)
|
|
||||||
annotation = ((XSElementDeclaration) node).getAnnotation();
|
|
||||||
else if (node instanceof XSAttributeDeclaration)
|
|
||||||
annotation = ((XSAttributeDeclaration) node).getAnnotation();
|
|
||||||
else if (node instanceof XSAttributeUse)
|
|
||||||
annotation =
|
|
||||||
((XSAttributeUse) node).getAttrDeclaration().getAnnotation();
|
|
||||||
|
|
||||||
return (annotation != null
|
|
||||||
? addHintFromDocumentation(xForm, annotation)
|
|
||||||
: null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param bindElement __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public void endBindElement(Element bindElement)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param controlElement __UNDOCUMENTED__
|
|
||||||
* @param controlType __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public void endFormControl(final Element controlElement,
|
|
||||||
final XSTypeDefinition controlType,
|
|
||||||
final Occurs o)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param groupElement __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public void endFormGroup(final Element groupElement,
|
|
||||||
final XSTypeDefinition controlType,
|
|
||||||
final Occurs o,
|
|
||||||
final Element modelSection)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param bindElement __UNDOCUMENTED__
|
|
||||||
* @param controlType __UNDOCUMENTED__
|
|
||||||
* @param minOccurs __UNDOCUMENTED__
|
|
||||||
* @param maxOccurs __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element startBindElement(final Element bindElement,
|
|
||||||
final XSModel schema,
|
|
||||||
final XSTypeDefinition controlType,
|
|
||||||
final Occurs o)
|
|
||||||
{
|
|
||||||
// START WORKAROUND
|
|
||||||
// Due to a Chiba bug, anyType is not a recognized type name.
|
|
||||||
// so, if this is an anyType, then we'll just skip the type
|
|
||||||
// setting.
|
|
||||||
//
|
|
||||||
// type.getName() may be 'null' for anonymous types, so compare against
|
|
||||||
// static string (see bug #1172541 on sf.net)
|
|
||||||
if (!"anyType".equals(controlType.getName()))
|
|
||||||
{
|
|
||||||
Element enveloppe = bindElement.getOwnerDocument().getDocumentElement();
|
|
||||||
String typeName = this.getXFormsTypeName(enveloppe, schema, controlType);
|
|
||||||
if (typeName != null && typeName.length() != 0)
|
|
||||||
bindElement.setAttributeNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "type",
|
|
||||||
typeName);
|
|
||||||
}
|
|
||||||
|
|
||||||
bindElement.setAttributeNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "required",
|
|
||||||
o.minimum == 0 ? "false()" : "true()");
|
|
||||||
|
|
||||||
|
|
||||||
//no more minOccurs & maxOccurs element: add a constraint if maxOccurs>1:
|
|
||||||
//count(.) <= maxOccurs && count(.) >= minOccurs
|
|
||||||
String minConstraint = null;
|
|
||||||
String maxConstraint = null;
|
|
||||||
|
|
||||||
if (o.minimum > 1)
|
|
||||||
//if 0 or 1 -> no constraint (managed by "required")
|
|
||||||
minConstraint = "count(.) >= " + o.minimum;
|
|
||||||
|
|
||||||
if (o.maximum > 1)
|
|
||||||
//if 1 or unbounded -> no constraint
|
|
||||||
maxConstraint = "count(.) <= " + o.maximum;
|
|
||||||
|
|
||||||
final String constraint = (minConstraint != null && maxConstraint != null
|
|
||||||
? minConstraint + " and " + maxConstraint
|
|
||||||
: (minConstraint != null
|
|
||||||
? minConstraint
|
|
||||||
: maxConstraint));
|
|
||||||
if (constraint != null && constraint.length() != 0)
|
|
||||||
bindElement.setAttributeNS(XFORMS_NS,
|
|
||||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "constraint",
|
|
||||||
constraint);
|
|
||||||
return bindElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param controlElement __UNDOCUMENTED__
|
|
||||||
* @param controlType __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element startFormControl(Element controlElement,
|
|
||||||
XSTypeDefinition controlType)
|
|
||||||
{
|
|
||||||
return controlElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param groupElement __UNDOCUMENTED__
|
|
||||||
* @param schemaElement __UNDOCUMENTED__
|
|
||||||
* @return __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public Element startFormGroup(Element groupElement,
|
|
||||||
XSElementDeclaration schemaElement)
|
|
||||||
{
|
|
||||||
return groupElement;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.templating.xforms.schemabuilder;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This exception is thrown when implementations of <code>SchemaFormBuilder</code> encounters an
|
|
||||||
* error building a form.
|
|
||||||
*
|
|
||||||
* @author Brian Dueck
|
|
||||||
* @version $Id: FormBuilderException.java,v 1.4 2005/01/31 22:49:31 joernt Exp $
|
|
||||||
*/
|
|
||||||
public class FormBuilderException extends java.lang.Exception {
|
|
||||||
private Exception cause = null;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new instance of <code>FormBuilderException</code> without detail message.
|
|
||||||
*/
|
|
||||||
public FormBuilderException() {
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an instance of <code>FormBuilderException</code> with the specified detail message.
|
|
||||||
*
|
|
||||||
* @param msg the detail message.
|
|
||||||
*/
|
|
||||||
public FormBuilderException(String msg) {
|
|
||||||
super(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructs an instance of <code>FormBuilderException</code> with the specified root exception.
|
|
||||||
*
|
|
||||||
* @param x The root exception.
|
|
||||||
*/
|
|
||||||
public FormBuilderException(Exception x) {
|
|
||||||
//THIS DOES NOT WORK WITH JDK 1.3 CAUSE THIS IS NEW IN JDK 1.4
|
|
||||||
//super(x);
|
|
||||||
super(x.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
$Log: FormBuilderException.java,v $
|
|
||||||
Revision 1.4 2005/01/31 22:49:31 joernt
|
|
||||||
added copyright notice
|
|
||||||
|
|
||||||
Revision 1.3 2004/08/15 14:14:07 joernt
|
|
||||||
preparing release...
|
|
||||||
-reformatted sources to fix mixture of tabs and spaces
|
|
||||||
-optimized imports on all files
|
|
||||||
|
|
||||||
Revision 1.2 2003/10/02 15:15:49 joernt
|
|
||||||
applied chiba jalopy settings to whole src tree
|
|
||||||
|
|
||||||
Revision 1.1 2003/07/12 12:22:48 joernt
|
|
||||||
package refactoring: moved from xforms.builder
|
|
||||||
Revision 1.1.1.1 2003/05/23 14:54:08 unl
|
|
||||||
no message
|
|
||||||
Revision 1.2 2003/02/19 09:09:15 soframel
|
|
||||||
print the exception's message
|
|
||||||
Revision 1.1 2002/12/11 14:50:42 soframel
|
|
||||||
transferred the Schema2XForms generator from chiba2 to chiba1
|
|
||||||
Revision 1.3 2002/06/11 17:13:03 joernt
|
|
||||||
commented out jdk 1.3 incompatible constructor-impl
|
|
||||||
Revision 1.2 2002/06/11 14:06:31 joernt
|
|
||||||
commented out the jdk 1.4 constructor
|
|
||||||
Revision 1.1 2002/05/22 22:24:34 joernt
|
|
||||||
Brian's initial version of schema2xforms builder
|
|
||||||
*/
|
|
@@ -1,445 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.templating.xforms.schemabuilder;
|
|
||||||
|
|
||||||
import org.apache.commons.logging.Log;
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.xerces.xs.*;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
import org.w3c.dom.Element;
|
|
||||||
|
|
||||||
import javax.xml.transform.Source;
|
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import org.alfresco.web.templating.*;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* An object that implements this interface can build an XForm that conforms to
|
|
||||||
* the elements and attributes declared in an XML Schema.
|
|
||||||
*
|
|
||||||
* @author Brian Dueck
|
|
||||||
* @version $Id: SchemaFormBuilder.java,v 1.16 2005/02/10 13:24:57 joernt Exp $
|
|
||||||
*/
|
|
||||||
public interface SchemaFormBuilder
|
|
||||||
{
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public static class Occurs
|
|
||||||
{
|
|
||||||
public final static int UNBOUNDED = -1;
|
|
||||||
|
|
||||||
public final int minimum;
|
|
||||||
public final int maximum;
|
|
||||||
|
|
||||||
public Occurs(final XSParticle particle)
|
|
||||||
{
|
|
||||||
if (particle == null)
|
|
||||||
{
|
|
||||||
this.minimum = 1;
|
|
||||||
this.maximum = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
this.minimum = particle.getMinOccurs();
|
|
||||||
this.maximum = (particle.getMaxOccursUnbounded()
|
|
||||||
? Occurs.UNBOUNDED
|
|
||||||
: particle.getMaxOccurs());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Occurs(final int minimum)
|
|
||||||
{
|
|
||||||
this(minimum, UNBOUNDED);
|
|
||||||
}
|
|
||||||
|
|
||||||
public Occurs(final int minimum, final int maximum)
|
|
||||||
{
|
|
||||||
this.minimum = minimum;
|
|
||||||
this.maximum = maximum;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isUnbounded()
|
|
||||||
{
|
|
||||||
return this.maximum == UNBOUNDED;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "minimum=" + minimum + ", maximum=" + maximum;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
public final static Log LOGGER =
|
|
||||||
LogFactory.getLog(SchemaFormBuilder.class);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XMLSchema Instance Namespace declaration
|
|
||||||
*/
|
|
||||||
public static final String XMLSCHEMA_INSTANCE_NS =
|
|
||||||
"http://www.w3.org/2001/XMLSchema-instance";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XMLSchema instance prefix
|
|
||||||
*/
|
|
||||||
public static final String XMLSCHEMA_INSTANCE_NS_PREFIX = "xsi:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XMLNS Namespace declaration.
|
|
||||||
*/
|
|
||||||
public static final String XMLNS_NAMESPACE_URI =
|
|
||||||
"http://www.w3.org/2000/xmlns/";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML Namespace declaration
|
|
||||||
*/
|
|
||||||
public static final String XML_NAMESPACE_URI =
|
|
||||||
"http://www.w3.org/XML/1998/namespace";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XForms namespace declaration.
|
|
||||||
*/
|
|
||||||
public static final String XFORMS_NS =
|
|
||||||
"http://www.w3.org/2002/xforms";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XForms prefix
|
|
||||||
*/
|
|
||||||
public static final String XFORMS_NS_PREFIX = "xforms:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chiba namespace declaration.
|
|
||||||
*/
|
|
||||||
public static final String CHIBA_NS =
|
|
||||||
"http://chiba.sourceforge.net/xforms";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Chiba prefix
|
|
||||||
*/
|
|
||||||
public static final String CHIBA_NS_PREFIX = "chiba:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XLink namespace declaration.
|
|
||||||
*/
|
|
||||||
public static final String XLINK_NS = "http://www.w3.org/1999/xlink";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Xlink prefix
|
|
||||||
*/
|
|
||||||
public static final String XLINK_NS_PREFIX = "xlink:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML Events namsepace declaration.
|
|
||||||
*/
|
|
||||||
public static final String XMLEVENTS_NS = "http://www.w3.org/2001/xml-events";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* XML Events prefix
|
|
||||||
*/
|
|
||||||
public static final String XMLEVENTS_NS_PREFIX = "ev:";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Prossible values of the "@method" on the "submission" element
|
|
||||||
*/
|
|
||||||
public static final String SUBMIT_METHOD_POST = "post";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public static final String SUBMIT_METHOD_PUT = "put";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public static final String SUBMIT_METHOD_GET = "get";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public static final String SUBMIT_METHOD_FORM_DATA_POST = "form-data-post";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public static final String SUBMIT_METHOD_URLENCODED_POST =
|
|
||||||
"urlencoded-post";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the current set of properties used by implementations of SchemaFormBuilder.
|
|
||||||
*
|
|
||||||
* @return The list of properties.
|
|
||||||
*/
|
|
||||||
public Properties getProperties();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the property to the specified value. If the property exists, its value is overwritten.
|
|
||||||
*
|
|
||||||
* @param key The implementation defined property key.
|
|
||||||
* @param value The value for the property.
|
|
||||||
*/
|
|
||||||
public void setProperty(String key, String value);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value for the specified property.
|
|
||||||
*
|
|
||||||
* @param key The implementation defined property key.
|
|
||||||
* @return The property value if found, or null if the property cannot be located.
|
|
||||||
*/
|
|
||||||
public String getProperty(String key);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the value for the specified property, with a default if the property cannot be located.
|
|
||||||
*
|
|
||||||
* @param key The implementation defined property key.
|
|
||||||
* @param defaultValue This value will be returned if the property does not exists.
|
|
||||||
* @return The property value if found, or defaultValue if the property cannot be located.
|
|
||||||
*/
|
|
||||||
public String getProperty(String key, String defaultValue);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Generate the XForm based on a user supplied XML Schema.
|
|
||||||
*
|
|
||||||
* @param inputURI The document source for the XML Schema.
|
|
||||||
* @return The Document containing the XForm.
|
|
||||||
* @throws org.chiba.tools.schemabuilder.FormBuilderException
|
|
||||||
* If an error occurs building the XForm.
|
|
||||||
*/
|
|
||||||
public Document buildForm(final TemplateType tt)
|
|
||||||
throws FormBuilderException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a caption for the provided text extracted from the XML Schema.
|
|
||||||
* The implementation is responsible for reformatting the provided string to make it
|
|
||||||
* suitable to be displayed to users of the XForm. This typically includes translating
|
|
||||||
* XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly
|
|
||||||
* captions (e.g. Customer Street Address).
|
|
||||||
*
|
|
||||||
* @param text The string value to be reformatted for use as a caption.
|
|
||||||
* @return The caption.
|
|
||||||
*/
|
|
||||||
public String createCaption(String text);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a caption for the provided XML Schema attribute.
|
|
||||||
* The implementation is responsible for providing an appropriate caption
|
|
||||||
* suitable to be displayed to users of the XForm. This typically includes translating
|
|
||||||
* XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly
|
|
||||||
* captions (e.g. Customer Street Address).
|
|
||||||
*
|
|
||||||
* @param attribute The XML schema attribute for which a caption is required.
|
|
||||||
* @return The caption.
|
|
||||||
*/
|
|
||||||
public String createCaption(XSAttributeDeclaration attribute);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a caption for the provided XML Schema element.
|
|
||||||
* The implementation is responsible for providing an appropriate caption
|
|
||||||
* suitable to be displayed to users of the XForm. This typically includes translating
|
|
||||||
* XML tag name style identifiers (e.g. customerStreetAddress) into more reader friendly
|
|
||||||
* captions (e.g. Customer Street Address).
|
|
||||||
*
|
|
||||||
* @param element The XML schema element for which a caption is required.
|
|
||||||
* @return The caption.
|
|
||||||
*/
|
|
||||||
public String createCaption(XSElementDeclaration element);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form control for an XML Schema any type.
|
|
||||||
* <p/>
|
|
||||||
* This method is called when the form builder determines a form control is required for
|
|
||||||
* an any type.
|
|
||||||
* The implementation of this method is responsible for creating an XML element of the
|
|
||||||
* appropriate type to receive a value for <b>controlType</b>. The caller is responsible
|
|
||||||
* for adding the returned element to the form and setting caption, bind, and other
|
|
||||||
* standard elements and attributes.
|
|
||||||
*
|
|
||||||
* @param xForm The XForm document.
|
|
||||||
* @param controlType The XML Schema type for which the form control is to be created.
|
|
||||||
* @return The element for the form control.
|
|
||||||
*/
|
|
||||||
public Element createControlForAnyType(Document xForm,
|
|
||||||
String caption,
|
|
||||||
XSTypeDefinition controlType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form control for an XML Schema simple atomic type.
|
|
||||||
* <p/>
|
|
||||||
* This method is called when the form builder determines a form control is required for
|
|
||||||
* an atomic type.
|
|
||||||
* The implementation of this method is responsible for creating an XML element of the
|
|
||||||
* appropriate type to receive a value for <b>controlType</b>. The caller is responsible
|
|
||||||
* for adding the returned element to the form and setting caption, bind, and other
|
|
||||||
* standard elements and attributes.
|
|
||||||
*
|
|
||||||
* @param xForm The XForm document.
|
|
||||||
* @param controlType The XML Schema type for which the form control is to be created.
|
|
||||||
* @return The element for the form control.
|
|
||||||
*/
|
|
||||||
public Element createControlForAtomicType(Document xForm,
|
|
||||||
String caption,
|
|
||||||
XSSimpleTypeDefinition controlType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form control for an XML Schema simple type restricted by an enumeration.
|
|
||||||
* This method is called when the form builder determines a form control is required for
|
|
||||||
* an enumerated type.
|
|
||||||
* The implementation of this method is responsible for creating an XML element of the
|
|
||||||
* appropriate type to receive a value for <b>controlType</b>. The caller is responsible
|
|
||||||
* for adding the returned element to the form and setting caption, bind, and other
|
|
||||||
* standard elements and attributes.
|
|
||||||
*
|
|
||||||
* @param xForm The XForm document.
|
|
||||||
* @param controlType The XML Schema type for which the form control is to be created.
|
|
||||||
* @param caption The caption for the form control. The caller The purpose of providing the caption
|
|
||||||
* is to permit the implementation to add a <b>[Select1 .... ]</b> message that involves the caption.
|
|
||||||
* @param bindElement The bind element for this control. The purpose of providing the bind element
|
|
||||||
* is to permit the implementation to add a isValid attribute to the bind element that prevents
|
|
||||||
* the <b>[Select1 .... ]</b> item from being selected.
|
|
||||||
* @return The element for the form control.
|
|
||||||
*/
|
|
||||||
public Element createControlForEnumerationType(Document xForm,
|
|
||||||
XSSimpleTypeDefinition controlType,
|
|
||||||
String caption,
|
|
||||||
Element bindElement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a form control for an XML Schema simple list type.
|
|
||||||
* <p/>
|
|
||||||
* This method is called when the form builder determines a form control is required for
|
|
||||||
* a list type.
|
|
||||||
* The implementation of this method is responsible for creating an XML element of the
|
|
||||||
* appropriate type to receive a value for <b>controlType</b>. The caller is responsible
|
|
||||||
* for adding the returned element to the form and setting caption, bind, and other
|
|
||||||
* standard elements and attributes.
|
|
||||||
*
|
|
||||||
* @param xForm The XForm document.
|
|
||||||
* @param listType The XML Schema list type for which the form control is to be created.
|
|
||||||
* @param caption The caption for the form control. The caller The purpose of providing the caption
|
|
||||||
* is to permit the implementation to add a <b>[Select1 .... ]</b> message that involves the caption.
|
|
||||||
* @param bindElement The bind element for this control. The purpose of providing the bind element
|
|
||||||
* is to permit the implementation to add a isValid attribute to the bind element that prevents
|
|
||||||
* the <b>[Select1 .... ]</b> item from being selected.
|
|
||||||
* @return The element for the form control.
|
|
||||||
*/
|
|
||||||
public Element createControlForListType(Document xForm,
|
|
||||||
XSSimpleTypeDefinition listType,
|
|
||||||
String caption,
|
|
||||||
Element bindElement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a hint XML Schema annotated node (AttributeDecl or ElementDecl).
|
|
||||||
* The implementation is responsible for providing an xforms:hint element for the
|
|
||||||
* specified schemaNode suitable to be dsipalayed to users of the XForm. The caller
|
|
||||||
* is responsible for adding the returned element to the form.
|
|
||||||
* This typically includes extracting documentation from the element/attribute's
|
|
||||||
* annotation/documentation elements and/or extracting the same information from the
|
|
||||||
* element/attribute's type annotation/documentation.
|
|
||||||
*
|
|
||||||
* @param schemaNode The string value to be reformatted for use as a caption.
|
|
||||||
* @return The xforms:hint element. If a null value is returned a hint is not added.
|
|
||||||
*/
|
|
||||||
public Element createHint(Document xForm, XSObject schemaNode);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after the form builder is finished creating and processing
|
|
||||||
* a bind element. Implementations may choose to use this method to add/inspect/modify
|
|
||||||
* the bindElement prior to the builder moving onto the next bind element.
|
|
||||||
*
|
|
||||||
* @param bindElement The bind element being processed.
|
|
||||||
*/
|
|
||||||
public void endBindElement(Element bindElement);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after the form builder is finished creating and processing
|
|
||||||
* a form control. Implementations may choose to use this method to add/inspect/modify
|
|
||||||
* the controlElement prior to the builder moving onto the next control.
|
|
||||||
*
|
|
||||||
* @param controlElement The form control element that was created.
|
|
||||||
* @param controlType The XML Schema type for which <b>controlElement</b> was created.
|
|
||||||
*/
|
|
||||||
public void endFormControl(Element controlElement,
|
|
||||||
XSTypeDefinition controlType,
|
|
||||||
Occurs occurs);
|
|
||||||
/**
|
|
||||||
* __UNDOCUMENTED__
|
|
||||||
*
|
|
||||||
* @param groupElement __UNDOCUMENTED__
|
|
||||||
*/
|
|
||||||
public void endFormGroup(Element groupElement,
|
|
||||||
XSTypeDefinition controlType,
|
|
||||||
Occurs occurs,
|
|
||||||
Element modelSection);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the SchemaFormBuilder to default values.
|
|
||||||
*/
|
|
||||||
public void reset();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after an xforms:bind element is created for the specified SimpleType.
|
|
||||||
* The implementation is responsible for setting setting any/all bind attributes
|
|
||||||
* except for <b>id</b> and <b>ref</b> - these have been automatically set
|
|
||||||
* by the caller (and should not be touched by implementation of startBindElement)
|
|
||||||
* prior to invoking startBindElement.
|
|
||||||
* The caller automatically adds the returned element to the model section of
|
|
||||||
* the form.
|
|
||||||
*
|
|
||||||
* @param bindElement The bindElement being processed.
|
|
||||||
* @param controlType XML Schema type of the element/attribute this bind is for.
|
|
||||||
* @param minOccurs The minimum number of occurences for this element/attribute.
|
|
||||||
* @param maxOccurs The maximum number of occurences for this element/attribute.
|
|
||||||
* @return The bind Element to use in the XForm - bindElement or a replacement.
|
|
||||||
*/
|
|
||||||
public Element startBindElement(Element bindElement,
|
|
||||||
XSModel schema,
|
|
||||||
XSTypeDefinition controlType,
|
|
||||||
Occurs occurs);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after the form builder creates a form control
|
|
||||||
* via a createControlForXXX() method but prior to decorating the form control
|
|
||||||
* with common attributes such as a caption, hint, help text elements,
|
|
||||||
* bind attributes, etc.
|
|
||||||
* The returned element is used in the XForm in place of controlElement.
|
|
||||||
* Implementations may choose to use this method to substitute controlElement
|
|
||||||
* with a different element, or perform any other processing on controlElement
|
|
||||||
* prior to it being added to the form.
|
|
||||||
*
|
|
||||||
* @param controlElement The form control element that was created.
|
|
||||||
* @param controlType The XML Schema type for which <b>controlElement</b> was created.
|
|
||||||
* @return The Element to use in the XForm - controlElement or a replacement.
|
|
||||||
*/
|
|
||||||
public Element startFormControl(Element controlElement,
|
|
||||||
XSTypeDefinition controlType);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is invoked after an xforms:group element is created for the specified
|
|
||||||
* ElementDecl. A group is created whenever an element is encountered in the XML Schema
|
|
||||||
* that contains other elements and attributes (complex types or mixed content types).
|
|
||||||
* The caller automatically adds the returned element to the XForm.
|
|
||||||
*
|
|
||||||
* @param groupElement The groupElement being processed.
|
|
||||||
* @param schemaElement The schemaElement for the group.
|
|
||||||
* @return The group Element to use in the XForm - groupElement or a replacement. If a null
|
|
||||||
* value is returned, the group is not created.
|
|
||||||
*/
|
|
||||||
public Element startFormGroup(Element groupElement,
|
|
||||||
XSElementDeclaration schemaElement);
|
|
||||||
}
|
|
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.pr;
|
||||||
|
|
||||||
|
public class CompanyFooterBean
|
||||||
|
{
|
||||||
|
private final String name;
|
||||||
|
private final String href;
|
||||||
|
|
||||||
|
public CompanyFooterBean(final String name,
|
||||||
|
final String href)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
this.href = href;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHref()
|
||||||
|
{
|
||||||
|
return this.href;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.pr;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class PressReleaseBean
|
||||||
|
{
|
||||||
|
private final String title;
|
||||||
|
private final String theAbstract;
|
||||||
|
private final Date launchDate;
|
||||||
|
private final String href;
|
||||||
|
|
||||||
|
public PressReleaseBean(final String title,
|
||||||
|
final String theAbstract,
|
||||||
|
final Date launchDate,
|
||||||
|
final String href)
|
||||||
|
{
|
||||||
|
this.title = title;
|
||||||
|
this.theAbstract = theAbstract;
|
||||||
|
this.launchDate = launchDate;
|
||||||
|
this.href = href;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTitle()
|
||||||
|
{
|
||||||
|
return this.title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAbstract()
|
||||||
|
{
|
||||||
|
return this.theAbstract;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getLaunchDate()
|
||||||
|
{
|
||||||
|
return this.launchDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHref()
|
||||||
|
{
|
||||||
|
return this.href;
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* 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.pr;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.http.*;
|
||||||
|
import java.io.*;
|
||||||
|
import java.util.*;
|
||||||
|
import org.alfresco.jndi.*;
|
||||||
|
import org.alfresco.repo.avm.AVMRemote;
|
||||||
|
import org.alfresco.service.cmr.avm.AVMNodeDescriptor;
|
||||||
|
import org.w3c.dom.*;
|
||||||
|
import javax.xml.parsers.*;
|
||||||
|
import java.text.*;
|
||||||
|
|
||||||
|
public class Util
|
||||||
|
{
|
||||||
|
public static List<PressReleaseBean> getPressReleases(final HttpServletRequest request,
|
||||||
|
final ServletContext servletContext)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
final Map<String, Document> entries = Util.loadXMLDocuments(request,
|
||||||
|
servletContext,
|
||||||
|
"/media/releases/content",
|
||||||
|
"alfresco:press-release");
|
||||||
|
final List<PressReleaseBean> result = new ArrayList<PressReleaseBean>(entries.size());
|
||||||
|
for (Map.Entry<String, Document> entry : entries.entrySet() )
|
||||||
|
{
|
||||||
|
String fileName = entry.getKey();
|
||||||
|
Document d = entry.getValue();
|
||||||
|
Element t = (Element)d.getElementsByTagName("alfresco:title").item(0);
|
||||||
|
Element a = (Element)d.getElementsByTagName("alfresco:abstract").item(0);
|
||||||
|
Element dateEl = (Element)d.getElementsByTagName("alfresco:launch_date").item(0);
|
||||||
|
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateEl.getFirstChild().getNodeValue());
|
||||||
|
String href = "/media/releases/content/" + fileName;
|
||||||
|
href = href.replaceAll(".xml$", ".shtml");
|
||||||
|
result.add(new PressReleaseBean(t.getFirstChild().getNodeValue(),
|
||||||
|
a.getFirstChild().getNodeValue(),
|
||||||
|
date,
|
||||||
|
href));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<CompanyFooterBean> getCompanyFooters(final HttpServletRequest request,
|
||||||
|
final ServletContext servletContext)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
final Map<String, Document> entries = Util.loadXMLDocuments(request,
|
||||||
|
servletContext,
|
||||||
|
"/media/releases/content/company_footers",
|
||||||
|
"alfresco:company-footer");
|
||||||
|
final List<CompanyFooterBean> result = new ArrayList<CompanyFooterBean>(entries.size());
|
||||||
|
for (Map.Entry<String, Document> entry : entries.entrySet())
|
||||||
|
{
|
||||||
|
String fileName = entry.getKey();
|
||||||
|
Document d = entry.getValue();
|
||||||
|
Element n = (Element)d.getElementsByTagName("alfresco:name").item(0);
|
||||||
|
String href = "/media/releases/content/company_footers/" + fileName;
|
||||||
|
result.add(new CompanyFooterBean(n.getFirstChild().getNodeValue(),
|
||||||
|
href));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Map<String, Document> loadXMLDocuments(final HttpServletRequest request,
|
||||||
|
final ServletContext servletContext,
|
||||||
|
final String path,
|
||||||
|
final String documentElementNodeName)
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
|
dbf.setNamespaceAware(true);
|
||||||
|
dbf.setValidating(false);
|
||||||
|
final DocumentBuilder db = dbf.newDocumentBuilder();
|
||||||
|
|
||||||
|
// The real_path will look somethign like this:
|
||||||
|
// /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
||||||
|
//
|
||||||
|
String real_path = servletContext.getRealPath(path);
|
||||||
|
|
||||||
|
// The avm_path to the root of the context will look something like this:
|
||||||
|
// alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
||||||
|
//
|
||||||
|
String avm_path = real_path.substring(real_path.indexOf('$', real_path.indexOf('$') + 1) + 1);
|
||||||
|
avm_path = avm_path.replace('\\','/');
|
||||||
|
|
||||||
|
final AVMRemote avm_remote = AVMFileDirContext.getAVMRemote();
|
||||||
|
final Map<String, AVMNodeDescriptor> entries = avm_remote.getDirectoryListing(-1, avm_path);
|
||||||
|
|
||||||
|
Map<String, Document> result = new HashMap<String, Document>();
|
||||||
|
for (Map.Entry<String, AVMNodeDescriptor> entry : entries.entrySet() )
|
||||||
|
{
|
||||||
|
final String entry_name = entry.getKey();
|
||||||
|
AVMNodeDescriptor entry_node = entry.getValue();
|
||||||
|
if (entry_node.isFile())
|
||||||
|
{
|
||||||
|
final InputStream istream =
|
||||||
|
new AVMRemoteInputStream(avm_remote.getInputHandle(-1, avm_path + '/' + entry_name),
|
||||||
|
avm_remote );
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Document d = db.parse(istream);
|
||||||
|
if (documentElementNodeName.equals(d.getDocumentElement().getNodeName()))
|
||||||
|
result.put(entry_name, d);
|
||||||
|
}
|
||||||
|
catch (Throwable t)
|
||||||
|
{
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
istream.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
@@ -9,11 +9,7 @@
|
|||||||
|
|
||||||
<description>Alfresco Website</description>
|
<description>Alfresco Website</description>
|
||||||
|
|
||||||
<context-param>
|
<!-- Faces Servlet -->
|
||||||
<param-name>foor</param-name>
|
|
||||||
<param-value>bar</param-value>
|
|
||||||
<description>foo bar</description>
|
|
||||||
</context-param>
|
|
||||||
|
|
||||||
<welcome-file-list>
|
<welcome-file-list>
|
||||||
<welcome-file>index.jsp</welcome-file>
|
<welcome-file>index.jsp</welcome-file>
|
||||||
|
@@ -0,0 +1,25 @@
|
|||||||
|
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
|
||||||
|
|
||||||
|
<jsp:directive.page import="java.util.*"/>
|
||||||
|
<jsp:directive.page import="org.alfresco.web.pr.*"/>
|
||||||
|
|
||||||
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
|
elementFormDefault="qualified">
|
||||||
|
<xs:simpleType name="company-footer">
|
||||||
|
<xs:restriction base="xs:string">
|
||||||
|
<%
|
||||||
|
List<CompanyFooterBean> companyFooters = Util.getCompanyFooters(request, application);
|
||||||
|
for (CompanyFooterBean companyFooter : companyFooters)
|
||||||
|
{
|
||||||
|
%>
|
||||||
|
<xs:enumeration value="<%= companyFooter.getHref() %>">
|
||||||
|
<xs:annotation>
|
||||||
|
<xs:documentation><%= companyFooter.getName() %></xs:documentation>
|
||||||
|
</xs:annotation>
|
||||||
|
</xs:enumeration>
|
||||||
|
<%
|
||||||
|
}
|
||||||
|
%>
|
||||||
|
</xs:restriction>
|
||||||
|
</xs:simpleType>
|
||||||
|
</xs:schema>
|
@@ -1,88 +1,7 @@
|
|||||||
<jsp:directive.page import="java.io.*"/>
|
<jsp:directive.page language="java" contentType="text/html; charset=UTF-8"/>
|
||||||
<jsp:directive.page import="java.util.*"/>
|
|
||||||
<jsp:directive.page import="org.alfresco.jndi.*"/>
|
|
||||||
<jsp:directive.page import="org.alfresco.repo.avm.AVMRemote"/>
|
|
||||||
<jsp:directive.page import="org.alfresco.service.cmr.avm.AVMNodeDescriptor"/>
|
|
||||||
<jsp:directive.page import="org.w3c.dom.*"/>
|
|
||||||
<jsp:directive.page import="javax.xml.parsers.*"/>
|
|
||||||
<jsp:directive.page import="java.text.*"/>
|
<jsp:directive.page import="java.text.*"/>
|
||||||
<%!
|
<jsp:directive.page import="java.util.*"/>
|
||||||
class PressRelease
|
<jsp:directive.page import="org.alfresco.web.pr.*"/>
|
||||||
{
|
|
||||||
public final String title;
|
|
||||||
public final String theAbstract;
|
|
||||||
public final Date date;
|
|
||||||
public final String href;
|
|
||||||
|
|
||||||
public PressRelease(String title, String theAbstract, Date d, String href)
|
|
||||||
{
|
|
||||||
this.title = title;
|
|
||||||
this.theAbstract = theAbstract;
|
|
||||||
this.date = d;
|
|
||||||
this.href = href;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<PressRelease> getPressReleases(HttpServletRequest request, ServletContext servletContext, JspWriter out)
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
|
||||||
dbf.setNamespaceAware(true);
|
|
||||||
dbf.setValidating(false);
|
|
||||||
final DocumentBuilder db = dbf.newDocumentBuilder();
|
|
||||||
|
|
||||||
// The real_path will look somethign like this:
|
|
||||||
// /alfresco.avm/avm.alfresco.localhost/$-1$alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
|
||||||
//
|
|
||||||
String real_path = servletContext.getRealPath("/media/releases/content");
|
|
||||||
|
|
||||||
// The avm_path to the root of the context will look something like this:
|
|
||||||
// alfreco-guest-main:/appBase/avm_webapps/my_webapp
|
|
||||||
//
|
|
||||||
String avm_path = real_path.substring( real_path.indexOf('$', real_path.indexOf('$') + 1) + 1 );
|
|
||||||
avm_path = avm_path.replace('\\','/');
|
|
||||||
|
|
||||||
AVMRemote avm_remote = AVMFileDirContext.getAVMRemote();
|
|
||||||
Map< String, AVMNodeDescriptor> entries = avm_remote.getDirectoryListing(-1, avm_path);
|
|
||||||
|
|
||||||
List<PressRelease> result = new LinkedList<PressRelease>();
|
|
||||||
for ( Map.Entry<String, AVMNodeDescriptor> entry : entries.entrySet() )
|
|
||||||
{
|
|
||||||
String entry_name = entry.getKey();
|
|
||||||
AVMNodeDescriptor entry_node = entry.getValue();
|
|
||||||
if (entry_node.isFile())
|
|
||||||
{
|
|
||||||
InputStream istream = new AVMRemoteInputStream( avm_remote.getInputHandle( -1, avm_path + '/' + entry_name ), avm_remote );
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Document d = db.parse(istream);
|
|
||||||
if ("alfresco:press-release".equals(d.getDocumentElement().getNodeName()))
|
|
||||||
{
|
|
||||||
Element t = (Element)d.getElementsByTagName("alfresco:title").item(0);
|
|
||||||
Element a = (Element)d.getElementsByTagName("alfresco:abstract").item(0);
|
|
||||||
Element dateEl = (Element)d.getElementsByTagName("alfresco:launch_date").item(0);
|
|
||||||
Date date = new SimpleDateFormat("yyyy-MM-dd").parse(dateEl.getFirstChild().getNodeValue());
|
|
||||||
String href = "/media/releases/content/" + entry_name;
|
|
||||||
href = href.replaceAll(".xml$", ".shtml");
|
|
||||||
result.add(new PressRelease(t.getFirstChild().getNodeValue(),
|
|
||||||
a.getFirstChild().getNodeValue(),
|
|
||||||
date,
|
|
||||||
href));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Throwable t)
|
|
||||||
{
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
finally
|
|
||||||
{
|
|
||||||
istream.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
%>
|
|
||||||
|
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||||
@@ -162,12 +81,12 @@ public List<PressRelease> getPressReleases(HttpServletRequest request, ServletCo
|
|||||||
<h1>Alfresco Press Releases</h1>
|
<h1>Alfresco Press Releases</h1>
|
||||||
|
|
||||||
<%
|
<%
|
||||||
List<PressRelease> pressReleases = getPressReleases(request, application, out);
|
List<PressReleaseBean> pressReleases = Util.getPressReleases(request, application);
|
||||||
for (PressRelease pr : pressReleases)
|
for (PressReleaseBean pr : pressReleases)
|
||||||
{
|
{
|
||||||
%>
|
%>
|
||||||
<h2 class="headline"><a href="<%= pr.href %>"><%= pr.title %></a></h2>
|
<h2 class="headline"><a href="<%= pr.getHref() %>"><%= pr.getTitle() %></a></h2>
|
||||||
<p class="date"><%= DateFormat.getDateInstance(DateFormat.LONG).format(pr.date) %></p><p class="abstract"><%= pr.theAbstract %></p>
|
<p class="date"><%= DateFormat.getDateInstance(DateFormat.LONG).format(pr.getLaunchDate()) %></p><p class="abstract"><%= pr.getAbstract() %></p>
|
||||||
<%
|
<%
|
||||||
}
|
}
|
||||||
%>
|
%>
|
||||||
|
@@ -1,8 +1,10 @@
|
|||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
|
||||||
xmlns:alfresco="http://www.alfresco.org/alfresco"
|
xmlns:alfresco="http://www.alfresco.org/alfresco"
|
||||||
|
xml:base="http://wacko.org"
|
||||||
targetNamespace="http://www.alfresco.org/alfresco"
|
targetNamespace="http://www.alfresco.org/alfresco"
|
||||||
elementFormDefault="qualified">
|
elementFormDefault="qualified">
|
||||||
|
<xs:include schemaLocation="/GetCompanyFooterSimpleType"/>
|
||||||
<xs:element name="company-footer">
|
<xs:element name="company-footer">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
|
@@ -3,6 +3,7 @@
|
|||||||
xmlns:alfresco="http://www.alfresco.org/alfresco"
|
xmlns:alfresco="http://www.alfresco.org/alfresco"
|
||||||
targetNamespace="http://www.alfresco.org/alfresco"
|
targetNamespace="http://www.alfresco.org/alfresco"
|
||||||
elementFormDefault="qualified">
|
elementFormDefault="qualified">
|
||||||
|
<xs:include schemaLocation="/media/releases/get_company_footer_simple_type.jsp"/>
|
||||||
<xs:simpleType name="category">
|
<xs:simpleType name="category">
|
||||||
<xs:restriction base="xs:string">
|
<xs:restriction base="xs:string">
|
||||||
<xs:enumeration value="Product"/>
|
<xs:enumeration value="Product"/>
|
||||||
@@ -12,22 +13,6 @@
|
|||||||
<xs:enumeration value="Training"/>
|
<xs:enumeration value="Training"/>
|
||||||
</xs:restriction>
|
</xs:restriction>
|
||||||
</xs:simpleType>
|
</xs:simpleType>
|
||||||
<xs:simpleType name="company-footer">
|
|
||||||
<xs:restriction base="xs:string">
|
|
||||||
<xs:enumeration value="Activiti"/>
|
|
||||||
<xs:enumeration value="Alfresco"/>
|
|
||||||
<xs:enumeration value="Kofax"/>
|
|
||||||
<xs:enumeration value="Aarden Ringcroft"/>
|
|
||||||
<xs:enumeration value="PreVisor"/>
|
|
||||||
<xs:enumeration value="FileMark"/>
|
|
||||||
<xs:enumeration value="Red Herring"/>
|
|
||||||
<xs:enumeration value="Rivet Logic Corp."/>
|
|
||||||
<xs:enumeration value="Mayfield Fund"/>
|
|
||||||
<xs:enumeration value="Accel Partners"/>
|
|
||||||
<xs:enumeration value="BitRock"/>
|
|
||||||
<xs:enumeration value="aegif"/>
|
|
||||||
</xs:restriction>
|
|
||||||
</xs:simpleType>
|
|
||||||
<xs:element name="press-release">
|
<xs:element name="press-release">
|
||||||
<xs:complexType>
|
<xs:complexType>
|
||||||
<xs:sequence>
|
<xs:sequence>
|
||||||
|
@@ -87,9 +87,8 @@
|
|||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
<xsl:for-each select="/alfresco:press-release/alfresco:include_company_footer">
|
<xsl:for-each select="/alfresco:press-release/alfresco:include_company_footer">
|
||||||
<xsl:variable name="cf-id"><xsl:value-of select="."/></xsl:variable>
|
<xsl:variable name="cf-id"><xsl:value-of select="."/></xsl:variable>
|
||||||
<xsl:variable name="cf-url"><xsl:value-of select="concat('/media/releases/content/company_footers/', concat($cf-id, '.xml'))"/></xsl:variable>
|
<h2>About <xsl:value-of select="document($cf-id)/alfresco:company-footer/alfresco:name"/></h2>
|
||||||
<h2>About <xsl:value-of select="document($cf-url)/alfresco:company-footer/alfresco:name"/></h2>
|
<xsl:for-each select="document($cf-id)/alfresco:company-footer/alfresco:body">
|
||||||
<xsl:for-each select="document($cf-url)/alfresco:company-footer/alfresco:body">
|
|
||||||
<p><xsl:value-of select="." disable-output-escaping="yes"/></p>
|
<p><xsl:value-of select="." disable-output-escaping="yes"/></p>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
</xsl:for-each>
|
</xsl:for-each>
|
||||||
|
@@ -2545,8 +2545,7 @@
|
|||||||
Bean that returns information on a node
|
Bean that returns information on a node
|
||||||
</description>
|
</description>
|
||||||
<managed-bean-name>XFormsBean</managed-bean-name>
|
<managed-bean-name>XFormsBean</managed-bean-name>
|
||||||
<managed-bean-class>org.alfresco.web.bean.ajax.XFormsBean</managed-bean-class>
|
<managed-bean-class>org.alfresco.web.templating.xforms.XFormsBean</managed-bean-class>
|
||||||
<managed-bean-scope>session</managed-bean-scope>
|
<managed-bean-scope>session</managed-bean-scope>
|
||||||
</managed-bean>
|
</managed-bean>
|
||||||
|
|
||||||
</faces-config>
|
</faces-config>
|
||||||
|
@@ -18,6 +18,7 @@
|
|||||||
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
|
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
|
||||||
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
<%@ taglib uri="/WEB-INF/alfresco.tld" prefix="a" %>
|
||||||
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
<%@ taglib uri="/WEB-INF/repo.tld" prefix="r" %>
|
||||||
|
<%@ page import="org.alfresco.web.bean.wcm.AVMConstants" %>
|
||||||
<%@ page import="org.alfresco.web.app.Application" %>
|
<%@ page import="org.alfresco.web.app.Application" %>
|
||||||
<%@ page import="org.alfresco.web.templating.*" %>
|
<%@ page import="org.alfresco.web.templating.*" %>
|
||||||
<%@ page import="org.alfresco.web.bean.wcm.CreateWebContentWizard" %>
|
<%@ page import="org.alfresco.web.bean.wcm.CreateWebContentWizard" %>
|
||||||
@@ -57,25 +58,4 @@ dojo.addOnLoad(function()
|
|||||||
addSubmitHandlerToButton(document.getElementById("wizard:next-button"));
|
addSubmitHandlerToButton(document.getElementById("wizard:next-button"));
|
||||||
addSubmitHandlerToButton(document.getElementById("wizard:finish-button"));
|
addSubmitHandlerToButton(document.getElementById("wizard:finish-button"));
|
||||||
});
|
});
|
||||||
//
|
|
||||||
//var baseOnClick = b.onclick;
|
|
||||||
//b.onclick = function()
|
|
||||||
//{
|
|
||||||
// if (!document.submitTrigger.done)
|
|
||||||
// {
|
|
||||||
// document.submitTrigger.buttonClick();
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return baseOnClick();
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
//});
|
|
||||||
//function doSubmit()
|
|
||||||
//{
|
|
||||||
//var b = document.getElementById("wizard:next-button");
|
|
||||||
//b.click();
|
|
||||||
//}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user