mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
first pass on repeats.
- refactoring of schemaformbuilder to remove unnecessary methods/cleanup and modifications to get it to emit triggers that i need for insert at the top and insert after - implementation of ajax server side method for setting the repeat index and support for capturing and sending back event responses for all server requests. - implementation of client side repeat support: dom manipulation of repeat elements, identifying and relating widgets with model data, creating prototype clones, and support for some XFormsEvent (chiba-index-changed, chiba-item-inserted, chiba-prototype-cloned, chiba-id-generated) - changing background-colour to background-color in the dashlet. funny. - handling a null pointer exception in the errorbean when an error is thrown from the ajax stuff. - minor debugging enhancements in TemplatingService git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3814 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -123,7 +123,8 @@ public class ErrorBean
|
||||
{
|
||||
StringWriter stringWriter = new StringWriter();
|
||||
PrintWriter writer = new PrintWriter(stringWriter);
|
||||
this.lastError.printStackTrace(writer);
|
||||
if (this.lastError != null)
|
||||
this.lastError.printStackTrace(writer);
|
||||
|
||||
// format the message for HTML display
|
||||
String trace = stringWriter.toString();
|
||||
|
@@ -20,6 +20,7 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.util.Map;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import javax.faces.context.FacesContext;
|
||||
import javax.faces.context.ResponseWriter;
|
||||
@@ -36,7 +37,10 @@ import org.w3c.dom.Node;
|
||||
import org.alfresco.web.app.servlet.FacesHelper;
|
||||
import org.chiba.xml.xforms.ChibaBean;
|
||||
import org.chiba.xml.xforms.exception.XFormsException;
|
||||
import org.chiba.xml.xforms.events.XFormsEvent;
|
||||
import org.chiba.xml.xforms.events.XFormsEventFactory;
|
||||
|
||||
import org.w3c.dom.*;
|
||||
import org.w3c.dom.events.Event;
|
||||
import org.w3c.dom.events.EventListener;
|
||||
import org.w3c.dom.events.EventTarget;
|
||||
@@ -47,13 +51,13 @@ import org.chiba.xml.xforms.connector.http.AbstractHTTPConnector;
|
||||
* Manages the chiba bean lifecycle.
|
||||
*/
|
||||
public class XFormsBean
|
||||
implements EventListener
|
||||
{
|
||||
private static final Log LOGGER = LogFactory.getLog(XFormsBean.class);
|
||||
|
||||
private TemplateType tt;
|
||||
private InstanceData instanceData = null;
|
||||
private ChibaBean chibaBean;
|
||||
private final LinkedList<XFormsEvent> eventLog = new LinkedList<XFormsEvent>();
|
||||
|
||||
/** @return the template type */
|
||||
public TemplateType getTemplateType()
|
||||
@@ -95,12 +99,33 @@ public class XFormsBean
|
||||
tt.getInputMethods().get(0);
|
||||
final Document form = tim.getXForm(instanceData.getContent(), tt);
|
||||
this.chibaBean.setXMLContainer(form);
|
||||
this.chibaBean.init();
|
||||
EventTarget et = (EventTarget)
|
||||
|
||||
final EventTarget et = (EventTarget)
|
||||
this.chibaBean.getXMLContainer().getDocumentElement();
|
||||
//XXXarielb register more listener for to do validation and do something
|
||||
//with the results.
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_ERROR, this, true);
|
||||
final EventListener el = new EventListener()
|
||||
{
|
||||
public void handleEvent(Event e)
|
||||
{
|
||||
XFormsBean.LOGGER.debug("received event " + e);
|
||||
XFormsBean.this.eventLog.add((XFormsEvent)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);
|
||||
|
||||
this.chibaBean.init();
|
||||
|
||||
// register for notification events
|
||||
et.addEventListener(XFormsEventFactory.SUBMIT_ERROR, 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)
|
||||
{
|
||||
@@ -143,8 +168,34 @@ public class XFormsBean
|
||||
|
||||
LOGGER.debug(this + " setXFormsValue(" + id + ", " + value + ")");
|
||||
this.chibaBean.updateControlValue(id, value);
|
||||
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
out.write("<todo/>");
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* sets the value of a control in the processor.
|
||||
*
|
||||
* @param id the id of the control in the host document
|
||||
* @param value the new value
|
||||
* @return the list of events that may result through this action
|
||||
*/
|
||||
public void setRepeatIndex()
|
||||
throws XFormsException, IOException
|
||||
{
|
||||
final FacesContext context = FacesContext.getCurrentInstance();
|
||||
final Map requestParameters = context.getExternalContext().getRequestParameterMap();
|
||||
final String id = (String)requestParameters.get("id");
|
||||
final int index = Integer.parseInt((String)requestParameters.get("index"));
|
||||
|
||||
LOGGER.debug(this + " setRepeatIndex(" + id + ", " + index + ")");
|
||||
this.chibaBean.updateRepeatIndex(id, index);
|
||||
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
@@ -162,8 +213,10 @@ public class XFormsBean
|
||||
|
||||
LOGGER.debug(this + " fireAction(" + id + ")");
|
||||
this.chibaBean.dispatch(id, XFormsEventFactory.DOM_ACTIVATE);
|
||||
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
out.write("<todo/>");
|
||||
ts.writeXML(this.getEventLog(), out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
@@ -180,15 +233,38 @@ public class XFormsBean
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final Document result = ts.parseXML(request.getInputStream());
|
||||
this.instanceData.setContent(result);
|
||||
|
||||
final ResponseWriter out = context.getResponseWriter();
|
||||
ts.writeXML(result, out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
//XXXarielb placeholder for error handling
|
||||
public void handleEvent(Event e)
|
||||
private Node getEventLog()
|
||||
{
|
||||
LOGGER.debug("handleEvent " + e);
|
||||
final TemplatingService ts = TemplatingService.getInstance();
|
||||
final Document result = ts.newDocument();
|
||||
final Element eventsElement = result.createElement("events");
|
||||
result.appendChild(eventsElement);
|
||||
for (XFormsEvent xfe : this.eventLog)
|
||||
{
|
||||
final String type = xfe.getType();
|
||||
final Element target = (Element)xfe.getTarget();
|
||||
|
||||
final Element eventElement = result.createElement(type);
|
||||
eventsElement.appendChild(eventElement);
|
||||
eventElement.setAttribute("targetId", target.getAttributeNS(null, "id"));
|
||||
eventElement.setAttribute("targetName", target.getLocalName());
|
||||
|
||||
for (Object name : xfe.getPropertyNames())
|
||||
{
|
||||
final Element propertyElement = result.createElement((String)name);
|
||||
eventElement.appendChild(propertyElement);
|
||||
final String value = xfe.getContextInfo((String)name).toString();
|
||||
propertyElement.appendChild(result.createTextNode(value));
|
||||
}
|
||||
}
|
||||
this.eventLog.clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -308,16 +308,27 @@ public final class TemplatingService
|
||||
{
|
||||
try
|
||||
{
|
||||
System.out.println("writing out a document for " + n.getNodeName() +
|
||||
" to " + output);
|
||||
final TransformerFactory tf = TransformerFactory.newInstance();
|
||||
final Transformer t = tf.newTransformer();
|
||||
t.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||
|
||||
if (LOGGER.isDebugEnabled())
|
||||
{
|
||||
LOGGER.debug("writing out a document for " +
|
||||
(n instanceof Document
|
||||
? ((Document)n).getDocumentElement()
|
||||
: n).getNodeName() +
|
||||
" to " + output);
|
||||
final StringWriter sw = new StringWriter();
|
||||
t.transform(new DOMSource(n), new StreamResult(sw));
|
||||
LOGGER.debug(sw.toString());
|
||||
}
|
||||
t.transform(new DOMSource(n), new StreamResult(output));
|
||||
}
|
||||
catch (TransformerException te)
|
||||
{
|
||||
te.printStackTrace();
|
||||
assert false : te.getMessage();
|
||||
assert false : te.getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -145,6 +145,8 @@ public class XFormsInputMethod
|
||||
true);
|
||||
LOGGER.debug("building xform for schema " + tt.getName());
|
||||
final Document result = builder.buildForm(tt); //schemaFile.getPath());
|
||||
LOGGER.debug("generated xform:");
|
||||
LOGGER.debug(ts.writeXMLToString(result));
|
||||
// xmlContentFile.delete();
|
||||
// schemaFile.delete();
|
||||
return result;
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -167,15 +167,17 @@ public class BaseSchemaFormBuilder
|
||||
public Element createControlForAnyType(Document xForm,
|
||||
String caption,
|
||||
XSTypeDefinition controlType) {
|
||||
Element control = xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "textarea");
|
||||
Element control = xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "textarea");
|
||||
this.setXFormsId(control);
|
||||
control.setAttributeNS(CHIBA_NS, getChibaNSPrefix() + "height", "3");
|
||||
control.setAttributeNS(SchemaFormBuilder.CHIBA_NS,
|
||||
SchemaFormBuilder.CHIBA_NS_PREFIX + "height",
|
||||
"3");
|
||||
|
||||
//label
|
||||
Element captionElement = (Element)
|
||||
control.appendChild(xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "label"));
|
||||
control.appendChild(xForm.createElementNS(SchemaFormBuilder.XFORMS_NS,
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label"));
|
||||
this.setXFormsId(captionElement);
|
||||
captionElement.appendChild(xForm.createTextNode(caption));
|
||||
|
||||
@@ -199,24 +201,24 @@ public class BaseSchemaFormBuilder
|
||||
if ("boolean".equals(controlType.getName()))
|
||||
{
|
||||
control = xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "select1");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "select1");
|
||||
control.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "appearance",
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
||||
"full");
|
||||
this.setXFormsId(control);
|
||||
|
||||
Element item_true =
|
||||
xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
|
||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "item");
|
||||
this.setXFormsId(item_true);
|
||||
Element label_true =
|
||||
xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
|
||||
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, getXFormsNSPrefix() + "value");
|
||||
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);
|
||||
@@ -224,17 +226,17 @@ public class BaseSchemaFormBuilder
|
||||
control.appendChild(item_true);
|
||||
|
||||
Element item_false =
|
||||
xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "item");
|
||||
xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "item");
|
||||
this.setXFormsId(item_false);
|
||||
Element label_false =
|
||||
xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "label");
|
||||
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, getXFormsNSPrefix() + "value");
|
||||
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);
|
||||
@@ -243,14 +245,14 @@ public class BaseSchemaFormBuilder
|
||||
}
|
||||
else
|
||||
{
|
||||
control = xForm.createElementNS(XFORMS_NS, getXFormsNSPrefix() + "input");
|
||||
control = xForm.createElementNS(XFORMS_NS, SchemaFormBuilder.XFORMS_NS_PREFIX + "input");
|
||||
this.setXFormsId(control);
|
||||
}
|
||||
|
||||
//label
|
||||
Element captionElement = (Element)
|
||||
control.appendChild(xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "label"));
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label"));
|
||||
this.setXFormsId(captionElement);
|
||||
captionElement.appendChild(xForm.createTextNode(caption));
|
||||
|
||||
@@ -283,18 +285,18 @@ public class BaseSchemaFormBuilder
|
||||
Vector enumValues = new Vector();
|
||||
|
||||
Element control = xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "select1");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "select1");
|
||||
this.setXFormsId(control);
|
||||
|
||||
//label
|
||||
Element captionElement1 = (Element)
|
||||
control.appendChild(xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "label"));
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label"));
|
||||
this.setXFormsId(captionElement1);
|
||||
captionElement1.appendChild(xForm.createTextNode(caption));
|
||||
|
||||
Element choices = xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "choices");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "choices");
|
||||
this.setXFormsId(choices);
|
||||
|
||||
for (int i = 0; i < nbFacets; i++) {
|
||||
@@ -304,11 +306,11 @@ public class BaseSchemaFormBuilder
|
||||
|
||||
if (nbFacets < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))) {
|
||||
control.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "appearance",
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
||||
getProperty(SELECTONE_UI_CONTROL_SHORT_PROP));
|
||||
} else {
|
||||
control.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "appearance",
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
||||
getProperty(SELECTONE_UI_CONTROL_LONG_PROP));
|
||||
|
||||
// add the "Please select..." instruction item for the combobox
|
||||
@@ -318,20 +320,20 @@ public class BaseSchemaFormBuilder
|
||||
{
|
||||
String pleaseSelect = "[Select1 " + caption + "]";
|
||||
Element item = xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "item");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "item");
|
||||
this.setXFormsId(item);
|
||||
choices.appendChild(item);
|
||||
|
||||
Element captionElement =
|
||||
xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "label");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label");
|
||||
this.setXFormsId(captionElement);
|
||||
item.appendChild(captionElement);
|
||||
captionElement.appendChild(xForm.createTextNode(pleaseSelect));
|
||||
|
||||
Element value =
|
||||
xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "value");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "value");
|
||||
this.setXFormsId(value);
|
||||
item.appendChild(value);
|
||||
value.appendChild(xForm.createTextNode(pleaseSelect));
|
||||
@@ -344,13 +346,13 @@ public class BaseSchemaFormBuilder
|
||||
//check if there was a constraint
|
||||
String constraint = bindElement.getAttributeNS(XFORMS_NS, "constraint");
|
||||
|
||||
constraint = ((constraint != null && constraint.length() != 0)
|
||||
? constraint + " and " + isValidExpr
|
||||
: isValidExpr);
|
||||
constraint = (constraint != null && constraint.length() != 0
|
||||
? constraint + " and " + isValidExpr
|
||||
: isValidExpr);
|
||||
|
||||
bindElement.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "constraint",
|
||||
constraint);
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "constraint",
|
||||
constraint);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -381,13 +383,13 @@ public class BaseSchemaFormBuilder
|
||||
if (nbFacets <= 0)
|
||||
return null;
|
||||
Element control = xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "select");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "select");
|
||||
this.setXFormsId(control);
|
||||
|
||||
//label
|
||||
Element captionElement = (Element)
|
||||
control.appendChild(xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "label"));
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "label"));
|
||||
this.setXFormsId(captionElement);
|
||||
captionElement.appendChild(xForm.createTextNode(caption));
|
||||
|
||||
@@ -402,24 +404,26 @@ public class BaseSchemaFormBuilder
|
||||
//
|
||||
// For now, use checkbox if there are < DEFAULT_LONG_LIST_MAX_SIZE items, otherwise use long control
|
||||
//
|
||||
if (enumValues.size()
|
||||
< Long.parseLong(getProperty(SELECTMANY_LONG_LIST_SIZE_PROP))) {
|
||||
if (enumValues.size() < Long.parseLong(getProperty(SELECTMANY_LONG_LIST_SIZE_PROP)))
|
||||
{
|
||||
control.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "appearance",
|
||||
getProperty(SELECTMANY_UI_CONTROL_SHORT_PROP));
|
||||
} else {
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
||||
getProperty(SELECTMANY_UI_CONTROL_SHORT_PROP));
|
||||
}
|
||||
else
|
||||
{
|
||||
control.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "appearance",
|
||||
getProperty(SELECTMANY_UI_CONTROL_LONG_PROP));
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "appearance",
|
||||
getProperty(SELECTMANY_UI_CONTROL_LONG_PROP));
|
||||
}
|
||||
|
||||
Element choices =
|
||||
xForm.createElementNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "choices");
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "choices");
|
||||
this.setXFormsId(choices);
|
||||
control.appendChild(choices);
|
||||
|
||||
addChoicesForSelectControl(xForm, choices, enumValues);
|
||||
this.addChoicesForSelectControl(xForm, choices, enumValues);
|
||||
|
||||
return control;
|
||||
}
|
||||
@@ -431,7 +435,8 @@ public class BaseSchemaFormBuilder
|
||||
* @param node __UNDOCUMENTED__
|
||||
* @return __UNDOCUMENTED__
|
||||
*/
|
||||
public Element createHint(Document xForm, XSObject node) {
|
||||
public Element createHint(Document xForm, XSObject node)
|
||||
{
|
||||
XSAnnotation annotation = null;
|
||||
if (node instanceof XSElementDeclaration)
|
||||
annotation = ((XSElementDeclaration) node).getAnnotation();
|
||||
@@ -441,10 +446,9 @@ public class BaseSchemaFormBuilder
|
||||
annotation =
|
||||
((XSAttributeUse) node).getAttrDeclaration().getAnnotation();
|
||||
|
||||
if (annotation != null)
|
||||
return addHintFromDocumentation(xForm, annotation);
|
||||
else
|
||||
return null;
|
||||
return (annotation != null
|
||||
? addHintFromDocumentation(xForm, annotation)
|
||||
: null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -452,8 +456,8 @@ public class BaseSchemaFormBuilder
|
||||
*
|
||||
* @param bindElement __UNDOCUMENTED__
|
||||
*/
|
||||
public void endBindElement(Element bindElement) {
|
||||
return;
|
||||
public void endBindElement(Element bindElement)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -506,12 +510,12 @@ public class BaseSchemaFormBuilder
|
||||
String typeName = this.getXFormsTypeName(enveloppe, controlType);
|
||||
if (typeName != null && typeName.length() != 0)
|
||||
bindElement.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "type",
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "type",
|
||||
typeName);
|
||||
}
|
||||
|
||||
bindElement.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "required",
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "required",
|
||||
o.minimum == 0 ? "false()" : "true()");
|
||||
|
||||
|
||||
@@ -528,19 +532,14 @@ public class BaseSchemaFormBuilder
|
||||
//if 1 or unbounded -> no constraint
|
||||
maxConstraint = "count(.) <= " + o.maximum;
|
||||
|
||||
String constraint = null;
|
||||
|
||||
if ((minConstraint != null) && (maxConstraint != null)) {
|
||||
constraint = minConstraint + " and " + maxConstraint;
|
||||
} else if (minConstraint != null) {
|
||||
constraint = minConstraint;
|
||||
} else {
|
||||
constraint = maxConstraint;
|
||||
}
|
||||
|
||||
final String constraint = (minConstraint != null && maxConstraint != null
|
||||
? minConstraint + " and " + maxConstraint
|
||||
: (minConstraint != null
|
||||
? minConstraint
|
||||
: maxConstraint));
|
||||
if (constraint != null && constraint.length() != 0)
|
||||
bindElement.setAttributeNS(XFORMS_NS,
|
||||
getXFormsNSPrefix() + "constraint",
|
||||
SchemaFormBuilder.XFORMS_NS_PREFIX + "constraint",
|
||||
constraint);
|
||||
return bindElement;
|
||||
}
|
||||
@@ -553,7 +552,8 @@ public class BaseSchemaFormBuilder
|
||||
* @return __UNDOCUMENTED__
|
||||
*/
|
||||
public Element startFormControl(Element controlElement,
|
||||
XSTypeDefinition controlType) {
|
||||
XSTypeDefinition controlType)
|
||||
{
|
||||
return controlElement;
|
||||
}
|
||||
|
||||
@@ -565,7 +565,8 @@ public class BaseSchemaFormBuilder
|
||||
* @return __UNDOCUMENTED__
|
||||
*/
|
||||
public Element startFormGroup(Element groupElement,
|
||||
XSElementDeclaration schemaElement) {
|
||||
XSElementDeclaration schemaElement)
|
||||
{
|
||||
//groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "box-align",getProperty(GROUP_BOX_ALIGN_PROP));
|
||||
//groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "box-orient",getProperty(GROUP_BOX_ORIENT_PROP));
|
||||
//groupElement.setAttributeNS(CHIBA_NS,getChibaNSPrefix() + "caption-width",getProperty(GROUP_CAPTION_WIDTH_PROP));
|
||||
|
@@ -1,93 +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.w3c.dom.Document;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
/**
|
||||
* Basic implementation of WrapperElementsBuilder, with no additional design
|
||||
*
|
||||
* @author - Sophie Ramel
|
||||
*/
|
||||
public class BaseWrapperElementsBuilder implements WrapperElementsBuilder {
|
||||
/**
|
||||
* Creates a new instance of BaseWrapperElementsBuilder
|
||||
*/
|
||||
public BaseWrapperElementsBuilder() {
|
||||
}
|
||||
|
||||
/**
|
||||
* create the wrapper element of the different controls
|
||||
*
|
||||
* @param controlElement the control element (input, select, repeat, group, ...)
|
||||
* @return the wrapper element, already containing the control element
|
||||
*/
|
||||
public Element createControlsWrapper(Element controlElement) {
|
||||
return controlElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* creates the global enveloppe of the resulting document, and puts it in the document
|
||||
*
|
||||
* @return the enveloppe
|
||||
*/
|
||||
public Element createEnvelope(Document xForm) {
|
||||
Element envelopeElement = xForm.createElement("envelope");
|
||||
|
||||
//Element envelopeElement = xForm.createElementNS(CHIBA_NS, this.getChibaNSPrefix()+"envelope");
|
||||
xForm.appendChild(envelopeElement);
|
||||
|
||||
return envelopeElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* create the wrapper element of the form
|
||||
*
|
||||
* @param enveloppeElement the form element (chiba:form or other)
|
||||
* @return the wrapper element
|
||||
*/
|
||||
|
||||
public Element createFormWrapper(Element enveloppeElement) {
|
||||
//add a "body" element without NS
|
||||
Document doc = enveloppeElement.getOwnerDocument();
|
||||
Element body = doc.createElement("body");
|
||||
//body.appendChild(formElement);
|
||||
enveloppeElement.appendChild(body);
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* create the element that will contain the content of the group (or repeat) element
|
||||
*
|
||||
* @param groupElement the group or repeat element
|
||||
* @return the wrapper element, already containing the content of the group element
|
||||
*/
|
||||
public Element createGroupContentWrapper(Element groupElement) {
|
||||
return groupElement;
|
||||
}
|
||||
|
||||
/**
|
||||
* create the wrapper element of the xforms:model element
|
||||
*
|
||||
* @param modelElement the xforms:model element
|
||||
* @return the wrapper element, already containing the model
|
||||
*/
|
||||
public Element createModelWrapper(Element modelElement) {
|
||||
return modelElement;
|
||||
}
|
||||
}
|
@@ -92,9 +92,14 @@ public interface SchemaFormBuilder
|
||||
/**
|
||||
* XMLSchema Instance Namespace declaration
|
||||
*/
|
||||
public static final String XMLSCHEMA_INSTANCE_NAMESPACE_URI =
|
||||
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.
|
||||
*/
|
||||
@@ -110,7 +115,13 @@ public interface SchemaFormBuilder
|
||||
/**
|
||||
* XForms namespace declaration.
|
||||
*/
|
||||
public static final String XFORMS_NS = "http://www.w3.org/2002/xforms";
|
||||
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.
|
||||
@@ -118,40 +129,30 @@ public interface SchemaFormBuilder
|
||||
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";
|
||||
|
||||
/**
|
||||
* Chiba prefix
|
||||
*/
|
||||
public static final String chibaNSPrefix = "chiba:";
|
||||
|
||||
/**
|
||||
* XForms prefix
|
||||
*/
|
||||
public static final String xformsNSPrefix = "xforms:";
|
||||
|
||||
/**
|
||||
* Xlink prefix
|
||||
*/
|
||||
public static final String xlinkNSPrefix = "xlink:";
|
||||
|
||||
/**
|
||||
* XMLSchema instance prefix *
|
||||
*/
|
||||
public static final String xmlSchemaInstancePrefix = "xsi:";
|
||||
|
||||
/**
|
||||
* XML Events prefix
|
||||
*/
|
||||
public static final String xmleventsNSPrefix = "ev:";
|
||||
public static final String XMLEVENTS_NS_PREFIX = "ev:";
|
||||
|
||||
/**
|
||||
* Prossible values of the "@method" on the "submission" element
|
||||
|
Reference in New Issue
Block a user