support for specifying appearance for select and select1 from the schema.

handling the case where create web content is called with no forms configured for the web project

some more progress on xf:switch

updated tests - including one from ken at berkeley who is trying to use forms to write grant applications.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4925 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2007-01-25 00:39:30 +00:00
parent bd25cfa86f
commit 1c966e9a71
10 changed files with 1227 additions and 614 deletions

View File

@@ -84,6 +84,7 @@ public class CreateWebContentWizard extends BaseContentWizard
protected String content = null;
protected String formName;
protected transient List<SelectItem> createMimeTypes;
protected transient List<SelectItem> formChoices;
protected String createdPath = null;
protected List<Rendition> renditions = null;
protected FormInstanceData formInstanceData = null;
@@ -171,6 +172,8 @@ public class CreateWebContentWizard extends BaseContentWizard
this.renditions = null;
this.startWorkflow = false;
this.formSelectDisabled = false;
this.createMimeTypes = null;
this.formChoices = null;
// check for a form ID being passed in as a parameter
if (this.parameters.get(UIUserSandboxes.PARAM_FORM_NAME) != null)
@@ -522,18 +525,21 @@ public class CreateWebContentWizard extends BaseContentWizard
* @return the available forms from this web project that can be created.
*/
public List<SelectItem> getFormChoices()
{
if (this.formChoices == null)
{
final List<Form> forms = this.avmBrowseBean.getWebProject().getForms();
final List<SelectItem> items = new ArrayList<SelectItem>(forms.size());
this.formChoices = new ArrayList<SelectItem>(forms.size());
for (final Form f : forms)
{
items.add(new SelectItem(f.getName(), f.getTitle()));
this.formChoices.add(new SelectItem(f.getName(), f.getTitle()));
}
final QuickSort sorter = new QuickSort(items, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
final QuickSort sorter = new QuickSort(this.formChoices, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
return items;
}
return this.formChoices;
}
/**
@@ -543,21 +549,21 @@ public class CreateWebContentWizard extends BaseContentWizard
{
if (this.createMimeTypes == null)
{
FacesContext context = FacesContext.getCurrentInstance();
final FacesContext context = FacesContext.getCurrentInstance();
// add the well known object type to start with
this.createMimeTypes = new ArrayList<SelectItem>(5);
// add the configured create mime types to the list
ConfigService svc = Application.getConfigService(context);
Config wizardCfg = svc.getConfig("Content Wizards");
final ConfigService svc = Application.getConfigService(context);
final Config wizardCfg = svc.getConfig("Content Wizards");
if (wizardCfg == null)
{
LOGGER.warn("Could not find 'Content Wizards' configuration section");
}
else
{
ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
final ConfigElement typesCfg = wizardCfg.getConfigElement("create-mime-types");
if (typesCfg == null)
{
LOGGER.warn("Could not find 'create-mime-types' configuration element");
@@ -566,16 +572,20 @@ public class CreateWebContentWizard extends BaseContentWizard
{
for (ConfigElement child : typesCfg.getChildren())
{
String currentMimeType = child.getAttribute("name");
if (currentMimeType != null)
final String currentMimeType = child.getAttribute("name");
if (currentMimeType == null ||
(MimetypeMap.MIMETYPE_XML.equals(currentMimeType) &&
this.getFormChoices().size() == 0))
{
String label = getSummaryMimeType(currentMimeType);
this.createMimeTypes.add(new SelectItem(currentMimeType, label));
continue;
}
final String label = this.getSummaryMimeType(currentMimeType);
this.createMimeTypes.add(new SelectItem(currentMimeType, label));
}
// make sure the list is sorted by the label
QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
final QuickSort sorter = new QuickSort(this.objectTypes, "label", true, IDataContainer.SORT_CASEINSENSITIVE);
sorter.sort();
}
}

View File

@@ -34,6 +34,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;
/**
@@ -175,4 +176,41 @@ public class XMLUtil
return null;
}
}
/**
* Provides a NodeList of multiple nodelists
*/
public static NodeList combine(final NodeList... nls)
{
return new NodeList()
{
public Node item(final int index)
{
int offset = 0;
for (int i = 0; i < nls.length; i++)
{
if (index - offset < nls[i].getLength())
{
return nls[i].item(index - offset);
}
else
{
offset += nls[i].getLength();
}
}
return null;
}
public int getLength()
{
int result = 0;
for (int i = 0; i < nls.length; i++)
{
result += nls[i].getLength();
}
return result;
}
};
}
}

View File

@@ -73,65 +73,7 @@ public class Schema2XForms
private final static Log LOGGER = LogFactory.getLog(Schema2XForms.class);
private static final String PROPERTY_PREFIX =
"http://www.chiba.org/properties/schemaFormBuilder/";
/**
* Property to control the selection of UI control for a selectOne control.
* If a selectOne control has >= the number of values specified in this property,
* it is considered a <b>long</b> list, and the UI control specified by
* SELECTONE_UI_CONTROL_LONG_PROP is used. Otherwise, the value of SELECTONE_UI_CONTROL_SHORT_PROP
* is used.
*/
public static final String SELECTONE_LONG_LIST_SIZE_PROP =
PROPERTY_PREFIX + "select1@longListSize";
/**
* Property to specify the selectMany UI control to be used when there are releatively few items
* to choose from.
*/
public static final String SELECTONE_UI_CONTROL_SHORT_PROP =
PROPERTY_PREFIX + "select1@appearance/short";
/**
* Property to specify the selectMany UI control to be used when there are large numbers of items
* to choose from.
*/
public static final String SELECTONE_UI_CONTROL_LONG_PROP =
PROPERTY_PREFIX + "select1@appearance/long";
private static final String DEFAULT_SELECTONE_UI_CONTROL_SHORT_PROP =
"full";
private static final String DEFAULT_SELECTONE_UI_CONTROL_LONG_PROP =
"minimal";
/**
* Property to control the selection of UI control for a selectMany control.
* If a selectMany control has >= the number of values specified in this property,
* it is considered a <b>long</b> list, and the UI control specified by
* SELECTMANY_UI_CONTROL_LONG_PROP is used. Otherwise, the value of SELECTMANY_UI_CONTROL_SHORT_PROP
* is used.
*/
public static final String SELECTMANY_LONG_LIST_SIZE_PROP =
PROPERTY_PREFIX + "select@longListSize";
/**
* Property to specify the selectMany UI control to be used when there are releatively few items
* to choose from.
*/
public static final String SELECTMANY_UI_CONTROL_SHORT_PROP =
PROPERTY_PREFIX + "select@appearance/short";
/**
* Property to specify the selectMany UI control to be used when there are large numbers of items
* to choose from.
*/
public static final String SELECTMANY_UI_CONTROL_LONG_PROP =
PROPERTY_PREFIX + "select@appearance/long";
private static final String DEFAULT_SELECTMANY_UI_CONTROL_SHORT_PROP =
"full";
private static final String DEFAULT_SELECTMANY_UI_CONTROL_LONG_PROP =
"compact";
private static final String DEFAULT_LONG_LIST_MAX_SIZE = "6";
private final static int LONG_LIST_SIZE = 5;
private final String action;
private final SubmitMethod submitMethod;
@@ -143,7 +85,6 @@ public class Schema2XForms
* values: "Long" representing the counter for this element
*/
private final Map<String, Long> counter = new HashMap<String, Long>();
private final Properties properties = new Properties();
private String targetNamespace;
private final Map namespacePrefixes = new HashMap();
@@ -174,50 +115,6 @@ public class Schema2XForms
this.base = base;
}
/**
* Get the current set of properties used by implementations of Schema2XForms.
*
* @return The list of properties.
*/
public Properties getProperties()
{
return properties;
}
/**
* 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)
{
getProperties().setProperty(key, 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)
{
return getProperties().getProperty(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)
{
return getProperties().getProperty(key, defaultValue);
}
/**
* Generate the XForm based on a user supplied XML Schema.
*
@@ -373,16 +270,6 @@ public class Schema2XForms
public void reset()
{
this.counter.clear();
setProperty(SELECTMANY_LONG_LIST_SIZE_PROP, DEFAULT_LONG_LIST_MAX_SIZE);
setProperty(SELECTMANY_UI_CONTROL_SHORT_PROP,
DEFAULT_SELECTMANY_UI_CONTROL_SHORT_PROP);
setProperty(SELECTMANY_UI_CONTROL_LONG_PROP,
DEFAULT_SELECTMANY_UI_CONTROL_LONG_PROP);
setProperty(SELECTONE_LONG_LIST_SIZE_PROP, DEFAULT_LONG_LIST_MAX_SIZE);
setProperty(SELECTONE_UI_CONTROL_SHORT_PROP,
DEFAULT_SELECTONE_UI_CONTROL_SHORT_PROP);
setProperty(SELECTONE_UI_CONTROL_LONG_PROP,
DEFAULT_SELECTONE_UI_CONTROL_LONG_PROP);
}
private void insertPrototypeNodes(final Element instanceDocumentElement,
@@ -580,9 +467,10 @@ public class Schema2XForms
/**
*/
protected Map<String, Element> addChoicesForSelectSwitchControl(final Document xForm,
final Element choicesElement,
final List<XSTypeDefinition> choiceValues)
protected Map<String, Element> addChoicesForSelectSwitchControl(final Document xformsDocument,
final Element formSection,
final List<XSTypeDefinition> choiceValues,
final String typeBindId)
{
if (LOGGER.isDebugEnabled())
{
@@ -613,37 +501,32 @@ public class Schema2XForms
}
//build the case element
final Element caseElement = xForm.createElementNS(NamespaceConstants.XFORMS_NS,
final Element caseElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":case");
caseElement.appendChild(this.createLabel(xformsDocument, textValue));
final String caseId = this.setXFormsId(caseElement);
result.put(textValue, caseElement);
final Element item = this.createXFormsItem(xForm,
this.createCaption(textValue),
textValue);
choicesElement.appendChild(item);
/// action in the case
final Element action = xForm.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":action");
this.setXFormsId(action);
item.appendChild(action);
action.setAttributeNS(NamespaceConstants.XMLEVENTS_NS,
NamespaceConstants.XMLEVENTS_PREFIX + ":event",
"xforms-select");
final Element toggle = xForm.createElementNS(NamespaceConstants.XFORMS_NS,
final Element toggle = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":toggle");
this.setXFormsId(toggle);
toggle.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":case",
caseId);
//toggle.setAttributeNS(NamespaceConstants.XFORMS_NS,
//NamespaceConstants.XFORMS_PREFIX + ":case",bindIdPrefix + "_" + textValue +"_case");
action.appendChild(toggle);
final Element setValue = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":setvalue");
setValue.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":bind",
typeBindId);
setValue.appendChild(xformsDocument.createTextNode(textValue));
formSection.appendChild(this.createTrigger(xformsDocument,
null,
typeBindId,
"toggle to case " + caseId,
toggle,
setValue));
}
return result;
}
@@ -661,11 +544,15 @@ public class Schema2XForms
final NodeList d = doc.getElementsByTagNameNS(namespace, elementName);
if (d.getLength() == 0)
{
return null;
}
if (d.getLength() > 1)
LOGGER.warn("expect exactly one value for " + namespace +
{
LOGGER.warn("expected exactly one value for " + namespace +
":" + elementName +
". found " + d.getLength());
}
String result = DOMUtil.getTextNodeAsString(d.item(0));
LOGGER.debug(namespace + ":" + elementName + " = " + result);
if (result.startsWith("${") && result.endsWith("}") && resourceBundle != null)
@@ -685,7 +572,7 @@ public class Schema2XForms
return result;
}
private Element addAnyType(final Document xForm,
private Element addAnyType(final Document xformsDocument,
final Element modelSection,
final Element formSection,
final XSModel schema,
@@ -694,7 +581,7 @@ public class Schema2XForms
final String pathToRoot,
final ResourceBundle resourceBundle)
{
return this.addSimpleType(xForm,
return this.addSimpleType(xformsDocument,
modelSection,
formSection,
schema,
@@ -706,7 +593,7 @@ public class Schema2XForms
resourceBundle);
}
private void addAttributeSet(final Document xForm,
private void addAttributeSet(final Document xformsDocument,
final Element modelSection,
final Element defaultInstanceElement,
final Element formSection,
@@ -819,7 +706,7 @@ public class Schema2XForms
throw new FormBuilderException("error retrieving default value for attribute " +
attributeName + " at " + newPathToRoot, e);
}
this.addSimpleType(xForm,
this.addSimpleType(xformsDocument,
modelSection,
formSection,
schema,
@@ -831,7 +718,7 @@ public class Schema2XForms
}
}
private Element addComplexType(final Document xForm,
private Element addComplexType(final Document xformsDocument,
final Element modelSection,
final Element defaultInstanceElement,
final Element formSection,
@@ -861,13 +748,13 @@ public class Schema2XForms
}
// add a group node and recurse
final Element groupElement = this.createGroup(xForm,
final Element groupElement = this.createGroup(xformsDocument,
modelSection,
formSection,
owner,
resourceBundle);
final SchemaUtil.Occurance o = SchemaUtil.getOccurance(owner);
final Element repeatSection = this.addRepeatIfNecessary(xForm,
final Element repeatSection = this.addRepeatIfNecessary(xformsDocument,
modelSection,
groupElement,
controlType,
@@ -883,7 +770,7 @@ public class Schema2XForms
relative = true;
}
this.addComplexTypeChildren(xForm,
this.addComplexTypeChildren(xformsDocument,
modelSection,
defaultInstanceElement,
repeatSection,
@@ -897,7 +784,7 @@ public class Schema2XForms
return groupElement;
}
private void addComplexTypeChildren(final Document xForm,
private void addComplexTypeChildren(final Document xformsDocument,
Element modelSection,
final Element defaultInstanceElement,
final Element formSection,
@@ -937,7 +824,7 @@ public class Schema2XForms
{
if (base.getTypeCategory() == XSTypeDefinition.SIMPLE_TYPE)
{
this.addSimpleType(xForm,
this.addSimpleType(xformsDocument,
modelSection,
formSection,
schema,
@@ -973,7 +860,7 @@ public class Schema2XForms
}
//attributes
this.addAttributeSet(xForm,
this.addAttributeSet(xformsDocument,
modelSection,
defaultInstanceElement,
formSection,
@@ -1001,7 +888,7 @@ public class Schema2XForms
if (term instanceof XSModelGroup)
{
//call addGroup on this group
this.addGroup(xForm,
this.addGroup(xformsDocument,
modelSection,
defaultInstanceElement,
formSection,
@@ -1078,13 +965,15 @@ public class Schema2XForms
}
boolean relative = true;
String typeName = controlType.getName();
final String typeName = controlType.getName();
final boolean typeIsAbstract = ((XSComplexTypeDefinition)controlType).getAbstract();
final TreeSet<XSTypeDefinition> compatibleTypes =
typeName != null ? this.typeTree.get(controlType.getName()) : null;
typeName != null ? this.typeTree.get(typeName) : null;
if (compatibleTypes == null && typeName != null && LOGGER.isDebugEnabled())
{
LOGGER.debug("No compatible type found for " + typeName);
}
if (typeName != null && compatibleTypes != null)
{
relative = false;
@@ -1097,7 +986,7 @@ public class Schema2XForms
LOGGER.debug(" compatible type name=" + compType.getName());
}
}
final boolean typeIsAbstract = ((XSComplexTypeDefinition)controlType).getAbstract();
if (!typeIsAbstract && compatibleTypes.size() == 0)
{
relative = true;
@@ -1175,7 +1064,6 @@ public class Schema2XForms
true,
false,
resourceBundle);
}
private Element addElementWithMultipleCompatibleTypes(final Document xformsDocument,
@@ -1189,10 +1077,14 @@ public class Schema2XForms
final ResourceBundle resourceBundle)
throws FormBuilderException
{
LOGGER.debug("&&&&&&&&&&&&&&& path to root = " + pathToRoot);
// look for compatible types
final XSTypeDefinition controlType = elementDecl.getTypeDefinition();
defaultInstanceElement.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS,
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":type",
controlType.getName());
defaultInstanceElement.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS,
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":nil",
"true");
//get possible values
final List<XSTypeDefinition> enumValues = new LinkedList<XSTypeDefinition>();
@@ -1205,17 +1097,7 @@ public class Schema2XForms
//add compatible types
enumValues.addAll(compatibleTypes);
final Element control =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":select1");
final String select1Id = this.setXFormsId(control);
final Element choices =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":choices");
this.setXFormsId(choices, select1Id + "-choices");
final String caption = this.createCaption(elementDecl.getName() + " Type");
control.appendChild(this.createLabel(xformsDocument, caption));
// multiple compatible types for this element exist
// in the schema - allow the user to choose from
@@ -1229,98 +1111,34 @@ public class Schema2XForms
pathToRoot + "/@xsi:type");
modelSection.appendChild(bindElement);
control.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":bind",
bindId);
//add the "element" bind, in addition
Element bindElement2 = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element bindElement2 = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":bind");
String bindId2 = this.setXFormsId(bindElement2);
final String bindId2 = this.setXFormsId(bindElement2);
bindElement2.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":nodeset",
pathToRoot);
modelSection.appendChild(bindElement2);
control.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":appearance",
(enumValues.size() < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))
? getProperty(SELECTONE_UI_CONTROL_SHORT_PROP)
: getProperty(SELECTONE_UI_CONTROL_LONG_PROP)));
if (enumValues.size() >= 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
//
final String pleaseSelect = "[Select1 " + caption + "]";
final Element item = this.createXFormsItem(xformsDocument, pleaseSelect, pleaseSelect);
choices.appendChild(item);
// not(purchaseOrder/state = '[Choose State]')
//String isValidExpr = "not(" + bindElement.getAttributeNS(NamespaceConstants.XFORMS_NS, "nodeset") + " = '" + pleaseSelect + "')";
// ->no, not(. = '[Choose State]')
final String isValidExpr = "not( . = '" + pleaseSelect + "')";
//check if there was a constraint
final String constraint = bindElement.getAttributeNS(NamespaceConstants.XFORMS_NS, "constraint");
bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":constraint",
(constraint != null && constraint.length() != 0
? constraint + " && " + isValidExpr
: isValidExpr));
}
control.appendChild(choices);
formSection.appendChild(control);
// add content to select1
final Map<String, Element> caseTypes =
this.addChoicesForSelectSwitchControl(xformsDocument, choices, enumValues);
//add a trigger for this control (is there a way to not need it ?)
final Element dispatchTrigger = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":dispatch");
dispatchTrigger.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":name",
"DOMActivate");
dispatchTrigger.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":target",
select1Id);
formSection.appendChild(this.createTrigger(xformsDocument,
null,
null,
"validate choice",
dispatchTrigger));
this.addChoicesForSelectSwitchControl(xformsDocument, formSection, enumValues, bindId);
//add switch
final Element switchElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":switch");
this.setXFormsId(switchElement, select1Id + "-" + this.setXFormsId(switchElement));
final String switchId = this.setXFormsId(switchElement);
switchElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":bind",
bindId);
formSection.appendChild(switchElement);
//formSection.appendChild(switchElement);
/////////////// add this type //////////////
final Element firstCaseElement = caseTypes.get(controlType.getName());
switchElement.appendChild(firstCaseElement);
firstCaseElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":selected",
"true");
defaultInstanceElement.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS,
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":type",
controlType.getName());
defaultInstanceElement.setAttributeNS(NamespaceConstants.XMLSCHEMA_INSTANCE_NS,
NamespaceConstants.XMLSCHEMA_INSTANCE_PREFIX + ":nil",
"true");
LOGGER.debug("&&&&& die before " + XMLUtil.toString(defaultInstanceElement));
this.addComplexType(xformsDocument,
final Element firstGroupElement = this.addComplexType(xformsDocument,
modelSection,
defaultInstanceElement,
firstCaseElement,
@@ -1331,7 +1149,9 @@ public class Schema2XForms
true,
false,
resourceBundle);
LOGGER.debug("&&&&& die after " + XMLUtil.toString(defaultInstanceElement));
firstGroupElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":appearance",
"");
/////////////// add sub types //////////////
// add each compatible type within
@@ -1352,17 +1172,10 @@ public class Schema2XForms
continue;
}
//Element caseElement = (Element) xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,NamespaceConstants.XFORMS_PREFIX + ":case");
//caseElement.setAttributeNS(NamespaceConstants.XFORMS_NS,NamespaceConstants.XFORMS_PREFIX + ":id",bindId + "_" + type.getName() +"_case");
//String case_id=this.setXFormsId(caseElement);
final Element caseElement = caseTypes.get(type.getName());
caseElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":selected",
"false");
switchElement.appendChild(caseElement);
this.addComplexType(xformsDocument,
final Element groupElement = this.addComplexType(xformsDocument,
modelSection,
defaultInstanceElement,
caseElement,
@@ -1373,6 +1186,9 @@ public class Schema2XForms
true,
true,
resourceBundle);
groupElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":appearance",
"");
// modify bind to add a "relevant" attribute that checks the value of @xsi:type
if (LOGGER.isDebugEnabled())
@@ -1383,8 +1199,8 @@ public class Schema2XForms
final NodeList binds = bindElement2.getElementsByTagNameNS(NamespaceConstants.XFORMS_NS, "bind");
for (int i = 0; i < binds.getLength(); i++)
{
Element subBind = (Element) binds.item(i);
String name = subBind.getAttributeNS(NamespaceConstants.XFORMS_NS, "nodeset");
final Element subBind = (Element) binds.item(i);
final String name = subBind.getAttributeNS(NamespaceConstants.XFORMS_NS, "nodeset");
if (LOGGER.isDebugEnabled())
{
@@ -1427,7 +1243,7 @@ public class Schema2XForms
newRelevant);
}
}
return control;
return switchElement;
}
/**
@@ -1629,8 +1445,10 @@ public class Schema2XForms
}
}
else
{ //XSWildcard -> ignore ?
//LOGGER.warn("XSWildcard found in group from "+owner.getName()+" for pathToRoot="+pathToRoot);
{
LOGGER.warn("Unhandled term " + term +
" found in group from " + owner.getName() +
" for pathToRoot = " + pathToRoot);
}
}
@@ -1887,6 +1705,7 @@ public class Schema2XForms
{
formControl = this.createControlForListType(xformsDocument,
(XSSimpleTypeDefinition)controlType,
owner,
caption,
bindElement,
resourceBundle);
@@ -1896,6 +1715,7 @@ public class Schema2XForms
{
formControl = this.createControlForEnumerationType(xformsDocument,
(XSSimpleTypeDefinition)controlType,
owner,
caption,
bindElement,
resourceBundle);
@@ -2040,10 +1860,12 @@ public class Schema2XForms
}
//model element
Element modelElement = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element modelElement =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":model");
this.setXFormsId(modelElement);
Element modelWrapper = xformsDocument.createElementNS(NamespaceConstants.XHTML_NS,
final Element modelWrapper =
xformsDocument.createElementNS(NamespaceConstants.XHTML_NS,
NamespaceConstants.XHTML_PREFIX + ":head");
modelWrapper.appendChild(modelElement);
envelopeElement.appendChild(modelWrapper);
@@ -2051,7 +1873,8 @@ public class Schema2XForms
//form control wrapper -> created by wrapper
//Element formWrapper = xformsDocument.createElement("body");
//envelopeElement.appendChild(formWrapper);
Element formWrapper = xformsDocument.createElementNS(NamespaceConstants.XHTML_NS,
final Element formWrapper =
xformsDocument.createElementNS(NamespaceConstants.XHTML_NS,
NamespaceConstants.XHTML_PREFIX + ":body");
envelopeElement.appendChild(formWrapper);
return xformsDocument;
@@ -2064,7 +1887,7 @@ public class Schema2XForms
final ResourceBundle resourceBundle)
{
// add a group node and recurse
Element groupElement =
final Element groupElement =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":group");
this.setXFormsId(groupElement);
@@ -2111,19 +1934,27 @@ public class Schema2XForms
{
// if the word is all upper case, then set to lower case and continue
if (text.equals(text.toUpperCase()))
{
text = text.toLowerCase();
}
final String[] s = text.split("[-_\\ ]");
final 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();
}
@@ -2169,16 +2000,24 @@ public class Schema2XForms
final ResourceBundle resourceBundle)
{
if (element instanceof XSElementDeclaration)
{
return this.createCaption((XSElementDeclaration)element, resourceBundle);
}
if (element instanceof XSAttributeDeclaration)
{
return this.createCaption((XSAttributeDeclaration)element, resourceBundle);
}
if (element instanceof XSAttributeUse)
{
return this.createCaption((XSAttributeUse)element, resourceBundle);
}
else
{
LOGGER.warn("WARNING: createCaption: element is not an attribute nor an element: "
+ element.getClass().getName());
return null;
}
}
/**
* Creates a form control for an XML Schema any type.
@@ -2198,7 +2037,7 @@ public class Schema2XForms
final String caption,
final XSTypeDefinition controlType)
{
Element control = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element control = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":textarea");
this.setXFormsId(control);
// control.setAttributeNS(Schema2XForms.CHIBA_NS,
@@ -2206,7 +2045,6 @@ public class Schema2XForms
// "3");
control.appendChild(this.createLabel(xformsDocument, caption));
return control;
}
@@ -2310,6 +2148,7 @@ public class Schema2XForms
*/
public Element createControlForEnumerationType(final Document xformsDocument,
final XSSimpleTypeDefinition controlType,
final XSObject owner,
final String caption,
final Element bindElement,
final ResourceBundle resourceBundle)
@@ -2326,20 +2165,23 @@ public class Schema2XForms
return null;
}
Element control = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element control =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":select1");
this.setXFormsId(control);
//label
control.appendChild(this.createLabel(xformsDocument, caption));
Element choices = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element choices = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":choices");
this.setXFormsId(choices);
final XSObjectList mvFacets = controlType.getMultiValueFacets();
if (mvFacets.getLength() != 1)
{
throw new RuntimeException("expected exactly one MultiValueFacet for " + controlType);
}
final XSObjectList annotations =
((XSMultiValueFacet)mvFacets.item(0)).getAnnotations();
@@ -2354,18 +2196,21 @@ public class Schema2XForms
: null));
}
String appearance = this.extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI,
"appearance",
this.getAnnotation(owner),
resourceBundle);
if (appearance == null || appearance.length() == 0)
{
appearance = enumFacets.getLength() < Schema2XForms.LONG_LIST_SIZE ? "full" : "compact";
}
control.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":appearance",
(enumFacets.getLength() < Long.parseLong(getProperty(SELECTONE_LONG_LIST_SIZE_PROP))
? getProperty(SELECTONE_UI_CONTROL_SHORT_PROP)
: getProperty(SELECTONE_UI_CONTROL_LONG_PROP)));
appearance);
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
//
final String pleaseSelect = "[Select1 " + caption + "]";
final Element item = this.createXFormsItem(xformsDocument, pleaseSelect, pleaseSelect);
choices.appendChild(item);
@@ -2385,12 +2230,9 @@ public class Schema2XForms
bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":constraint",
constraint);
}
control.appendChild(choices);
this.addChoicesForSelectControl(xformsDocument, choices, enumValues, resourceBundle);
return control;
}
@@ -2415,6 +2257,7 @@ public class Schema2XForms
*/
public Element createControlForListType(final Document xformsDocument,
final XSSimpleTypeDefinition listType,
final XSObject owner,
final String caption,
final Element bindElement,
final ResourceBundle resourceBundle)
@@ -2423,17 +2266,19 @@ public class Schema2XForms
final StringList enumFacets = controlType.getLexicalEnumeration();
if (enumFacets.getLength() <= 0)
{
return null;
}
Element control = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":select");
this.setXFormsId(control);
control.appendChild(this.createLabel(xformsDocument, caption));
final XSObjectList mvFacets = controlType.getMultiValueFacets();
if (mvFacets.getLength() != 1)
{
throw new RuntimeException("expected exactly one MultiValueFacet for " + controlType);
}
final XSObjectList annotations =
((XSMultiValueFacet)mvFacets.item(0)).getAnnotations();
@@ -2453,19 +2298,23 @@ public class Schema2XForms
// 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
//
String appearance = this.extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI,
"appearance",
this.getAnnotation(owner),
resourceBundle);
if (appearance == null || appearance.length() == 0)
{
appearance = enumValues.size() < Schema2XForms.LONG_LIST_SIZE ? "full" : "compact";
}
control.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_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 = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
appearance);
final Element choices =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":choices");
this.setXFormsId(choices);
control.appendChild(choices);
this.addChoicesForSelectControl(xformsDocument, choices, enumValues, resourceBundle);
return control;
}
@@ -2487,13 +2336,17 @@ public class Schema2XForms
{
final XSAnnotation annotation = this.getAnnotation(node);
if (annotation == null)
{
return null;
}
final String s = this.extractPropertyFromAnnotation(NamespaceService.ALFRESCO_URI,
"hint",
annotation,
resourceBundle);
if (s == null)
{
return null;
}
final Element hintElement =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":hint");
@@ -2615,9 +2468,11 @@ public class Schema2XForms
? minConstraint
: maxConstraint));
if (constraint != null)
{
bindElement.setAttributeNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":constraint",
constraint);
}
return bindElement;
}
@@ -2873,13 +2728,11 @@ public class Schema2XForms
final Element rootGroup)
{
Element submission = this.createSubmissionElement(xformsDocument, "submission-validate", true);
Element submission =
this.createSubmissionElement(xformsDocument, "submission-validate", true);
modelSection.appendChild(submission);
Element submit = this.createSubmitControl(xformsDocument,
submission,
"submit",
"Submit");
Element submit = this.createSubmitControl(xformsDocument, submission, "submit", "Submit");
rootGroup.appendChild(submit);
submission = this.createSubmissionElement(xformsDocument, "submission-draft", false);
@@ -2896,12 +2749,14 @@ public class Schema2XForms
final String label,
final String value)
{
final Element item = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element item =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":item");
this.setXFormsId(item);
item.appendChild(this.createLabel(xformsDocument, label));
final Element e = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element e =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":value");
this.setXFormsId(e);
e.appendChild(xformsDocument.createTextNode(value));
@@ -2912,7 +2767,8 @@ public class Schema2XForms
private Element createLabel(final Document xformsDocument,
final String label)
{
final Element e = xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
final Element e =
xformsDocument.createElementNS(NamespaceConstants.XFORMS_NS,
NamespaceConstants.XFORMS_PREFIX + ":label");
this.setXFormsId(e);
e.appendChild(xformsDocument.createTextNode(label));

View File

@@ -660,12 +660,13 @@ public class XFormsBean
private static void rewriteInlineURIs(final Document schemaDocument,
final String cwdAvmPath)
{
final NodeList includes =
schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "include");
LOGGER.debug("rewriting " + includes.getLength() + " includes");
for (int i = 0; i < includes.getLength(); i++)
final NodeList nl =
XMLUtil.combine(schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "include"),
schemaDocument.getElementsByTagNameNS(NamespaceConstants.XMLSCHEMA_NS, "import"));
LOGGER.debug("rewriting " + nl.getLength() + " includes");
for (int i = 0; i < nl.getLength(); i++)
{
final Element includeEl = (Element)includes.item(i);
final Element includeEl = (Element)nl.item(i);
if (includeEl.hasAttribute("schemaLocation"))
{
String uri = includeEl.getAttribute("schemaLocation");

View File

@@ -0,0 +1,294 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- $Revision: 1.5 $ -->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:glob="http://apply.grants.gov/system/Global-V1.0" xmlns:att="http://apply.grants.gov/system/Attachments-V1.0" xmlns:globLib="http://apply.grants.gov/system/GlobalLibrary-V2.0" xmlns:RR_SF424="http://apply.grants.gov/forms/RR_SF424-V1.1" targetNamespace="http://apply.grants.gov/forms/RR_SF424-V1.1" elementFormDefault="qualified" attributeFormDefault="qualified" version="1.1">
<xs:import namespace="http://apply.grants.gov/system/GlobalLibrary-V2.0" schemaLocation="http://apply.grants.gov/system/schemas/GlobalLibrary-V2.0.xsd"/>
<xs:import namespace="http://apply.grants.gov/system/Global-V1.0" schemaLocation="http://apply.grants.gov/system/schemas/Global-V1.0.xsd"/>
<xs:import namespace="http://apply.grants.gov/system/Attachments-V1.0" schemaLocation="http://apply.grants.gov/system/schemas/Attachments-V1.0.xsd"/>
<xs:element name="RR_SF424">
<xs:complexType>
<xs:sequence>
<xs:element name="SubmissionTypeCode" type="RR_SF424:SubmissionTypeDataType"/>
<xs:element name="SubmittedDate" type="xs:date" minOccurs="0"/>
<xs:element name="ApplicantID" type="globLib:ApplicantIDDataType" minOccurs="0"/>
<xs:element name="StateReceivedDate" type="xs:date" minOccurs="0"/>
<xs:element name="StateID" type="globLib:StateIDDataType" minOccurs="0"/>
<xs:element name="FederalID" type="globLib:FederalIDDataType" minOccurs="0"/>
<xs:element name="ApplicantInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="OrganizationInfo" type="globLib:OrganizationDataType"/>
<xs:element name="ContactPersonInfo">
<xs:complexType>
<xs:sequence>
<xs:element name="Name" type="globLib:HumanNameDataType"/>
<xs:element name="Phone" type="globLib:TelephoneNumberDataType"/>
<xs:element name="Fax" type="globLib:TelephoneNumberDataType" minOccurs="0"/>
<xs:element name="Email" type="globLib:EmailDataType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="EmployerID">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="9"/>
<xs:maxLength value="30"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="ApplicantType">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicantTypeCode" type="globLib:ApplicantTypeCodeDataType"/>
<xs:element name="ApplicantTypeCodeOtherExplanation" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="50"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="SmallBusinessOrganizationType" nillable="true" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="isWomenOwned" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="globLib:YesNoDataType"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
<xs:element name="isSociallyEconomicallyDisadvantaged" minOccurs="0">
<xs:complexType>
<xs:simpleContent>
<xs:extension base="globLib:YesNoDataType"/>
</xs:simpleContent>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ApplicationType">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicationTypeCode" type="RR_SF424:ApplicationTypeCodeDataType"/>
<xs:element name="RevisionCode" type="RR_SF424:RevisionTypeCodeDataType" minOccurs="0"/>
<xs:element name="RevisionCodeOtherExplanation" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="45"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="isOtherAgencySubmission" type="globLib:YesNoDataType"/>
<xs:element name="OtherAgencySubmissionExplanation" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="20"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="FederalAgencyName" type="globLib:AgencyNameDataType"/>
<xs:element name="CFDANumber" type="globLib:CFDANumberDataType" minOccurs="0"/>
<xs:element name="ActivityTitle" type="globLib:ProgramActivityTitleDataType" minOccurs="0"/>
<xs:element name="ProjectTitle" type="globLib:ProjectTitleDataType"/>
<xs:element name="Location">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:minLength value="1"/>
<xs:maxLength value="45"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="ProposedProjectPeriod">
<xs:complexType>
<xs:sequence>
<xs:element name="ProposedStartDate" type="xs:date"/>
<xs:element name="ProposedEndDate" type="xs:date"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="CongressionalDistrict">
<xs:complexType>
<xs:sequence>
<xs:element name="ApplicantCongressionalDistrict" type="globLib:CongressionalDistrictDataType"/>
<xs:element name="ProjectCongressionalDistrict" type="globLib:CongressionalDistrictDataType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="PDPIContactInfo" type="RR_SF424:OrganizationContactPersonDataType"/>
<xs:element name="EstimatedProjectFunding">
<xs:complexType>
<xs:sequence>
<xs:element name="TotalEstimatedAmount" type="globLib:BudgetTotalAmountDataType"/>
<xs:element name="TotalfedNonfedrequested" type="globLib:BudgetTotalAmountDataType"/>
<xs:element name="EstimatedProgramIncome" type="globLib:BudgetTotalAmountDataType"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="StateReview">
<xs:complexType>
<xs:sequence>
<xs:element name="StateReviewCodeType" type="RR_SF424:StateReviewCodeTypeDataType"/>
<xs:element name="StateReviewDate" type="xs:date" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="TrustAgree" type="globLib:YesNoDataType"/>
<xs:element name="AORInfo" type="RR_SF424:AORInfoType"/>
<xs:element name="PreApplicationAttachment" type="att:AttachedFileDataType" minOccurs="0"/>
<xs:element name="AdditionalCongressionalDistricts" type="att:AttachedFileDataType" minOccurs="0"/>
<xs:element name="AOR_Signature" type="globLib:SignatureDataType"/>
<xs:element name="AOR_SignedDate" type="xs:date"/>
</xs:sequence>
<xs:attribute name="FormVersion" type="globLib:FormVersionDataType" use="required" fixed="1.1"/>
</xs:complexType>
<!--
<xs:key name="ApplicantTypeCodeKey">
<xs:selector xpath="./RR_SF424:ApplicantType"/>
<xs:field xpath="RR_SF424:ApplicantTypeCode"/>
</xs:key>
<xs:keyref name="ApplicantTypeCodeOtherKeyRef" refer="RR_SF424:ApplicantTypeCodeKey">
<xs:selector xpath="./RR_SF424:ApplicantType/RR_SF424:ApplicantTypeCodeOtherExplanation"/>
<xs:field xpath="@ApplicantTypeCode"/>
</xs:keyref>
<xs:keyref name="ApplicantTypeCodeSmallBusinessKeyRef" refer="RR_SF424:ApplicantTypeCodeKey">
<xs:selector xpath="./RR_SF424:ApplicantType/RR_SF424:SmallBusinessOrganizationType"/>
<xs:field xpath="@ApplicantTypeCode"/>
</xs:keyref>
<xs:key name="ApplicationTypeCodeKey">
<xs:selector xpath="./RR_SF424:ApplicationType"/>
<xs:field xpath="RR_SF424:ApplicationTypeCode"/>
</xs:key>
<xs:keyref name="ApplicationTypeCodeKeyRef" refer="RR_SF424:ApplicationTypeCodeKey">
<xs:selector xpath="./RR_SF424:ApplicationType/RR_SF424:RevisionCode"/>
<xs:field xpath="@ApplicationTypeCode"/>
</xs:keyref>
<xs:key name="isOtherAgencySubmissionKey">
<xs:selector xpath="./RR_SF424:ApplicationType"/>
<xs:field xpath="RR_SF424:isOtherAgencySubmission"/>
</xs:key>
<xs:keyref name="isOtherAgencySubmissionKeyRef" refer="RR_SF424:isOtherAgencySubmissionKey">
<xs:selector xpath="./RR_SF424:ApplicationType/RR_SF424:OtherAgencySubmissionExplanation"/>
<xs:field xpath="@isOtherAgencySubmission"/>
</xs:keyref>
<xs:key name="StateReviewCodeTypeKey">
<xs:selector xpath="./RR_SF424:StateReview"/>
<xs:field xpath="RR_SF424:StateReviewCodeType"/>
</xs:key>
<xs:keyref name="StateReviewCodeTypeKeyRef" refer="RR_SF424:StateReviewCodeTypeKey">
<xs:selector xpath="./RR_SF424:StateReview/RR_SF424:StateReview"/>
<xs:field xpath="@StateReviewCodeType"/>
</xs:keyref>
-->
</xs:element>
<xs:simpleType name="SubmissionTypeDataType">
<xs:restriction base="xs:string">
<xs:enumeration value="Preapplication"/>
<xs:enumeration value="Application"/>
<xs:enumeration value="Change/Corrected Application"/>
</xs:restriction>
</xs:simpleType>
<!--
<xs:simpleType name="ApplicantTypeCodeDataType">
<xs:restriction base="xs:string">
<xs:enumeration value="A: State Government"/>
<xs:enumeration value="B: County Government"/>
<xs:enumeration value="C: City or Township Government"/>
<xs:enumeration value="D: Special District Governments"/>
<xs:enumeration value="E: Independent School District"/>
<xs:enumeration value="F: State-Controlled Institution of Higher Education"/>
<xs:enumeration value="G: Native American Tribal Government (Federally Recognized)"/>
<xs:enumeration value="H: Public/Indian Housing Authority"/>
<xs:enumeration value="I: Native American Tribal Organization (other than Federally recognized)"/>
<xs:enumeration value="J: Nonprofit with 501C3 IRS status (other than Institution of Higher Education)"/>
<xs:enumeration value="K: Nonprofit without 501C3 IRS status (other than Institution of Higher Education)"/>
<xs:enumeration value="L: Private Institution of Higher Education"/>
<xs:enumeration value="M: Individual"/>
<xs:enumeration value="N: For-profit Organization (other than small business)"/>
<xs:enumeration value="O: Small Business"/>
<xs:enumeration value="P: Other (specify)"/>
</xs:restriction>
</xs:simpleType>-->
<xs:simpleType name="ApplicationTypeCodeDataType">
<xs:restriction base="xs:string">
<xs:enumeration value="New"/>
<xs:enumeration value="Resubmission"/>
<xs:enumeration value="Renewal"/>
<xs:enumeration value="Continuation"/>
<xs:enumeration value="Revision"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RevisionTypeCodeDataType">
<xs:restriction base="xs:string">
<xs:enumeration value="A"/>
<xs:enumeration value="B"/>
<xs:enumeration value="C"/>
<xs:enumeration value="D"/>
<xs:enumeration value="E"/>
<xs:enumeration value="AC"/>
<xs:enumeration value="AD"/>
<xs:enumeration value="BC"/>
<xs:enumeration value="BD"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="StateReviewCodeTypeDataType">
<xs:restriction base="xs:string">
<xs:enumeration value="Y: Yes"/>
<xs:enumeration value="Program is not covered by E.O. 12372"/>
<xs:enumeration value="Program has not been selected by state for review"/>
</xs:restriction>
</xs:simpleType>
<xs:complexType name="OrganizationContactPersonDataType">
<xs:sequence>
<xs:element name="Name" type="globLib:HumanNameDataType"/>
<xs:element name="Title" type="globLib:HumanTitleDataType" minOccurs="0"/>
<xs:element name="Address" type="globLib:AddressDataType"/>
<xs:element name="Phone" type="globLib:TelephoneNumberDataType"/>
<xs:element name="Fax" type="globLib:TelephoneNumberDataType" minOccurs="0"/>
<xs:element name="Email" type="globLib:EmailDataType"/>
<xs:element name="OrganizationName" type="globLib:OrganizationNameDataType"/>
<xs:element name="DepartmentName" type="globLib:DepartmentNameDataType" minOccurs="0"/>
<xs:element name="DivisionName" type="globLib:DivisionNameDataType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<!-- ================================================ -->
<!-- AORInfoType -->
<!-- The AORInfoType is a re-definition of the global -->
<!-- library's ContactPersonDataType. Restriction -->
<!-- based inheritence could not be used since each -->
<!-- element in the restricted derivation would have -->
<!-- a different namespace from the base type, making -->
<!-- it an entirely different element that cannot be -->
<!-- mapped back to its base particle. This violates -->
<!-- the schema specification for "Particle Derivation-->
<!-- OK (All:All,Sequence:Sequence - Recurse)" line -->
<!-- 2.1, for more information see the following link:-->
<!-- http://www.w3.org/TR/xmlschema-1/#rcase-Recurse -->
<!-- ================================================ -->
<xs:complexType name="AORInfoType">
<xs:sequence>
<xs:element name="Name" type="globLib:HumanNameDataType"/>
<xs:element name="Title" type="globLib:HumanTitleDataType"/>
<xs:element name="Address" type="globLib:AddressDataType"/>
<xs:element name="Phone" type="globLib:TelephoneNumberDataType"/>
<xs:element name="Fax" type="globLib:TelephoneNumberDataType" minOccurs="0"/>
<xs:element name="Email" type="globLib:EmailDataType"/>
<xs:element name="OrganizationName" type="globLib:OrganizationNameDataType"/>
<xs:element name="DepartmentName" type="globLib:DepartmentNameDataType" minOccurs="0"/>
<xs:element name="DivisionName" type="globLib:DivisionNameDataType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>

View File

@@ -0,0 +1,214 @@
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:alf="http://www.alfresco.org"
elementFormDefault="qualified">
<xs:simpleType name="four_presidents">
<xs:restriction base="xs:string">
<xs:enumeration value="washington"/>
<xs:enumeration value="jefferson"/>
<xs:enumeration value="lincoln"/>
<xs:enumeration value="roosevelt1">
<xs:annotation>
<xs:appinfo><alf:label>Teddy Roosevelt</alf:label></xs:appinfo>
</xs:annotation>
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="four_presidents_list">
<xs:list itemType="four_presidents"/>
</xs:simpleType>
<xs:simpleType name="thirteen_colonies">
<xs:restriction base="xs:string">
<xs:enumeration value="massachusetts"/>
<xs:enumeration value="NH">
<xs:annotation>
<xs:appinfo><alf:label>new hampshire</alf:label></xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="NY">
<xs:annotation>
<xs:appinfo><alf:label>new york</alf:label></xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="connecticut"/>
<xs:enumeration value="RI">
<xs:annotation>
<xs:appinfo><alf:label>rhode island</alf:label></xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="NJ">
<xs:annotation>
<xs:appinfo><alf:label>new jersey</alf:label></xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="delaware"/>
<xs:enumeration value="maryland"/>
<xs:enumeration value="pennsylvania"/>
<xs:enumeration value="virginia"/>
<xs:enumeration value="NC">
<xs:annotation>
<xs:appinfo><alf:label>north carolina</alf:label></xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="SC">
<xs:annotation>
<xs:appinfo><alf:label>south carolina</alf:label></xs:appinfo>
</xs:annotation>
</xs:enumeration>
<xs:enumeration value="georgia"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="thirteen_colonies_list">
<xs:list itemType="thirteen_colonies"/>
</xs:simpleType>
<xs:element name="list-test">
<xs:complexType>
<xs:sequence>
<xs:element name="select1">
<xs:complexType>
<xs:sequence>
<xs:element name="four_items">
<xs:complexType>
<xs:sequence>
<xs:element name="full"
type="four_presidents"
default="jefferson"
minOccurs="1"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>full</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="compact"
type="four_presidents"
default="roosevelt1"
minOccurs="1"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>compact</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="default"
type="four_presidents"
default="jefferson"
minOccurs="1"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ten_items">
<xs:complexType>
<xs:sequence>
<xs:element name="full"
type="thirteen_colonies"
minOccurs="1"
default="NY"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>full</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="compact"
type="thirteen_colonies"
default="NJ"
minOccurs="1"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>compact</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="default"
type="thirteen_colonies"
default="NJ"
minOccurs="1"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="select">
<xs:complexType>
<xs:sequence>
<xs:element name="four_items">
<xs:complexType>
<xs:sequence>
<xs:element name="full"
type="four_presidents_list"
default="jefferson"
minOccurs="1"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>full</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="compact"
type="four_presidents_list"
default="jefferson"
minOccurs="1"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>compact</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="default"
type="four_presidents_list"
default="jefferson"
minOccurs="1"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="ten_items">
<xs:complexType>
<xs:sequence>
<xs:element name="full"
type="thirteen_colonies_list"
minOccurs="1"
default="NJ"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>full</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="compact"
type="thirteen_colonies_list"
default="massachusetts"
minOccurs="1"
maxOccurs="1">
<xs:annotation>
<xs:appinfo>
<alf:appearance>compact</alf:appearance>
</xs:appinfo>
</xs:annotation>
</xs:element>
<xs:element name="default"
type="thirteen_colonies_list"
default="maryland"
minOccurs="1"
maxOccurs="1"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:othernsprefix="http://other.org/othernsuri"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="http://other.org/othernsuri">
<xs:simpleType name="type1">
<xs:restriction base="xs:string">
<xs:minLength value="5"/>
<xs:maxLength value="5"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:mynsprefix="http://mine.org/mynsuri"
xmlns:othernsprefix="http://other.org/othernsuri"
elementFormDefault="qualified"
attributeFormDefault="qualified"
targetNamespace="http://mine.org/mynsuri">
<xs:import namespace="http://other.org/othernsuri" schemaLocation="/multi-namespace-test-other.xsd"/>
<xs:element name="multi-namespace-test">
<xs:complexType>
<xs:sequence>
<xs:element name="element_type_1" type="othernsprefix:type1"/>
</xs:sequence>
<xs:attribute name="attribute_type_1" type="othernsprefix:type1" use="required"/>
</xs:complexType>
</xs:element>
</xs:schema>

View File

@@ -94,7 +94,12 @@
<h:outputText value=""/>
<h:outputText value="#{msg.form}:"/>
<h:selectOneMenu value="#{WizardManager.bean.formName}" disabled="#{WizardManager.bean.formSelectDisabled}">
<h:selectOneMenu value="#{WizardManager.bean.formName}"
disabled="#{WizardManager.bean.formSelectDisabled}"
rendered="#{!empty WizardManager.bean.formChoices}">
<f:selectItems value="#{WizardManager.bean.formChoices}" />
</h:selectOneMenu>
<h:outputText value="#{msg.sandbox_no_web_forms}"
style="font-style: italic"
rendered="#{empty WizardManager.bean.formChoices}"/>
</h:panelGrid>

View File

@@ -457,6 +457,14 @@ dojo.declare("alfresco.xforms.Widget",
}
},
/** Returns the value of the appearance attribute for widget */
getAppearance: function()
{
var result = (this.xformsNode.getAttribute("appearance") ||
this.xformsNode.getAttribute(alfresco_xforms_constants.XFORMS_PREFIX + ":appearance"));
return result == null || result.length == 0 ? null : result;
},
/** Updates the display of the widget. This is intended to be overridden. */
_updateDisplay: function()
{
@@ -520,10 +528,10 @@ dojo.declare("alfresco.xforms.Widget",
/** The file picker widget which handles xforms widget xf:upload. */
dojo.declare("alfresco.xforms.FilePicker",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -583,10 +591,10 @@ dojo.declare("alfresco.xforms.FilePicker",
/** The textfield widget which handle xforms widget xf:input with any string or numerical type */
dojo.declare("alfresco.xforms.TextField",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -737,11 +745,11 @@ dojo.declare("alfresco.xforms.NumericalRange",
/** The textfield widget which handle xforms widget xf:textarea. */
dojo.declare("alfresco.xforms.TextArea",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
this.focused = false;
},
{
/////////////////////////////////////////////////////////////////
// methods
@@ -952,7 +960,7 @@ dojo.declare("alfresco.xforms.Select",
var initial_value = this.getInitialValue();
initial_value = initial_value ? initial_value.split(' ') : [];
this._selectedValues = [];
if (values.length <= 5)
if (this.getAppearance() == "full")
{
this.widget = document.createElement("div");
this.widget.style.width = "100%";
@@ -1051,7 +1059,7 @@ dojo.declare("alfresco.xforms.Select",
{
if (event.target.options[i].selected)
{
this._selectedValues.push(event.target.options[i].value);
this._selectedValues.push(event.target.options[i].getAttribute("value"));
}
}
this._commitValueChange();
@@ -1060,12 +1068,12 @@ dojo.declare("alfresco.xforms.Select",
_checkbox_clickHandler: function(event)
{
this._selectedValues = [];
for (var i = 0; i < 5; i++)
var all_checkboxes = this.widget.getElementsByTagName("input");
for (var i = 0; i < all_checkboxes.length; i++)
{
var checkbox = document.getElementById(this.id + "_" + i + "-widget");
if (checkbox && checkbox.checked)
if (all_checkboxes[i] && all_checkboxes[i].checked)
{
this._selectedValues.push(checkbox.value);
this._selectedValues.push(all_checkboxes[i].getAttribute("value"));
}
}
this._commitValueChange();
@@ -1090,13 +1098,19 @@ dojo.declare("alfresco.xforms.Select1",
{
var values = this._getItemValues();
var initial_value = this.getInitialValue();
if (values.length <= 5)
if (this.getAppearance() == "full")
{
this.widget = document.createElement("div");
this.widget.style.width = "100%";
attach_point.appendChild(this.widget);
for (var i = 0; i < values.length; i++)
{
if (!values[i].valid)
{
// always skip the invalid values for radios
continue;
}
var radio_div = document.createElement("div");
radio_div.style.lineHeight = "16px";
this.widget.appendChild(radio_div);
@@ -1273,10 +1287,10 @@ dojo.declare("alfresco.xforms.Checkbox",
/** The date picker widget which handles xforms widget xf:input with type xf:date */
dojo.declare("alfresco.xforms.DatePicker",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -1363,10 +1377,10 @@ dojo.declare("alfresco.xforms.DatePicker",
/** The date picker widget which handles xforms widget xf:input with type xf:date */
dojo.declare("alfresco.xforms.TimePicker",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -1438,10 +1452,10 @@ dojo.declare("alfresco.xforms.TimePicker",
/** The year picker handles xforms widget xf:input with a gYear type */
dojo.declare("alfresco.xforms.YearPicker",
alfresco.xforms.TextField,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -1479,10 +1493,10 @@ dojo.declare("alfresco.xforms.YearPicker",
/** The day picker widget which handles xforms widget xf:input with type xf:gDay */
dojo.declare("alfresco.xforms.DayPicker",
alfresco.xforms.Select1,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -1506,10 +1520,10 @@ dojo.declare("alfresco.xforms.DayPicker",
/** The month picker widget which handles xforms widget xf:input with type xf:gMonth */
dojo.declare("alfresco.xforms.MonthPicker",
alfresco.xforms.Select1,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -1535,8 +1549,7 @@ dojo.declare("alfresco.xforms.MonthPicker",
/** The month day picker widget which handles xforms widget xf:input with type xf:gMonthDay */
dojo.declare("alfresco.xforms.MonthDayPicker",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
this.monthPicker = new alfresco.xforms.MonthPicker(xform, xformsNode);
this.monthPicker._compositeParent = this;
@@ -1544,6 +1557,7 @@ dojo.declare("alfresco.xforms.MonthDayPicker",
this.dayPicker = new alfresco.xforms.DayPicker(xform, xformsNode);
this.dayPicker._compositeParent = this;
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -1575,8 +1589,7 @@ dojo.declare("alfresco.xforms.MonthDayPicker",
/** The year month picker widget which handles xforms widget xf:input with type xf:gYearMonth */
dojo.declare("alfresco.xforms.YearMonthPicker",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
this.yearPicker = new alfresco.xforms.YearPicker(xform, xformsNode);
this.yearPicker._compositeParent = this;
@@ -1584,6 +1597,7 @@ dojo.declare("alfresco.xforms.YearMonthPicker",
this.monthPicker = new alfresco.xforms.MonthPicker(xform, xformsNode);
this.monthPicker._compositeParent = this;
},
{
/////////////////////////////////////////////////////////////////
// overridden methods
@@ -1625,23 +1639,17 @@ dojo.declare("alfresco.xforms.YearMonthPicker",
*/
dojo.declare("alfresco.xforms.Group",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
this._children = [];
dojo.html.removeClass(this.domNode, "xformsItem");
},
{
/////////////////////////////////////////////////////////////////
// methods & properties
/////////////////////////////////////////////////////////////////
/** Returns the value of the appearance attribute for widget */
getAppearance: function()
{
return (this.xformsNode.getAttribute("appearance") ||
this.xformsNode.getAttribute(alfresco_xforms_constants.XFORMS_PREFIX + ":appearance"));
},
_groupHeaderNode: null,
/** Returns the child at the specified index or null if the index is out of range. */
getChildAt: function(index)
@@ -1704,11 +1712,38 @@ dojo.declare("alfresco.xforms.Group",
this._children.splice(position, 0, child);
}
if (this.getAppearance() == "full" &&
!(this instanceof alfresco.xforms.Repeat) &&
child.isVisible() &&
((child instanceof alfresco.xforms.Group && position != 0) ||
this._children[position - 1] instanceof alfresco.xforms.Group))
function shouldInsertDivider(group, child, position)
{
if (group.getAppearance() != "full")
{
return false;
}
if (group instanceof alfresco.xforms.Repeat)
{
return false;
}
if (!child.isVisible())
{
return false;
}
if (group._children[position - 1] instanceof alfresco.xforms.Group)
{
return true;
}
if (child instanceof alfresco.xforms.Group)
{
for (var i = position - 1; i > 0; i--)
{
if (group._children[i].isVisible())
{
return true;
}
}
}
return false;
}
if (shouldInsertDivider(this, child, position))
{
var divider = document.createElement("div");
dojo.html.setClass(divider, "xformsGroupDivider");
@@ -1898,13 +1933,13 @@ dojo.declare("alfresco.xforms.Group",
attach_point.offsetWidth)) * 100 + "%";
}
this.groupHeaderNode = document.createElement("div");
this.groupHeaderNode.id = this.id + "-groupHeaderNode";
dojo.html.setClass(this.groupHeaderNode, "xformsGroupHeader");
this.domNode.appendChild(this.groupHeaderNode);
this._groupHeaderNode = document.createElement("div");
this._groupHeaderNode.setAttribute("id", this.id + "-groupHeaderNode");
dojo.html.setClass(this._groupHeaderNode, "xformsGroupHeader");
this.domNode.appendChild(this._groupHeaderNode);
this.toggleExpandedImage = document.createElement("img");
this.groupHeaderNode.appendChild(this.toggleExpandedImage);
this._groupHeaderNode.appendChild(this.toggleExpandedImage);
this.toggleExpandedImage.setAttribute("src", alfresco_xforms_constants.EXPANDED_IMAGE.src);
this.toggleExpandedImage.align = "absmiddle";
this.toggleExpandedImage.style.marginLeft = "5px";
@@ -1915,7 +1950,7 @@ dojo.declare("alfresco.xforms.Group",
this,
this._toggleExpanded_clickHandler);
this.groupHeaderNode.appendChild(document.createTextNode(this.getLabel()));
this._groupHeaderNode.appendChild(document.createTextNode(this.getLabel()));
}
attach_point.appendChild(this.domNode);
@@ -2037,17 +2072,86 @@ dojo.declare("alfresco.xforms.SwitchGroup",
alfresco.xforms.Group,
function(xform, xformsNode)
{
this.selectedCaseId = null;
var widgets = this.xform.getBinding(this.xformsNode).widgets;
for (var i in widgets)
if (this.getInitialValue())
{
if (widgets[i] instanceof alfresco.xforms.Select1)
{
widgets[i].setValue(this.getInitialValue(), "true");
}
var initialValueTrigger = this._getCaseToggleTriggerByTypeValue(this.getInitialValue());
this._selectedCaseId = initialValueTrigger.getActions()["toggle"].properties["case"];
}
},
{
/////////////////////////////////////////////////////////////////
// methods & properties
/////////////////////////////////////////////////////////////////
_getCaseToggleTriggers: function()
{
var bw = this.xform.getBinding(this.xformsNode).widgets;
var result = [];
for (var i in bw)
{
if (! (bw[i] instanceof alfresco.xforms.Trigger))
{
continue;
}
var action = bw[i].getActions()["toggle"];
if (action)
{
result.push(bw[i]);
}
}
return result;
},
_getCaseToggleTriggerByCaseId: function(caseId)
{
var bw = this.xform.getBinding(this.xformsNode).widgets;
for (var i in bw)
{
if (! (bw[i] instanceof alfresco.xforms.Trigger))
{
continue;
}
var action = bw[i].getActions()["toggle"];
if (!action)
{
continue;
}
if (action.properties["case"] == caseId)
{
return bw[i];
}
}
throw new Error("unable to find trigger " + type +
", properties " + properties +
" for " + this.id);
},
_getCaseToggleTriggerByTypeValue: function(typeValue)
{
var bw = this.xform.getBinding(this.xformsNode).widgets;
for (var i in bw)
{
if (! (bw[i] instanceof alfresco.xforms.Trigger))
{
continue;
}
var action = bw[i].getActions()["setvalue"];
if (!action)
{
continue;
}
if (action.properties["value"] == typeValue)
{
return bw[i];
}
}
throw new Error("unable to find toggle trigger for type value " + typeValue +
" for " + this.id);
},
/////////////////////////////////////////////////////////////////
// overridden methods & properties
/////////////////////////////////////////////////////////////////
@@ -2057,14 +2161,42 @@ dojo.declare("alfresco.xforms.SwitchGroup",
{
var childDomContainer =
alfresco.xforms.SwitchGroup.superclass._insertChildAt.call(this, child, position);
this.selectedCaseId = this.selectedCaseId || child.id;
if (this.selectedCaseId != child.id)
if (child.id == this._selectedCaseId)
{
this._getCaseToggleTriggerByCaseId(this._selectedCaseId).fire();
}
else
{
childDomContainer.style.display = "none";
}
return childDomContainer;
},
render: function(attach_point)
{
alfresco.xforms.SwitchGroup.superclass.render.call(this, attach_point);
this._groupHeaderNode = document.createElement("div");
this._groupHeaderNode.setAttribute("id", this.id + "-groupHeaderNode");
this.domNode.appendChild(this._groupHeaderNode);
this._groupHeaderNode.style.backgroundColor = "orange";
var cases = this._getCaseToggleTriggers();
for (var i = 0; i < cases.length; i++)
{
var d = document.createElement("div");
this._groupHeaderNode.appendChild(d);
var link = document.createElement("a");
link.setAttribute("id", cases[i].id);
link.trigger = cases[i];
link.appendChild(document.createTextNode(cases[i].getLabel()));
d.appendChild(link);
dojo.event.browser.addListener(link,
"onclick",
function(event)
{
event.target.trigger.fire();
});
}
},
/////////////////////////////////////////////////////////////////
// XForms event handlers
@@ -2091,6 +2223,15 @@ dojo.declare("alfresco.xforms.SwitchGroup",
}
});
/** */
dojo.declare("alfresco.xforms.CaseGroup",
alfresco.xforms.Group,
function(xform, xformsNode)
{
},
{
});
/**
* Handles xforms widget xf:group for the root group. Does some special rendering
* to present a title rather than a group header.
@@ -2109,18 +2250,18 @@ dojo.declare("alfresco.xforms.ViewRoot",
this.domNode.style.width = "100%";
dojo.html.setClass(this.domNode, "xformsViewRoot");
this.groupHeaderNode = document.createElement("div");
this.groupHeaderNode.id = this.id + "-groupHeaderNode";
dojo.html.setClass(this.groupHeaderNode, "xformsViewRootHeader");
this.domNode.appendChild(this.groupHeaderNode);
this._groupHeaderNode = document.createElement("div");
this._groupHeaderNode.id = this.id + "-groupHeaderNode";
dojo.html.setClass(this._groupHeaderNode, "xformsViewRootHeader");
this.domNode.appendChild(this._groupHeaderNode);
var icon = document.createElement("img");
this.groupHeaderNode.appendChild(icon);
this._groupHeaderNode.appendChild(icon);
icon.setAttribute("src", alfresco_xforms_constants.WEBAPP_CONTEXT + "/images/icons/file_large.gif");
icon.align = "absmiddle";
icon.style.marginLeft = "5px";
icon.style.marginRight = "5px";
this.groupHeaderNode.appendChild(document.createTextNode(this.getLabel()));
this._groupHeaderNode.appendChild(document.createTextNode(this.getLabel()));
attach_point.appendChild(this.domNode);
this.domNode.childContainerNode = document.createElement("div");
@@ -2211,8 +2352,8 @@ dojo.declare("alfresco.xforms.Repeat",
continue;
}
var action = bw[i].getAction();
if (action.getType() != type)
var action = bw[i].getActions()[type];
if (!action)
{
continue;
}
@@ -2432,10 +2573,10 @@ dojo.declare("alfresco.xforms.Repeat",
// clear the border bottom for the group header since we'll be getting it
// from the repeat item border
this.groupHeaderNode.style.borderBottomWidth = "0px";
this._groupHeaderNode.style.borderBottomWidth = "0px";
this.groupHeaderNode.repeat = this;
dojo.event.connect(this.groupHeaderNode, "onclick", function(event)
this._groupHeaderNode.repeat = this;
dojo.event.connect(this._groupHeaderNode, "onclick", function(event)
{
if (event.target == event.currentTarget)
{
@@ -2445,7 +2586,7 @@ dojo.declare("alfresco.xforms.Repeat",
this.headerInsertRepeatItemImage = document.createElement("img");
this.headerInsertRepeatItemImage.repeat = this;
this.groupHeaderNode.appendChild(this.headerInsertRepeatItemImage);
this._groupHeaderNode.appendChild(this.headerInsertRepeatItemImage);
this.headerInsertRepeatItemImage.setAttribute("src",
alfresco_xforms_constants.WEBAPP_CONTEXT +
"/images/icons/plus.gif");
@@ -2469,14 +2610,14 @@ dojo.declare("alfresco.xforms.Repeat",
(this.getViewRoot().focusedRepeat == this ||
this.getViewRoot().focusedRepeat.isAncestorOf(this)))
{
if (!dojo.html.hasClass(this.groupHeaderNode, "xformsRepeatFocusedHeader"))
if (!dojo.html.hasClass(this._groupHeaderNode, "xformsRepeatFocusedHeader"))
{
dojo.html.addClass(this.groupHeaderNode, "xformsRepeatFocusedHeader");
dojo.html.addClass(this._groupHeaderNode, "xformsRepeatFocusedHeader");
}
}
else if (dojo.html.hasClass(this.groupHeaderNode, "xformsRepeatFocusedHeader"))
else if (dojo.html.hasClass(this._groupHeaderNode, "xformsRepeatFocusedHeader"))
{
dojo.html.removeClass(this.groupHeaderNode, "xformsRepeatFocusedHeader");
dojo.html.removeClass(this._groupHeaderNode, "xformsRepeatFocusedHeader");
}
for (var i = 0; i < this._children.length; i++)
@@ -2533,7 +2674,7 @@ dojo.declare("alfresco.xforms.Repeat",
var repeatItem = repeat.getChildAt(index);
this.setFocusedChild(repeatItem);
var trigger = this._getRepeatItemTrigger("insert", { position: "after" });
this.xform.fireAction(trigger.id);
trigger.fire();
}
},
@@ -2551,7 +2692,7 @@ dojo.declare("alfresco.xforms.Repeat",
{
this.setFocusedChild(null);
var trigger = this._getRepeatItemTrigger("insert", { position: "before" });
this.xform.fireAction(trigger.id);
trigger.fire();
}
}
},
@@ -2570,7 +2711,7 @@ dojo.declare("alfresco.xforms.Repeat",
var repeatItem = repeat.getChildAt(index);
this.setFocusedChild(repeatItem);
var trigger = this._getRepeatItemTrigger("delete", {});
this.xform.fireAction(trigger.id);
trigger.fire();
}
},
@@ -2666,22 +2807,42 @@ dojo.declare("alfresco.xforms.Repeat",
*/
dojo.declare("alfresco.xforms.Trigger",
alfresco.xforms.Widget,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
},
{
/////////////////////////////////////////////////////////////////
// methods & properties
/////////////////////////////////////////////////////////////////
/** TODO: DOCUMENT */
getAction: function()
getActions: function()
{
var action = _getElementsByTagNameNS(this.xformsNode,
if (typeof this._actions == "undefined")
{
var actionNode = _getElementsByTagNameNS(this.xformsNode,
alfresco_xforms_constants.XFORMS_NS,
alfresco_xforms_constants.XFORMS_PREFIX,
"action")[0];
return new alfresco.xforms.XFormsAction(this.xform, dojo.dom.firstElement(action));
this._actions = {};
for (var i = 0; i < actionNode.childNodes.length; i++)
{
if (actionNode.childNodes[i].nodeType != dojo.dom.ELEMENT_NODE)
{
continue;
}
var a = new alfresco.xforms.XFormsAction(this.xform, actionNode.childNodes[i]);
this._actions[a.getType()] = a;
}
}
return this._actions;
},
/** fires the xforms action associated with the trigger */
fire: function()
{
this.xform.fireAction(this.id);
},
/////////////////////////////////////////////////////////////////
@@ -2717,7 +2878,7 @@ dojo.declare("alfresco.xforms.Trigger",
/////////////////////////////////////////////////////////////////
_clickHandler: function(event)
{
this.xform.fireAction(this.id);
this.fire();
}
});
@@ -2726,8 +2887,7 @@ dojo.declare("alfresco.xforms.Trigger",
*/
dojo.declare("alfresco.xforms.Submit",
alfresco.xforms.Trigger,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
var submit_buttons = (this.id == "submit"
? _xforms_getSubmitButtons()
@@ -2773,6 +2933,7 @@ dojo.declare("alfresco.xforms.Submit",
false);
}
},
{
/////////////////////////////////////////////////////////////////
// DOM event handlers
@@ -2782,7 +2943,7 @@ dojo.declare("alfresco.xforms.Submit",
{
this.done = false;
_hide_errors();
this.xform.fireAction(this.id);
this.fire();
}
});
@@ -2791,8 +2952,7 @@ dojo.declare("alfresco.xforms.Submit",
*/
dojo.declare("alfresco.xforms.XFormsAction",
null,
{
initializer: function(xform, xformsNode)
function(xform, xformsNode)
{
this.xform = xform;
this.xformsNode = xformsNode;
@@ -2807,8 +2967,12 @@ dojo.declare("alfresco.xforms.XFormsAction",
attr.nodeValue;
}
}
if (this.getType() == "setvalue" && !this.properties["value"])
{
this.properties["value"] = this.xformsNode.firstChild.nodeValue;
}
},
{
/** Returns the action type. */
getType: function()
{
@@ -2826,8 +2990,7 @@ dojo.declare("alfresco.xforms.XFormsAction",
*/
dojo.declare("alfresco.xforms.XFormsEvent",
null,
{
initializer: function(node)
function(node)
{
this.type = node.nodeName;
this.targetId = node.getAttribute("targetId");
@@ -2836,10 +2999,13 @@ dojo.declare("alfresco.xforms.XFormsEvent",
for (var i = 0; i < node.childNodes.length; i++)
{
if (node.childNodes[i].nodeType == dojo.dom.ELEMENT_NODE)
{
this.properties[node.childNodes[i].getAttribute("name")] =
node.childNodes[i].getAttribute("value");
}
}
},
{
/** Returns the widget managing the specified target id. */
getTarget: function()
{
@@ -2857,8 +3023,7 @@ dojo.declare("alfresco.xforms.XFormsEvent",
*/
dojo.declare("alfresco.xforms.Binding",
null,
{
initializer: function(xformsNode, parent)
function(xformsNode, parent)
{
this.xformsNode = xformsNode;
this.id = this.xformsNode.getAttribute("id");
@@ -2885,7 +3050,7 @@ dojo.declare("alfresco.xforms.Binding",
this.parent = parent;
this.widgets = {};
},
{
/** Returns the expected schema type for this binding. */
getType: function()
{
@@ -2923,13 +3088,8 @@ dojo.declare("alfresco.xforms.Binding",
*/
dojo.declare("alfresco.xforms.XForm",
null,
{
/////////////////////////////////////////////////////////////////
// Initialization
/////////////////////////////////////////////////////////////////
/** Makes a request to the XFormsBean to load the xforms document. */
initializer: function()
function()
{
var req = AjaxHelper.createRequest(this,
"getXForm",
@@ -2940,6 +3100,10 @@ dojo.declare("alfresco.xforms.XForm",
});
AjaxHelper.sendRequest(req);
},
{
/////////////////////////////////////////////////////////////////
// Initialization
/////////////////////////////////////////////////////////////////
/** Parses the xforms document and produces the widget tree. */
_loadHandler: function(xformDocument)
@@ -3074,8 +3238,7 @@ dojo.declare("alfresco.xforms.XForm",
case alfresco_xforms_constants.XFORMS_PREFIX + ":switch":
return new alfresco.xforms.SwitchGroup(this, xformsNode);
case alfresco_xforms_constants.XFORMS_PREFIX + ":case":
return new alfresco.xforms.Group(this, xformsNode);
return new alfresco.xforms.CaseGroup(this, xformsNode);
default:
throw new Error("unknown type " + xformsNode.nodeName);
}
@@ -3086,8 +3249,10 @@ dojo.declare("alfresco.xforms.XForm",
{
for (var i = 0; i < xformsNode.childNodes.length; i++)
{
if (xformsNode.childNodes[i].nodeType == dojo.dom.ELEMENT_NODE)
if (xformsNode.childNodes[i].nodeType != dojo.dom.ELEMENT_NODE)
{
continue;
}
dojo.debug("loading " + xformsNode.childNodes[i].nodeName +
" into " + parentWidget.id);
if (xformsNode.childNodes[i].getAttribute(alfresco_xforms_constants.ALFRESCO_PREFIX +
@@ -3108,7 +3273,6 @@ dojo.declare("alfresco.xforms.XForm",
}
}
}
}
},
/** Loads all bindings from the xforms document. */