fixed bug with checkboxes

partially removed need for sample instance xml - i'm doing a bunch of hacks at the moment to get around it - basically using xmlbeans to generate the sample xml, and then cleaning it up.  ended up not needing to do insane things in javascript with this approach.  emailed joern at chiba to see if he has suggestions for how others deal with this issue.
serializing the template configuration using object serialization for now.  it'll work good for the demo and we'll do something more robust/human readable post demo.  this required a bunch of refactoring and springifying the TemplateService, but we're now reading back xsds and xsls from the repository which is sorta a nice thing i think.
remove the preview form wizard step from create xml content type flow.
tried getting rid of a temporary file in generating the xform but failed.  need to find a way to get an url to a noderef that the xform can use to reference the xsd.  emailed london people about that.  but still did some refactoring along those lines.



git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/WCM-DEV2/root@3558 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Ariel Backenroth
2006-08-21 22:34:59 +00:00
parent d385022212
commit 80bf0acd64
18 changed files with 472 additions and 224 deletions

View File

@@ -30,5 +30,12 @@
<ref bean="DictionaryService" /> <ref bean="DictionaryService" />
</constructor-arg> </constructor-arg>
</bean> </bean>
<!-- NOTE: This references a bean in the repository Spring configuration -->
<bean id="templatingSerivce" class="org.alfresco.web.templating.TemplatingService">
<constructor-arg>
<ref bean="ContentService" />
</constructor-arg>
</bean>
</beans> </beans>

View File

@@ -173,12 +173,14 @@
description-id="create_xml_content_type_step1_desc" description-id="create_xml_content_type_step1_desc"
instruction-id="default_instruction" /> instruction-id="default_instruction" />
</step> </step>
<!--
<step name="edit_schema" title-id="edit_xml_schema" description-id="create_xml_content_type_step2_desc"> <step name="edit_schema" title-id="edit_xml_schema" description-id="create_xml_content_type_step2_desc">
<page path="/jsp/content/create-xml-content-type-wizard/edit.jsp" <page path="/jsp/content/create-xml-content-type-wizard/edit.jsp"
title-id="create_xml_content_type_step2_title" title-id="create_xml_content_type_step2_title"
description-id="create_xml_content_type_step2_desc" description-id="create_xml_content_type_step2_desc"
instruction-id="default_instruction" /> instruction-id="default_instruction" />
</step> </step>
-->
<step name="configure_presentation_templates" <step name="configure_presentation_templates"
title-id="configure_presentation_templates" title-id="configure_presentation_templates"
description-id="create_xml_content_type_step2_desc"> description-id="create_xml_content_type_step2_desc">

View File

@@ -566,16 +566,16 @@ public class CheckinCheckoutBean
{ {
// make content available to the editing screen // make content available to the editing screen
String contentString = reader.getContentString(); String contentString = reader.getContentString();
setDocumentContent(contentString); setDocumentContent(contentString);
setEditorOutput(contentString); setEditorOutput(contentString);
// navigate to appropriate screen // navigate to appropriate screen
FacesContext fc = FacesContext.getCurrentInstance(); FacesContext fc = FacesContext.getCurrentInstance();
this.navigator.setupDispatchContext(node); this.navigator.setupDispatchContext(node);
String s = (MimetypeMap.MIMETYPE_XML.equals(mimetype) String s = (MimetypeMap.MIMETYPE_XML.equals(mimetype)
? "editXmlInline" ? "editXmlInline"
: "editTextInline"); : "editTextInline");
fc.getApplication().getNavigationHandler().handleNavigation(fc, null, s); fc.getApplication().getNavigationHandler().handleNavigation(fc, null, s);
} }
else else
{ {

View File

@@ -60,8 +60,6 @@ public class CreateContentWizard extends BaseContentWizard
private static final Log LOGGER = private static final Log LOGGER =
LogFactory.getLog(CreateContentWizard.class); LogFactory.getLog(CreateContentWizard.class);
public static final org.alfresco.service.namespace.QName TT_QNAME =
org.alfresco.service.namespace.QName.createQName(org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI, "tt");
// ------------------------------------------------------------------------------ // ------------------------------------------------------------------------------
// Wizard implementation // Wizard implementation
@@ -75,45 +73,20 @@ public class CreateContentWizard extends BaseContentWizard
if (this.templateTypeName != null) if (this.templateTypeName != null)
{ {
LOGGER.debug("generating template output for " + this.templateTypeName); LOGGER.debug("generating template output for " + this.templateTypeName);
this.nodeService.setProperty(this.createdNode, TT_QNAME, this.templateTypeName); this.nodeService.setProperty(this.createdNode,
TemplatingService.TT_QNAME,
this.templateTypeName);
TemplatingService ts = TemplatingService.getInstance(); TemplatingService ts = TemplatingService.getInstance();
TemplateType tt = this.getTemplateType(); TemplateType tt = this.getTemplateType();
if (tt.getOutputMethods().size() != 0) if (tt.getOutputMethods().size() != 0)
{ {
try { OutputUtil.generate(ts.parseXML(this.content),
// get the node ref of the node that will contain the content tt,
NodeRef containerNodeRef = this.getContainerNodeRef(); this.fileName,
final String fileName = this.fileName + "-generated.html"; this.getContainerNodeRef(),
FileInfo fileInfo = this.fileFolderService,
this.fileFolderService.create(containerNodeRef, this.contentService,
fileName, this.nodeService);
ContentModel.TYPE_CONTENT);
NodeRef fileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " +
fileName);
// get a writer for the content and put the file
ContentWriter writer = contentService.getWriter(fileNodeRef,
ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype("text/html");
writer.setEncoding("UTF-8");
TemplateOutputMethod tom = tt.getOutputMethods().get(0);
OutputStreamWriter out =
new OutputStreamWriter(writer.getContentOutputStream());
tom.generate(ts.parseXML(this.content), tt, out);
out.close();
this.nodeService.setProperty(fileNodeRef, TT_QNAME, this.templateTypeName);
LOGGER.debug("generated " + fileName + " using " + tom);
}
catch (Exception e)
{
e.printStackTrace();
throw e;
}
} }
} }

View File

@@ -78,14 +78,14 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
this.fileFolderService.create(containerNodeRef, this.fileFolderService.create(containerNodeRef,
this.getSchemaFileName(), this.getSchemaFileName(),
ContentModel.TYPE_CONTENT); ContentModel.TYPE_CONTENT);
NodeRef fileNodeRef = fileInfo.getNodeRef(); final NodeRef schemaFileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled()) if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " + LOGGER.debug("Created file node for file: " +
this.getSchemaFileName()); this.getSchemaFileName());
// get a writer for the content and put the file // get a writer for the content and put the file
ContentWriter writer = contentService.getWriter(fileNodeRef, ContentWriter writer = contentService.getWriter(schemaFileNodeRef,
ContentModel.PROP_CONTENT, true); ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding // set the mimetype and encoding
writer.setMimetype("text/xml"); writer.setMimetype("text/xml");
@@ -95,14 +95,14 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
fileInfo = this.fileFolderService.create(containerNodeRef, fileInfo = this.fileFolderService.create(containerNodeRef,
this.getPresentationTemplateFileName(), this.getPresentationTemplateFileName(),
ContentModel.TYPE_CONTENT); ContentModel.TYPE_CONTENT);
fileNodeRef = fileInfo.getNodeRef(); final NodeRef presentationTemplateFileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled()) if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " + LOGGER.debug("Created file node for file: " +
this.getPresentationTemplateFileName()); this.getPresentationTemplateFileName());
// get a writer for the content and put the file // get a writer for the content and put the file
writer = contentService.getWriter(fileNodeRef, writer = contentService.getWriter(presentationTemplateFileNodeRef,
ContentModel.PROP_CONTENT, true); ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding // set the mimetype and encoding
writer.setMimetype("text/xml"); writer.setMimetype("text/xml");
@@ -110,7 +110,14 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
writer.putContent(this.getPresentationTemplateFile()); writer.putContent(this.getPresentationTemplateFile());
final TemplatingService ts = TemplatingService.getInstance(); final TemplatingService ts = TemplatingService.getInstance();
ts.registerTemplateType(this.getTemplateType()); final String rootTagName =
this.getSchemaFileName().replaceAll("([^\\.])\\..+", "$1");
final TemplateType tt = ts.newTemplateType(rootTagName, schemaFileNodeRef);
if (this.getPresentationTemplateFile() != null)
{
tt.addOutputMethod(new XSLTOutputMethod(presentationTemplateFileNodeRef));
}
ts.registerTemplateType(tt);
// return the default outcome // return the default outcome
return outcome; return outcome;
@@ -278,25 +285,6 @@ public class CreateXmlContentTypeWizard extends BaseWizardBean
{ {
return this.getFile("pt"); return this.getFile("pt");
} }
public TemplateType getTemplateType()
throws ParserConfigurationException,
SAXException,
IOException
{
if (this.getSchemaFile() == null)
return null;
final TemplatingService ts = TemplatingService.getInstance();
final String rootTagName =
this.getSchemaFileName().replaceAll("([^\\.])\\..+", "$1");
final Document d = ts.parseXML(this.getSchemaFile());
final TemplateType result = ts.newTemplateType(rootTagName, d);
if (this.getPresentationTemplateFile() != null)
{
result.addOutputMethod(new XSLTOutputMethod(this.getPresentationTemplateFile()));
}
return result;
}
/** /**
* @return Returns a list of mime types to allow the user to select from * @return Returns a list of mime types to allow the user to select from

View File

@@ -0,0 +1,118 @@
/*
* 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;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.ResourceBundle;
import javax.faces.context.FacesContext;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import org.alfresco.config.Config;
import org.alfresco.config.ConfigElement;
import org.alfresco.config.ConfigService;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.web.app.AlfrescoNavigationHandler;
import org.alfresco.web.app.Application;
import org.alfresco.web.bean.repository.Node;
import org.alfresco.web.data.IDataContainer;
import org.alfresco.web.data.QuickSort;
import org.alfresco.web.templating.*;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.alfresco.model.ContentModel;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.ContentWriter;
import java.io.OutputStreamWriter;
import org.alfresco.web.app.servlet.FacesHelper;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeService;
import org.w3c.dom.Document;
import org.alfresco.repo.avm.*;
public class OutputUtil
{
private static final Log LOGGER = LogFactory.getLog(OutputUtil.class);
public static void generate(Document xml,
TemplateType tt,
String fileName,
NodeRef containerNodeRef,
FileFolderService fileFolderService,
ContentService contentService,
NodeService nodeService)
throws Exception
{
try {
// get the node ref of the node that will contain the content
fileName = fileName + "-generated.html";
FileInfo fileInfo =
fileFolderService.create(containerNodeRef,
fileName,
ContentModel.TYPE_CONTENT);
NodeRef fileNodeRef = fileInfo.getNodeRef();
if (LOGGER.isDebugEnabled())
LOGGER.debug("Created file node for file: " +
fileName);
// get a writer for the content and put the file
ContentWriter writer = contentService.getWriter(fileNodeRef,
ContentModel.PROP_CONTENT, true);
// set the mimetype and encoding
writer.setMimetype("text/html");
writer.setEncoding("UTF-8");
TemplateOutputMethod tom = tt.getOutputMethods().get(0);
OutputStreamWriter out =
new OutputStreamWriter(writer.getContentOutputStream());
tom.generate(xml, tt, out);
out.close();
nodeService.setProperty(fileNodeRef,
TemplatingService.TT_QNAME,
tt.getName());
LOGGER.debug("generated " + fileName + " using " + tom);
AVMService avmService = AVMContext.fgInstance.getAVMService();
String parentPath = "repo-1:/repo-1/alice/appBase/avm_webapps/my_webapp";
try
{
out = new OutputStreamWriter(avmService.createFile(parentPath, fileName));
}
catch (AVMExistsException e)
{
out = new OutputStreamWriter(avmService.getFileOutputStream(parentPath + "/" + fileName));
}
LOGGER.debug("generating " + fileName + " to avm");
tom.generate(xml, tt, out);
out.close();
}
catch (Exception e)
{
LOGGER.error(e);
e.printStackTrace();
throw e;
}
}
}

View File

@@ -17,9 +17,11 @@
package org.alfresco.web.templating; package org.alfresco.web.templating;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import java.io.Serializable;
import java.io.Writer; import java.io.Writer;
public interface TemplateInputMethod public interface TemplateInputMethod
extends Serializable
{ {
public void generate(final InstanceData instanceData, public void generate(final InstanceData instanceData,
final TemplateType tt, final TemplateType tt,

View File

@@ -16,11 +16,12 @@
*/ */
package org.alfresco.web.templating; package org.alfresco.web.templating;
import java.io.Serializable;
import java.io.Writer; import java.io.Writer;
import org.w3c.dom.Document; import org.w3c.dom.Document;
public interface TemplateOutputMethod public interface TemplateOutputMethod
extends Serializable
{ {
public void generate(final Document xmlContent, public void generate(final Document xmlContent,

View File

@@ -18,14 +18,21 @@ package org.alfresco.web.templating;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import java.util.List; import java.util.List;
import java.io.Serializable;
//import org.alfresco.service.cmr.repository.NodeRef;
public interface TemplateType public interface TemplateType
extends Serializable
{ {
public String getName(); public String getName();
public Document getSchema(); public Document getSchema();
// public void setSchemaNodeRef(final NodeRef nodeRef);
//
// public NodeRef getSchemaNodeRef();
public Document getSampleXml(final String rootTagName); public Document getSampleXml(final String rootTagName);
public List<TemplateInputMethod> getInputMethods(); public List<TemplateInputMethod> getInputMethods();

View File

@@ -34,16 +34,86 @@ import org.xml.sax.SAXException;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
public class TemplatingService import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.model.ContentModel;
import org.alfresco.util.TempFileProvider;
public final class TemplatingService
implements Serializable
{ {
////////////////////////////////////////////////////////////////////////////
private static class Configuration
{
private final static File CONFIG_FILE =
new File(TempFileProvider.getTempDir(), "templating_configuration.xml");
public static void load()
throws IOException
{
if (!CONFIG_FILE.exists())
return;
final TemplatingService ts = TemplatingService.getInstance();
final ObjectInputStream out = new ObjectInputStream(new FileInputStream(CONFIG_FILE));
try
{
final List<TemplateType> tt = (List<TemplateType>)out.readObject();
for (TemplateType t : tt)
{
ts.registerTemplateType(t);
}
out.close();
}
catch (ClassNotFoundException cnfe)
{
assert false : cnfe;
TemplatingService.LOGGER.error(cnfe);
}
}
public static void save()
throws IOException
{
if (!CONFIG_FILE.exists())
CONFIG_FILE.createNewFile();
final TemplatingService ts = TemplatingService.getInstance();
final ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(CONFIG_FILE));
out.writeObject(ts.getTemplateTypes());
out.close();
}
}
////////////////////////////////////////////////////////////////////////////
public static final org.alfresco.service.namespace.QName TT_QNAME =
org.alfresco.service.namespace.QName.createQName(org.alfresco.service.namespace.NamespaceService.CONTENT_MODEL_1_0_URI, "tt");
private static final Log LOGGER = LogFactory.getLog(TemplatingService.class); private static final Log LOGGER = LogFactory.getLog(TemplatingService.class);
private final static TemplatingService INSTANCE = new TemplatingService(); private static TemplatingService INSTANCE;
private ArrayList<TemplateType> templateTypes = private ArrayList<TemplateType> templateTypes =
new ArrayList<TemplateType>(); new ArrayList<TemplateType>();
private final ContentService contentService;
private TemplatingService() public TemplatingService(final ContentService contentService)
{ {
this.contentService = contentService;
if (INSTANCE == null)
{
INSTANCE = this;
try
{
Configuration.load();
}
catch (IOException ioe)
{
LOGGER.error(ioe);
}
}
} }
public static TemplatingService getInstance() public static TemplatingService getInstance()
@@ -71,12 +141,20 @@ public class TemplatingService
public void registerTemplateType(final TemplateType tt) public void registerTemplateType(final TemplateType tt)
{ {
this.templateTypes.add(tt); this.templateTypes.add(tt);
try
{
Configuration.save();
}
catch (IOException ioe)
{
LOGGER.error(ioe);
}
} }
public TemplateType newTemplateType(final String name, public TemplateType newTemplateType(final String name,
final Document schema) final NodeRef schemaNodeRef)
{ {
return new TemplateTypeImpl(name, schema); return new TemplateTypeImpl(name, schemaNodeRef);
} }
public Document newDocument() public Document newDocument()
@@ -125,7 +203,6 @@ public class TemplatingService
public void writeXML(final Node n, final File output) public void writeXML(final Node n, final File output)
throws IOException throws IOException
{ {
this.writeXML(n, new FileWriter(output)); this.writeXML(n, new FileWriter(output));
} }
@@ -144,6 +221,17 @@ public class TemplatingService
return this.parseXML(new ByteArrayInputStream(source.getBytes())); return this.parseXML(new ByteArrayInputStream(source.getBytes()));
} }
public Document parseXML(final NodeRef nodeRef)
throws ParserConfigurationException,
SAXException,
IOException
{
final ContentReader contentReader =
this.contentService.getReader(nodeRef, ContentModel.TYPE_CONTENT);
final InputStream in = contentReader.getContentInputStream();
return this.parseXML(in);
}
public Document parseXML(final File source) public Document parseXML(final File source)
throws ParserConfigurationException, throws ParserConfigurationException,
SAXException, SAXException,

View File

@@ -19,6 +19,7 @@ package org.alfresco.web.templating.xforms;
import java.io.*; import java.io.*;
import java.util.*; import java.util.*;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.util.TempFileProvider; import org.alfresco.util.TempFileProvider;
import org.alfresco.web.templating.*; import org.alfresco.web.templating.*;
@@ -27,23 +28,35 @@ import org.alfresco.web.templating.xforms.schemabuilder.FormBuilderException;
import org.apache.xmlbeans.*; import org.apache.xmlbeans.*;
import org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil; import org.apache.xmlbeans.impl.xsd2inst.SampleXmlUtil;
import org.w3c.dom.Document; import org.w3c.dom.*;
import org.w3c.dom.Node;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.alfresco.model.ContentModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class TemplateTypeImpl public class TemplateTypeImpl
implements TemplateType implements TemplateType
{ {
private static final Log LOGGER = LogFactory.getLog(TemplateTypeImpl.class);
private final Document schema; private transient Document schema;
private final NodeRef schemaNodeRef;
private final String name; private final String name;
private final LinkedList outputMethods = new LinkedList(); private final LinkedList<TemplateOutputMethod> outputMethods =
new LinkedList<TemplateOutputMethod>();
private final static LinkedList<TemplateInputMethod> INPUT_METHODS =
new LinkedList<TemplateInputMethod>();
static
{
INPUT_METHODS.add(new XFormsInputMethod());
}
public TemplateTypeImpl(final String name, public TemplateTypeImpl(final String name,
final Document schema) final NodeRef schemaNodeRef)
{ {
this.name = name; this.name = name;
this.schema = schema; this.schemaNodeRef = schemaNodeRef;
} }
public String getName() public String getName()
@@ -53,6 +66,18 @@ public class TemplateTypeImpl
public Document getSchema() public Document getSchema()
{ {
if (this.schema == null)
{
final TemplatingService ts = TemplatingService.getInstance();
try
{
this.schema = ts.parseXML(this.schemaNodeRef);
}
catch (Exception e)
{
LOGGER.error(e);
}
}
return this.schema; return this.schema;
} }
@@ -63,15 +88,11 @@ public class TemplateTypeImpl
final XmlObject[] schemas = new XmlObject[1]; final XmlObject[] schemas = new XmlObject[1];
try try
{ {
final File schemaFile = TempFileProvider.createTempFile("alfresco", ".schema"); schemas[0] = XmlObject.Factory.parse(this.getSchema(), xmlOptions);
TemplatingService.getInstance().writeXML(this.schema, schemaFile);
schemas[0] = XmlObject.Factory.parse(schemaFile, xmlOptions);
schemaFile.delete();
} }
catch (Exception e) catch (XmlException xmle)
{ {
System.err.println("Can not load schema file: " + schema + ": "); LOGGER.error(xmle);
e.printStackTrace();
} }
final XmlOptions compileOptions = new XmlOptions(); final XmlOptions compileOptions = new XmlOptions();
@@ -88,8 +109,7 @@ public class TemplateTypeImpl
} }
catch (XmlException xmle) catch (XmlException xmle)
{ {
xmle.printStackTrace(); LOGGER.error(xmle);
return null;
} }
if (sts == null) if (sts == null)
@@ -110,11 +130,18 @@ public class TemplateTypeImpl
if (elem == null) if (elem == null)
throw new NullPointerException("Could not find a global element with name \"" + rootTagName + "\""); throw new NullPointerException("Could not find a global element with name \"" + rootTagName + "\"");
final String result = SampleXmlUtil.createSampleForType(elem); final String xmlString = SampleXmlUtil.createSampleForType(elem);
try try
{ {
final TemplatingService ts = TemplatingService.getInstance(); final TemplatingService ts = TemplatingService.getInstance();
return ts.parseXML(new ByteArrayInputStream(result.getBytes())); final Document d = ts.parseXML(new ByteArrayInputStream(xmlString.getBytes()));
System.out.println("sample xml:");
System.out.println(ts.writeXMLToString(d));
TemplateTypeImpl.cleanUpSampleXml(d.getDocumentElement());
System.out.println("cleaned up xml:");
System.out.println(ts.writeXMLToString(d));
return d;
} }
catch (ParserConfigurationException pce) catch (ParserConfigurationException pce)
{ {
@@ -133,11 +160,32 @@ public class TemplateTypeImpl
} }
} }
private static void cleanUpSampleXml(final Node n)
{
if (n instanceof CharacterData)
{
// System.out.println("replacing data " + ((CharacterData)n).getData());
((CharacterData)n).setData(" ");
}
else if (n instanceof Element)
{
final NamedNodeMap attrs = n.getAttributes();
for (int i = 0; i < attrs.getLength(); i++)
{
// System.out.println("not replacing data " + ((Attr)n).getValue());
// ((Attr)attrs.item(i)).setValue("");
}
}
final NodeList nl = n.getChildNodes();
for (int i = 0; i < nl.getLength(); i++)
{
TemplateTypeImpl.cleanUpSampleXml(nl.item(i));
}
}
public List<TemplateInputMethod> getInputMethods() public List<TemplateInputMethod> getInputMethods()
{ {
return (List<TemplateInputMethod>)Arrays.asList(new TemplateInputMethod[] { return INPUT_METHODS;
new XFormsInputMethod()
});
} }
public void addOutputMethod(TemplateOutputMethod output) public void addOutputMethod(TemplateOutputMethod output)

View File

@@ -21,7 +21,6 @@ import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.ServletContext; import javax.servlet.ServletContext;
import org.alfresco.util.TempFileProvider;
import org.alfresco.web.templating.*; import org.alfresco.web.templating.*;
import org.alfresco.web.templating.xforms.schemabuilder.*; import org.alfresco.web.templating.xforms.schemabuilder.*;
import org.alfresco.web.bean.ajax.XFormsBean; import org.alfresco.web.bean.ajax.XFormsBean;
@@ -105,16 +104,6 @@ public class XFormsInputMethod
if (xmlContent == null) if (xmlContent == null)
xmlContent = tt.getSampleXml(tt.getName()); xmlContent = tt.getSampleXml(tt.getName());
final TemplatingService ts = TemplatingService.getInstance(); final TemplatingService ts = TemplatingService.getInstance();
final File schemaFile = TempFileProvider.createTempFile("alfresco", ".schema");
try
{
ts.writeXML(tt.getSchema(), schemaFile);
}
catch (IOException ioe)
{
assert false : ioe.getMessage();
LOGGER.error(ioe);
}
final FacesContext fc = FacesContext.getCurrentInstance(); final FacesContext fc = FacesContext.getCurrentInstance();
final HttpServletRequest request = (HttpServletRequest) final HttpServletRequest request = (HttpServletRequest)
fc.getExternalContext().getRequest(); fc.getExternalContext().getRequest();
@@ -124,16 +113,16 @@ public class XFormsInputMethod
LOGGER.debug("using baseUrl " + baseUrl + " for schemaformbuilder"); LOGGER.debug("using baseUrl " + baseUrl + " for schemaformbuilder");
final SchemaFormBuilder builder = final SchemaFormBuilder builder =
new BaseSchemaFormBuilder(getDocumentElementNameNoNS(xmlContent), new BaseSchemaFormBuilder(tt.getName(),
xmlContent, xmlContent,
request.getContextPath() + "/ajax/invoke/XFormsBean.handleAction", request.getContextPath() + "/ajax/invoke/XFormsBean.handleAction",
"post", SchemaFormBuilder.SUBMIT_METHOD_POST,
new XHTMLWrapperElementsBuilder(), new XHTMLWrapperElementsBuilder(),
null, null,
baseUrl, baseUrl,
true); true);
LOGGER.debug("building xform for schema " + schemaFile.getPath()); LOGGER.debug("building xform for schema " + tt.getName());
final Document result = builder.buildForm(schemaFile.getPath()); final Document result = builder.buildForm(tt); //schemaFile.getPath());
// xmlContentFile.delete(); // xmlContentFile.delete();
// schemaFile.delete(); // schemaFile.delete();
return result; return result;

View File

@@ -35,16 +35,17 @@ import javax.xml.transform.stream.StreamResult;
import org.w3c.dom.Document; import org.w3c.dom.Document;
import org.w3c.dom.Node; import org.w3c.dom.Node;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
import org.alfresco.service.cmr.repository.NodeRef;
public class XSLTOutputMethod public class XSLTOutputMethod
implements TemplateOutputMethod implements TemplateOutputMethod
{ {
private final File file; private final NodeRef nodeRef;
public XSLTOutputMethod(final File f) public XSLTOutputMethod(final NodeRef nodeRef)
{ {
this.file = f; this.nodeRef = nodeRef;
} }
public void generate(final Document xmlContent, public void generate(final Document xmlContent,
@@ -58,7 +59,7 @@ public class XSLTOutputMethod
{ {
TransformerFactory tf = TransformerFactory.newInstance(); TransformerFactory tf = TransformerFactory.newInstance();
TemplatingService ts = TemplatingService.getInstance(); TemplatingService ts = TemplatingService.getInstance();
DOMSource source = new DOMSource(ts.parseXML(this.file)); DOMSource source = new DOMSource(ts.parseXML(this.nodeRef));
final Templates templates = tf.newTemplates(source); final Templates templates = tf.newTemplates(source);
final Transformer t = templates.newTransformer(); final Transformer t = templates.newTransformer();
final StreamResult result = new StreamResult(out); final StreamResult result = new StreamResult(out);

View File

@@ -24,7 +24,7 @@ import org.chiba.xml.xforms.NamespaceCtx;
import org.w3c.dom.*; import org.w3c.dom.*;
import org.w3c.dom.bootstrap.DOMImplementationRegistry; import org.w3c.dom.bootstrap.DOMImplementationRegistry;
import org.xml.sax.InputSource; import org.xml.sax.InputSource;
import org.alfresco.web.templating.*;
import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.ParserConfigurationException;
@@ -33,7 +33,7 @@ import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.StringWriter; import java.io.StringWriter;
import java.util.*; import java.util.*;
import org.alfresco.util.TempFileProvider;
/* /*
* Search for TODO for things remaining to-do in this implementation. * Search for TODO for things remaining to-do in this implementation.
* *
@@ -199,32 +199,6 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
PROPERTY_PREFIX + "group@border"; PROPERTY_PREFIX + "group@border";
private static final String DEFAULT_GROUP_BORDER = "0"; private static final String DEFAULT_GROUP_BORDER = "0";
/**
* Prossible values of the "@method" on the "submission" element
*/
public static final String SUBMIT_METHOD_POST = "post";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_PUT = "put";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_GET = "get";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_FORM_DATA_POST = "form-data-post";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_URLENCODED_POST =
"urlencoded-post";
/** /**
* __UNDOCUMENTED__ * __UNDOCUMENTED__
*/ */
@@ -418,33 +392,6 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
return _submitMethod; return _submitMethod;
} }
private void loadSchema(String inputURI)
throws ClassNotFoundException,
InstantiationException,
IllegalAccessException
{
// Get DOM Implementation using DOM Registry
System.setProperty(DOMImplementationRegistry.PROPERTY,
"org.apache.xerces.dom.DOMXSImplementationSourceImpl");
DOMImplementationRegistry registry =
DOMImplementationRegistry.newInstance();
Object o = registry.getDOMImplementation("XS-Loader");
if (o instanceof XSImplementation)
{
XSImplementation impl = (XSImplementation) o;
XSLoader schemaLoader = impl.createXSLoader(null);
this.schema = schemaLoader.loadURI(inputURI);
}
else if (o != null)
{
if (LOGGER.isDebugEnabled())
LOGGER.debug("DOMImplementation is not a XSImplementation: "
+ o.getClass().getName());
throw new RuntimeException(o.getClass().getName() + " is not a XSImplementation");
}
}
/** /**
* builds a form from a XML schema. * builds a form from a XML schema.
* *
@@ -452,37 +399,62 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
* @return __UNDOCUMENTED__ * @return __UNDOCUMENTED__
* @throws FormBuilderException __UNDOCUMENTED__ * @throws FormBuilderException __UNDOCUMENTED__
*/ */
public Document buildForm(String inputFile) public Document buildForm(final TemplateType tt)
throws FormBuilderException { throws FormBuilderException {
try { try {
this.loadSchema(new File(inputFile).toURI().toString()); // Get DOM Implementation using DOM Registry
this.buildTypeTree(schema); System.setProperty(DOMImplementationRegistry.PROPERTY,
"org.apache.xerces.dom.DOMXSImplementationSourceImpl");
final DOMImplementationRegistry registry =
DOMImplementationRegistry.newInstance();
final XSImplementation xsImpl = (XSImplementation)
registry.getDOMImplementation("XS-Loader");
// final DOMImplementationLS lsImpl = (DOMImplementationLS)
// registry.getDOMImplementation("XML 1.0 LS 3.0");
// LSInput in = lsImpl.createLSInput();
// in.setCharacterStrea
final TemplatingService ts = TemplatingService.getInstance();
final File schemaFile = TempFileProvider.createTempFile("alfresco", ".schema");
try
{
ts.writeXML(tt.getSchema(), schemaFile);
}
catch (IOException ioe)
{
assert false : ioe.getMessage();
LOGGER.error(ioe);
}
final String inputURI = schemaFile.toURI().toString();
final XSLoader schemaLoader = xsImpl.createXSLoader(null);
this.schema = schemaLoader.loadURI(inputURI);
this.buildTypeTree(this.schema);
//refCounter = 0; //refCounter = 0;
counter = new HashMap(); this.counter = new HashMap();
Document xForm = createFormTemplate(_rootTagName,
_rootTagName + " Form",
getProperty(CSS_STYLE_PROP,
DEFAULT_CSS_STYLE_PROP));
final Document xForm = createFormTemplate(_rootTagName,
_rootTagName + " Form",
getProperty(CSS_STYLE_PROP,
DEFAULT_CSS_STYLE_PROP));
//this.buildInheritenceTree(schema); //this.buildInheritenceTree(schema);
Element envelopeElement = xForm.getDocumentElement(); Element envelopeElement = xForm.getDocumentElement();
//Element formSection = (Element) envelopeElement.getElementsByTagNameNS(CHIBA_NS, "form").item(0); //Element formSection = (Element) envelopeElement.getElementsByTagNameNS(CHIBA_NS, "form").item(0);
//Element formSection =(Element) envelopeElement.getElementsByTagName("body").item(0); //Element formSection =(Element) envelopeElement.getElementsByTagName("body").item(0);
//find form element: last element created //find form element: last element created
NodeList children = xForm.getDocumentElement().getChildNodes(); final NodeList children = xForm.getDocumentElement().getChildNodes();
Element formSection = (Element)children.item(children.getLength() - 1); final Element formSection = (Element)children.item(children.getLength() - 1);
Element modelSection = (Element) final Element modelSection = (Element)
envelopeElement.getElementsByTagNameNS(XFORMS_NS, "model").item(0); envelopeElement.getElementsByTagNameNS(XFORMS_NS, "model").item(0);
//add XMLSchema if we use schema types //add XMLSchema if we use schema types
if (_useSchemaTypes && modelSection != null) if (_useSchemaTypes && modelSection != null)
modelSection.setAttributeNS(XFORMS_NS, modelSection.setAttributeNS(XFORMS_NS,
this.getXFormsNSPrefix() + "schema", this.getXFormsNSPrefix() + "schema",
new File(inputFile).toURI().toString()); inputURI);
//change stylesheet //change stylesheet
String stylesheet = this.getStylesheet(); String stylesheet = this.getStylesheet();
@@ -502,7 +474,7 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
//TODO: find a better way to find the targetNamespace //TODO: find a better way to find the targetNamespace
try try
{ {
Document domDoc = DOMUtil.parseXmlFile(inputFile, true, false); final Document domDoc = tt.getSchema();
if (domDoc != null) if (domDoc != null)
{ {
Element root = domDoc.getDocumentElement(); Element root = domDoc.getDocumentElement();
@@ -1167,14 +1139,14 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
int[] occurance = this.getOccurance(owner); int[] occurance = this.getOccurance(owner);
addSimpleType(xForm, addSimpleType(xForm,
modelSection, modelSection,
formSection, formSection,
controlType, controlType,
owner.getName(), owner.getName(),
owner, owner,
pathToRoot, pathToRoot,
occurance[0], occurance[0],
occurance[1]); occurance[1]);
} }
private void addAttributeSet(Document xForm, private void addAttributeSet(Document xForm,
@@ -1189,20 +1161,22 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
if (attrUses != null) { if (attrUses != null) {
int nbAttr = attrUses.getLength(); int nbAttr = attrUses.getLength();
for (int i = 0; i < nbAttr; i++) { for (int i = 0; i < nbAttr; i++) {
XSAttributeUse currentAttributeUse = XSAttributeUse currentAttributeUse = (XSAttributeUse)attrUses.item(i);
(XSAttributeUse) attrUses.item(i);
XSAttributeDeclaration currentAttribute = XSAttributeDeclaration currentAttribute =
currentAttributeUse.getAttrDeclaration(); currentAttributeUse.getAttrDeclaration();
//test if extended ! //test if extended !
if (checkIfExtension && this.doesAttributeComeFromExtension(currentAttributeUse, controlType)) { if (checkIfExtension &&
if (LOGGER.isDebugEnabled()) { this.doesAttributeComeFromExtension(currentAttributeUse, controlType))
{
if (LOGGER.isDebugEnabled())
{
LOGGER.debug("This attribute comes from an extension: recopy form controls. \n Model section: "); LOGGER.debug("This attribute comes from an extension: recopy form controls. \n Model section: ");
DOMUtil.prettyPrintDOM(modelSection); DOMUtil.prettyPrintDOM(modelSection);
} }
String attributeName = currentAttributeUse.getName(); String attributeName = currentAttributeUse.getName();
if (attributeName == null || attributeName.equals("")) if (attributeName == null || attributeName.length() == 0)
attributeName = currentAttributeUse.getAttrDeclaration().getName(); attributeName = currentAttributeUse.getAttrDeclaration().getName();
//find the existing bind Id //find the existing bind Id
@@ -1248,7 +1222,7 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
} else { } else {
String newPathToRoot; String newPathToRoot;
if ((pathToRoot == null) || pathToRoot.equals("")) { if (pathToRoot == null || pathToRoot.length() == 0) {
newPathToRoot = "@" + currentAttribute.getName(); newPathToRoot = "@" + currentAttribute.getName();
} else if (pathToRoot.endsWith("/")) { } else if (pathToRoot.endsWith("/")) {
newPathToRoot = newPathToRoot =
@@ -1266,11 +1240,11 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
}*/ }*/
addSimpleType(xForm, addSimpleType(xForm,
modelSection, modelSection,
formSection, formSection,
simpleType, simpleType,
currentAttributeUse, currentAttributeUse,
newPathToRoot); newPathToRoot);
} }
} }
} }
@@ -1411,12 +1385,12 @@ public abstract class AbstractSchemaFormBuilder implements SchemaFormBuilder {
//attributes //attributes
addAttributeSet(xForm, addAttributeSet(xForm,
modelSection, modelSection,
formSection, formSection,
controlType, controlType,
owner, owner,
pathToRoot, pathToRoot,
checkIfExtension); checkIfExtension);
//process group //process group
XSParticle particle = controlType.getParticle(); XSParticle particle = controlType.getParticle();

View File

@@ -25,6 +25,8 @@ import org.w3c.dom.Element;
import javax.xml.transform.Source; import javax.xml.transform.Source;
import java.util.Properties; import java.util.Properties;
import org.alfresco.web.templating.*;
/** /**
* An object that implements this interface can build an XForm that conforms to * An object that implements this interface can build an XForm that conforms to
* the elements and attributes declared in an XML Schema. * the elements and attributes declared in an XML Schema.
@@ -101,6 +103,32 @@ public interface SchemaFormBuilder {
*/ */
public static final String xmleventsNSPrefix = "ev:"; public static final String xmleventsNSPrefix = "ev:";
/**
* Prossible values of the "@method" on the "submission" element
*/
public static final String SUBMIT_METHOD_POST = "post";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_PUT = "put";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_GET = "get";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_FORM_DATA_POST = "form-data-post";
/**
* __UNDOCUMENTED__
*/
public static final String SUBMIT_METHOD_URLENCODED_POST =
"urlencoded-post";
/** /**
* __UNDOCUMENTED__ * __UNDOCUMENTED__
* *
@@ -174,7 +202,8 @@ public interface SchemaFormBuilder {
* @throws org.chiba.tools.schemabuilder.FormBuilderException * @throws org.chiba.tools.schemabuilder.FormBuilderException
* If an error occurs building the XForm. * If an error occurs building the XForm.
*/ */
public Document buildForm(String inputURI) throws FormBuilderException; public Document buildForm(final TemplateType tt)
throws FormBuilderException;
/** /**
* Creates a caption for the provided text extracted from the XML Schema. * Creates a caption for the provided text extracted from the XML Schema.

View File

@@ -35,7 +35,9 @@ final InstanceData instanceData = new InstanceData() {
{ {
try try
{ {
return wiz.getContent() != null ? ts.parseXML(wiz.getContent()) : null; return (wiz.getContent() != null
? ts.parseXML(wiz.getContent())
: null);
} }
catch (Exception e) catch (Exception e)
{ {

View File

@@ -41,12 +41,14 @@
<h:panelGrid id="panel_grid_3" <h:panelGrid id="panel_grid_3"
columns="3" cellpadding="3" cellspacing="3" border="0" columns="3" cellpadding="3" cellspacing="3" border="0"
width="100%"> width="100%">
<%--
<h:graphicImage value="/images/icons/required_field.gif" alt="Required Field" /> <h:graphicImage value="/images/icons/required_field.gif" alt="Required Field" />
<h:outputText id="panel_grid_3_output_text_1" <h:outputText id="panel_grid_3_output_text_1"
value="Presentation Template Type:" escape="false" /> value="Presentation Template Type:" escape="false" />
<h:selectOneRadio value="#{WizardManager.bean.presentationTemplateType}"> <h:selectOneRadio value="#{WizardManager.bean.presentationTemplateType}">
<f:selectItems value="#{WizardManager.bean.createPresentationTemplateTypes}"/> <f:selectItems value="#{WizardManager.bean.createPresentationTemplateTypes}"/>
</h:selectOneRadio> </h:selectOneRadio>
--%>
<h:graphicImage id="required_image_pt" <h:graphicImage id="required_image_pt"
value="/images/icons/required_field.gif" alt="Required Field" /> value="/images/icons/required_field.gif" alt="Required Field" />

View File

@@ -1,4 +1,5 @@
dojo.require("dojo.widget.DebugConsole"); dojo.require("dojo.widget.DebugConsole");
dojo.require("dojo.widget.DatePicker");
dojo.require("dojo.widget.Button"); dojo.require("dojo.widget.Button");
dojo.require("dojo.widget.validate"); dojo.require("dojo.widget.validate");
dojo.require("dojo.widget.ComboBox"); dojo.require("dojo.widget.ComboBox");
@@ -136,7 +137,7 @@ function load_body(body, ui_element_stack)
nodeRef.setAttribute("style", "height: 200px; border: solid 1px black;"); nodeRef.setAttribute("style", "height: 200px; border: solid 1px black;");
cell.appendChild(nodeRef); cell.appendChild(nodeRef);
var id = o.getAttribute("id"); var id = o.getAttribute("id");
var initial_value = get_initial_value(o); var initial_value = get_initial_value(o) || "";
nodeRef.appendChild(document.createTextNode(initial_value)); nodeRef.appendChild(document.createTextNode(initial_value));
var w = dojo.widget.createWidget("Editor", var w = dojo.widget.createWidget("Editor",
{ {
@@ -181,10 +182,11 @@ function load_body(body, ui_element_stack)
row.appendChild(cell); row.appendChild(cell);
var nodeRef = document.createElement("div"); var nodeRef = document.createElement("div");
cell.appendChild(nodeRef); cell.appendChild(nodeRef);
var value = get_initial_value(o); var initial_value = get_initial_value(o);
switch (get_type(o)) switch (get_type(o))
{ {
case "date": case "date":
initial_value = initial_value || dojo.widget.DatePicker.util.toRfcDate();
var dateTextBoxDiv = document.createElement("div"); var dateTextBoxDiv = document.createElement("div");
nodeRef.appendChild(dateTextBoxDiv); nodeRef.appendChild(dateTextBoxDiv);
var dateTextBox = dojo.widget.createWidget("DateTextBox", var dateTextBox = dojo.widget.createWidget("DateTextBox",
@@ -192,7 +194,7 @@ function load_body(body, ui_element_stack)
widgetId: id, widgetId: id,
required: is_required(o), required: is_required(o),
format: "YYYY-MM-DD", format: "YYYY-MM-DD",
value: value value: initial_value
}, },
dateTextBoxDiv); dateTextBoxDiv);
dateTextBox.onfocus = function(o) { dateTextBox.onfocus = function(o) {
@@ -205,7 +207,7 @@ function load_body(body, ui_element_stack)
dateTextBox.picker = dojo.widget.createWidget("DatePicker", dateTextBox.picker = dojo.widget.createWidget("DatePicker",
{ {
isHidden: true, isHidden: true,
value : value value : initial_value
}, },
datePickerDiv); datePickerDiv);
dateTextBox.picker.hide(); dateTextBox.picker.hide();
@@ -223,11 +225,12 @@ function load_body(body, ui_element_stack)
case "integer": case "integer":
case "positiveInteger": case "positiveInteger":
case "negativeInteger": case "negativeInteger":
initial_value = initial_value || "";
var w = dojo.widget.createWidget("SpinnerIntegerTextBox", var w = dojo.widget.createWidget("SpinnerIntegerTextBox",
{ {
widgetId: id, widgetId: id,
required: is_required(o), required: is_required(o),
value: value value: initial_value
}, },
nodeRef); nodeRef);
var handler = function(event) var handler = function(event)
@@ -242,11 +245,12 @@ function load_body(body, ui_element_stack)
dojo.event.connect(w, "onkeyup", handler); dojo.event.connect(w, "onkeyup", handler);
break; break;
case "double": case "double":
initial_value = initial_value || "0";
var w = dojo.widget.createWidget("SpinnerRealNumberTextBox", var w = dojo.widget.createWidget("SpinnerRealNumberTextBox",
{ {
widgetId: id, widgetId: id,
required: is_required(o), required: is_required(o),
value: value value: initial_value
}, },
nodeRef); nodeRef);
var handler = function(event) var handler = function(event)
@@ -262,11 +266,12 @@ function load_body(body, ui_element_stack)
break; break;
case "string": case "string":
default: default:
initial_value = initial_value || "";
var w = dojo.widget.createWidget("ValidationTextBox", var w = dojo.widget.createWidget("ValidationTextBox",
{ {
widgetId: id, widgetId: id,
required: is_required(o), required: is_required(o),
value: value value: initial_value
}, },
nodeRef); nodeRef);
dojo.event.connect(w, dojo.event.connect(w,
@@ -303,11 +308,20 @@ function load_body(body, ui_element_stack)
var initial_value = get_initial_value(o); var initial_value = get_initial_value(o);
if (get_type(o) == "boolean") if (get_type(o) == "boolean")
{ {
initial_value = initial_value || false;
var w = dojo.widget.createWidget("CheckBox", var w = dojo.widget.createWidget("CheckBox",
{ {
checked: initial_value widgetId: o.getAttribute('id'),
checked: initial_value
}, },
nodeRef); nodeRef);
dojo.event.connect(w,
"onClick",
function(event)
{
setXFormsValue(w.widgetId, w.checked);
});
} }
else if (values.length <= 5) else if (values.length <= 5)
{ {
@@ -444,7 +458,10 @@ function get_initial_value(o)
else if (element_name == '.') else if (element_name == '.')
break; break;
node = node.getElementsByTagName(element_name)[0]; node = node.getElementsByTagName(element_name)[0];
dojo.debug("got node " + node.nodeName); if (node)
dojo.debug("got node " + node.nodeName);
else
return null;
} }
return dojo.dom.textContent(node); return dojo.dom.textContent(node);
} }