Warning: This message has had one or more attachments removed
Warning: (verify.js).
Warning: Please read the "FilterNotice.txt" attachment(s) for more information.
Stefan Esterer wrote:
Can you post your script, page and html file so we can study it?
At the moment I'm just trying to use the built in validators (I'm using
Required, Pattern, Min, Max and MaxDate).
verify.js is a custom script that just does some input disabling based
on a radio choice - I'm hoping it's not relevant.
The validation works server side, when the form clientValidationEnabled
is set to false, but I get the error message below when it's set to true.
Thanks,
jim
Can anyone help me to get client-side validation working?
I've enabled client side validation on my form component, and used a
ScriptIncludes component to load the dojo components, but now whenever I
submit the form (whether or not there are any invalid inputs) the
following message is appended in a div at the end of the document: -
ERROR: 12:03:28: Error validating TypeError : value has no properties :
http://localhost:8084/spectrasub/submission?service=asset&path=%2Fdojo%2Fdojo.js
: line 24
Any ideas what gives?
thanks,
jim
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<?xml version="1.0"?>
<!DOCTYPE page-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<page-specification
class="uk.ac.cam.spectra.spectrasub.pages.AddMetadata">
<property name="currentError" />
<property name="embargoRelease" initial-value="ognl:true" />
<bean name="delegate" property="delegate"
class="uk.ac.cam.spectra.spectrasub.pages.AddMetadataValidationDelegate" />
<component id="form" type="Form">
<binding name="success" value="listener:submit" />
<binding name="delegate" value="bean:delegate" />
<binding name="clientValidationEnabled" value="ognl:true"/>
</component>
<component id="embargoPeriodLabel" type="FieldLabel">
<binding name="field" value="component:embargoPeriodSelect" />
</component>
<component id="embargoPeriodSelect" type="PropertySelection">
<binding name="model" value="prop:embargoOptions" />
<binding name="displayName" value="message:embargoPeriodLabel" />
<binding name="value" value="prop:embargoPeriod" />
<binding name="validators" value="validators:required" />
</component>
<component id="embargoReleaseGroup" type="RadioGroup">
<binding name="selected" value="prop:embargoRelease" />
</component>
<component id="autoRelease" type="Radio">
<binding name="value" value="ognl:true" />
</component>
<component id="manualRelease" type="Radio">
<binding name="value" value="ognl:false" />
</component>
<bean name="experimentDateValidator" lifecycle="render"
class="org.apache.tapestry.form.validator.MaxDate">
<set name="maxDate" value="new java.util.Date()" />
<set name="message" value="message:experimentDateWarning" />
</bean>
<component id="experimentDateLabel" type="FieldLabel">
<binding name="field" value="component:experimentDate" />
</component>
<component id="experimentDate" type="DatePicker">
<binding name="displayName" value="message:experimentDateLabel" />
<binding name="value" value="prop:experimentDate" />
<binding name="validators" value="bean:experimentDateValidator" />
<binding name="translator"
value="translator:date,pattern=dd/MM/yyyy" />
</component>
<component id="experimentRefLabel" type="FieldLabel">
<binding name="field" value="component:experimentRef" />
</component>
<component id="experimentRef" type="TextField">
<binding name="displayName" value="message:experimentRefLabel" />
<binding name="value" value="prop:experimentRef" />
</component>
<component id="specTypeRadios" type="RadioGroup">
<binding name="selected" value="prop:spectrumDimension" />
<binding name="translator" value="translator:number,pattern=#" />
<binding name="validators"
value="validators:required,min=1,max=2" />
<binding name="displayName" value="message:specTypeRadioLabel" />
</component>
<component id="oneDRadio" type="Radio">
<binding name="value" value="ognl:1" />
</component>
<component id="twoDRadio" type="Radio">
<binding name="value" value="ognl:2" />
</component>
<component id="nucleus1DLabel" type="FieldLabel">
<binding name="field" value="component:nucleus1D" />
</component>
<component id="nucleus1D" type="PropertySelection">
<binding name="displayName" value="message:nucleusLabel" />
<binding name="model" value="prop:nucleus1DOptions" />
<binding name="value" value="prop:nucleus1D" />
</component>
<component id="nucleus2DLabel" type="FieldLabel">
<binding name="field" value="component:nucleus2D" />
</component>
<component id="nucleus2D" type="Select">
<binding name="displayName" value="message:nucleusLabel" />
<binding name="multiple" value="ognl:true" />
</component>
<component id="nucleus2DOptionLoop" type="For">
<binding name="source"
value="ognl:@[EMAIL PROTECTED]" />
<binding name="value" value="prop:nucleusLabel" />
<binding name="index" value="prop:idx" />
</component>
<component id="nucleus2DOption" type="Option">
<binding name="label" value="prop:nucleusLabel" />
<binding name="selected" value="ognl:nucleus2DSelection[idx]" />
</component>
<component id="pulseSequence2DLabel" type="FieldLabel">
<binding name="field" value="component:pulseSequence2D" />
</component>
<component id="pulseSequence2D" type="PropertySelection">
<binding name="displayName" value="message:pulseSequenceLabel" />
<binding name="model" value="prop:pulseSequence2DOptions" />
<binding name="value" value="prop:pulseSequence2D" />
</component>
<component id="solventLabel" type="FieldLabel">
<binding name="field" value="component:solvent"/>
</component>
<component id="solvent" type="PropertySelection">
<binding name="displayName" value="message:solventLabel"/>
<binding name="model" value="prop:solventOptions"/>
<binding name="value" value="prop:solvent"/>
</component>
<component id="temperatureLabel" type="FieldLabel">
<binding name="field" value="component:temperature"/>
</component>
<component id="temperature" type="PropertySelection">
<binding name="displayName" value="message:temperatureLabel"/>
<binding name="model" value="prop:temperatureOptions"/>
<binding name="value" value="prop:temperature"/>
</component>
<component id="chemicalFormulaLabel" type="FieldLabel">
<binding name="field" value="component:chemicalFormula" />
</component>
<component id="chemicalFormula" type="TextField">
<binding name="displayName"
value="message:chemicalFormulaLabel" />
<binding name="value" value="prop:chemicalFormula" />
</component>
<component id="systematicNameLabel" type="FieldLabel">
<binding name="field" value="component:systematicName" />
</component>
<component id="systematicName" type="TextArea">
<binding name="displayName" value="message:systematicNameLabel" />
<binding name="value" value="prop:systematicName" />
</component>
<component id="compoundClassLabel" type="FieldLabel">
<binding name="field" value="component:compoundClass" />
</component>
<component id="compoundClass" type="PropertySelection">
<binding name="displayName" value="message:compoundClassLabel" />
<binding name="model" value="prop:compoundClassOptions" />
<binding name="value" value="prop:compoundClass" />
<binding name="validators" value="validators:required" />
</component>
<component id="chemistsLoop" type="For">
<binding name="source" value="ognl:chemists" />
<binding name="value" value="ognl:chemistName" />
<binding name="renderTag" value="ognl:true" />
<binding name="converter" value="ognl:nameConverter"/>
</component>
<component id="chemistInitials" type="TextField">
<binding name="value" value="ognl:chemistName.initials" />
</component>
<component id="chemistSurname" type="TextField">
<binding name="value" value="ognl:chemistName.surname" />
</component>
<bean name="initialsValidator"
class="org.apache.tapestry.form.validator.Pattern">
<set name="pattern" value="literal:^(\w+\.)*$" />
<set name="message" value="message:initialsProblem" />
</bean>
<component id="supervisorLabel" type="FieldLabel">
<binding name="field" value="component:supervisorSurname" />
</component>
<component id="supervisorInitials" type="TextField">
<binding name="value" value="prop:supervisor.initials" />
<binding name="validators"
value="validators:$initialsValidator" />
</component>
<component id="supervisorSurname" type="TextField">
<binding name="displayName" value="message:supervisorLabel" />
<binding name="value" value="prop:supervisor.surname" />
</component>
<component id="institutionLabel" type="FieldLabel">
<binding name="field" value="component:institution" />
</component>
<component id="institution" type="TextField">
<binding name="displayName" value="message:institutionLabel" />
<binding name="value" value="prop:institution" />
</component>
</page-specification>
package uk.ac.cam.spectra.spectrasub.pages;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import org.apache.tapestry.annotations.InjectObject;
import org.apache.tapestry.components.IPrimaryKeyConverter;
import org.apache.tapestry.event.PageBeginRenderListener;
import org.apache.tapestry.event.PageEvent;
import org.apache.tapestry.form.IPropertySelectionModel;
import org.apache.tapestry.form.LabeledPropertySelectionModel;
import org.apache.tapestry.form.StringPropertySelectionModel;
import org.apache.tapestry.html.BasePage;
import org.apache.tapestry.valid.IValidationDelegate;
import uk.ac.cam.spectra.spectranmr.NMRMetadata;
import uk.ac.cam.spectra.spectrasub.Combine;
import uk.ac.cam.spectra.spectrasub.DataPackage;
import uk.ac.cam.spectra.spectrasub.DataPackageDAO;
import uk.ac.cam.spectra.spectrasub.DataPackageManager;
import uk.ac.cam.spectra.spectrasub.Name;
import uk.ac.cam.spectra.spectrasub.NotFoundException;
import uk.ac.cam.spectra.spectrasub.SpectraMetadata;
import com.hp.hpl.jena.rdf.model.Model;
import com.hp.hpl.jena.rdf.model.ModelFactory;
import com.hp.hpl.jena.rdf.model.Resource;
public abstract class AddMetadata extends BasePage implements
PageBeginRenderListener {
private static final Logger LOG = Logger.getLogger(AddMetadata.class);
private static final String EMBARGO_RELEASE_AUTO = "automatic";
private static final String EMBARGO_RELEASE_MANUAL = "manual";
public static final String[] NUCLEUS_2D_OPTION_LABELS = new String[] {
"[Select at least one]", "1H", "13C", "15N", "19F", "31P", "Other" };
public void pageBeginRender(PageEvent event) {
if (getNucleus2DSelection() == null) {
setNucleus2DSelection(new boolean[NUCLEUS_2D_OPTION_LABELS.length]);
}
if (getRequestCycle().isRewinding()) {
LOG.debug("Form is rewinding");
List<Name> cs = new ArrayList<Name>(10);
for (int i = 0; i < 10; i++) {
cs.add(new Name());
}
setChemists(cs);
setSupervisor(new Name());
setSpectrumDimension(1);
} else {
setupPage(event);
}
}
private void setupPage(PageEvent event) {
String id = getPackageId();
if (id == null) {
throw new RuntimeException("Package ID lost, cannot continue");
} else if (!getDelegate().getHasErrors()) {
LOG.debug("Loading package: " + id);
try {
DataPackage p = getPackageDao().load(id);
setPackage(p);
Integer ePeriod = p
.getIntegerValue(SpectraMetadata.embargo_period);
if (ePeriod != null) {
setEmbargoPeriod(ePeriod);
}
String release = p.getValue(SpectraMetadata.embargo_release);
if (release != null) {
setEmbargoRelease(EMBARGO_RELEASE_MANUAL.equals(release));
}
String institution = p.getValue(SpectraMetadata.institution);
if (institution != null) {
setInstitution(institution);
}
Date experimentDate = p
.getDateValue(SpectraMetadata.experiment_date);
if (experimentDate != null) {
setExperimentDate(experimentDate);
}
String experimentRef = p
.getValue(SpectraMetadata.experiment_ref);
if (experimentRef != null) {
setExperimentRef(experimentRef);
}
Integer spectrumDimensions = p
.getIntegerValue(NMRMetadata.spectrum_dimensions);
if (spectrumDimensions != null) {
setSpectrumDimension(spectrumDimensions);
switch (spectrumDimensions) {
case 1:
String nucleus1D = p
.getValue(NMRMetadata.spectrum_nucleus);
if (nucleus1D != null) {
setNucleus1D(nucleus1D);
}
break;
case 2:
List<String> nucleii2D = p
.getValues(NMRMetadata.spectrum_nucleus);
if (!nucleii2D.isEmpty()) {
boolean[] slcted = getNucleus2DSelection();
for (String s : nucleii2D) {
int idx = Arrays.binarySearch(
NUCLEUS_2D_OPTION_LABELS, s);
if (idx >= 0) {
slcted[idx] = true;
} else {
LOG.warn("Could not find " + s
+ " in the options array. Hmmm.");
}
}
setNucleus2DSelection(slcted);
}
String ps = p.getValue(NMRMetadata.pulse_sequence);
if (ps != null) {
setPulseSequence2D(ps);
}
break;
}
} else {
setSpectrumDimension(1);
}
String solvent = p.getValue(NMRMetadata.solvent);
if (solvent != null) {
setSolvent(solvent);
}
String temp = p.getValue(NMRMetadata.temperature);
if (temp != null) {
setTemperature(temp);
}
String chemicalFormula = p
.getValue(SpectraMetadata.chemical_formula);
if (chemicalFormula != null) {
setChemicalFormula(chemicalFormula);
}
String systematicName = p
.getValue(SpectraMetadata.chemical_systematic_name);
if (systematicName != null) {
setSystematicName(systematicName);
}
List<String> cNames = p.getValues(SpectraMetadata.chemist);
List<Name> cs = new ArrayList<Name>(cNames.size());
for (String c : cNames) {
cs.add(Name.decode(c));
}
cs.add(new Name());
LOG.debug("Setting " + cs.size() + " chemists: " + cs);
setChemists(cs);
String supervisor = p.getValue(SpectraMetadata.supervisor);
if (supervisor != null) {
LOG.debug("Setting supervisor to " + supervisor);
setSupervisor(Name.decode(supervisor));
} else {
LOG.debug("Setting blank name for supervisor");
setSupervisor(new Name());
}
} catch (NotFoundException e) {
LOG.error("Could not find process: " + e.getMessage(), e);
throw new RuntimeException("Could not find process: "
+ e.getMessage(), e);
}
}
}
public void submit() {
LOG.debug("Experiment date: " + getExperimentDate());
Model m = ModelFactory.createDefaultModel();
DataPackage p;
try {
p = getPackageDao().load(getPackageId());
setPackage(p);
Resource pRes = m.createResource(p.getNormalizedURIString());
if (getInstitution() != null) {
SpectraMetadata.institution.add(pRes, getInstitution());
}
if (getEmbargoPeriod() != null) {
SpectraMetadata.embargo_period.add(pRes, getEmbargoPeriod());
}
SpectraMetadata.embargo_release.add(pRes,
getEmbargoRelease() ? EMBARGO_RELEASE_AUTO
: EMBARGO_RELEASE_MANUAL);
if (getExperimentDate() != null) {
SpectraMetadata.experiment_date.add(pRes, getExperimentDate());
}
if (getExperimentRef() != null) {
SpectraMetadata.experiment_ref.add(pRes, getExperimentRef());
}
NMRMetadata.spectrum_dimensions.add(pRes, getSpectrumDimension());
switch (getSpectrumDimension()) {
case 1:
if (getNucleus1D() != null) {
NMRMetadata.spectrum_nucleus.add(pRes, getNucleus1D());
}
break;
case 2:
for (int i = 0; i < getNucleus2DSelection().length; i++) {
if (getNucleus2DSelection()[i]) {
NMRMetadata.spectrum_nucleus.add(pRes,
NUCLEUS_2D_OPTION_LABELS[i]);
}
}
if (getPulseSequence2D() != null) {
NMRMetadata.pulse_sequence.add(pRes, getPulseSequence2D());
}
}
if (getSolvent() != null) {
NMRMetadata.solvent.add(pRes, getSolvent());
}
if (getTemperature() != null) {
NMRMetadata.temperature.add(pRes, getTemperature());
}
if (getChemicalFormula() != null) {
SpectraMetadata.chemical_formula
.add(pRes, getChemicalFormula());
}
if (getSystematicName() != null) {
SpectraMetadata.chemical_systematic_name.add(pRes,
getSystematicName());
}
LOG.debug("Submission. Chemists: " + getChemists());
if (!Name.isEmpty(getChemists())) {
LOG.debug("Not empty");
for (Name n : Name.trim(getChemists())) {
LOG.debug("adding " + n);
SpectraMetadata.chemist.add(pRes, n.toString());
}
}
LOG.debug("Supervisor " + getSupervisor());
if (!getSupervisor().isBlank()) {
SpectraMetadata.supervisor
.add(pRes, getSupervisor().toString());
}
p.addMetadata(m, Combine.overwrite);
getPackageManager().buildPackage(p);
} catch (NotFoundException e) {
LOG.error("Could not find process: " + e.getMessage(), e);
throw new RuntimeException("Could not find process: "
+ e.getMessage(), e);
}
}
public IPropertySelectionModel getEmbargoOptions() {
final int[] periods = new int[] { 0, 6, 12, 24, 36 };
final String[] labels = new String[] {
"No embargo - publish immediately", "6 months", "1 year",
"2 years", "3 years" };
return new LabeledPropertySelectionModel(new IPropertySelectionModel() {
public String getLabel(int i) {
return labels[i];
}
public Object getOption(int i) {
return periods[i];
}
public int getOptionCount() {
return periods.length;
}
public String getValue(int i) {
return Integer.valueOf(periods[i]).toString();
}
public Object translateValue(String val) {
return Integer.valueOf(val);
}
}, "[ Select one ]");
}
public IPropertySelectionModel getCompoundClassOptions() {
return new LabeledPropertySelectionModel(
new StringPropertySelectionModel(
new String[] { "Organic", "Bio-Organic",
"Organometallic", "Inorganic", "Polymer" }),
"[Select one]");
}
public IPropertySelectionModel getNucleus1DOptions() {
return new LabeledPropertySelectionModel(
new StringPropertySelectionModel(new String[] { "1H", "13C",
"15N", "19F", "31P", "Other" }), "[Select one]");
}
public IPropertySelectionModel getPulseSequence2DOptions() {
final String[] values = new String[] { "NOESY", "COSY", "HETCOR",
"HMBC", "DOSY", "Other" };
final String[] labels = new String[] {
"NOE Correlation (NOESY, ROESY)",
"H-H Connectivity (COSY, TOCSY)",
"Direct H-X Connectivity (HETCOR, HMQC)",
"Long-range H-X Connectivity (HMBC)",
"Molecular size / chemical shift (DOSY)", "Other" };
return new LabeledPropertySelectionModel(new IPropertySelectionModel() {
public String getLabel(int i) {
return labels[i];
}
public Object getOption(int i) {
return values[i];
}
public int getOptionCount() {
return values.length;
}
public String getValue(int i) {
return values[i];
}
public Object translateValue(String val) {
return val;
}
}, "[ Select one ]");
}
public IPropertySelectionModel getSolventOptions() {
return new LabeledPropertySelectionModel(
new StringPropertySelectionModel(new String[] { "CDCl3",
"DMSO-d6", "D20", "H20", "C6D6", "Methanol-d4",
"Acetone-d6", "Toluene-d8", "Other" }), "[Select one]");
}
public IPropertySelectionModel getTemperatureOptions() {
return new LabeledPropertySelectionModel(
new StringPropertySelectionModel(new String[] { "Ambient",
"Low temperature", "High temperature" }),
"[Select one]");
}
public IPrimaryKeyConverter getNameConverter() {
return new IPrimaryKeyConverter() {
public Object getPrimaryKey(Object name) {
LOG.debug("Looking for pk of " + name);
return (name == null) ? 1 : name.hashCode();
}
public Object getValue(Object pk) {
LOG.debug("Looking for object corresponding to " + pk);
return new Name();
}
};
}
public abstract String getCompoundClass();
public abstract void setCompoundClass(String cclass);
public abstract String getPackageId();
public abstract void setPackageId(String id);
public abstract void setPackage(DataPackage package1);
public abstract DataPackage getPackage();
public abstract void setUploadMessage(String uploadMessage);
public abstract String getUploadMessage();
/**
* True if embargo release is automatic
*
* @return
*/
public abstract boolean getEmbargoRelease();
public abstract void setEmbargoRelease(boolean release);
public abstract Integer getEmbargoPeriod();
public abstract void setEmbargoPeriod(Integer period);
public abstract Date getExperimentDate();
public abstract void setExperimentDate(Date experimentDate);
public abstract String getExperimentRef();
public abstract void setExperimentRef(String exptRef);
public abstract Integer getSpectrumDimension();
public abstract void setSpectrumDimension(Integer d);
public abstract String getNucleus1D();
public abstract void setNucleus1D(String nucleusType);
public abstract String getNucleusLabel();
public abstract int getIdx();
public abstract boolean[] getNucleus2DSelection();
public abstract void setNucleus2DSelection(boolean[] slctn);
public abstract String getPulseSequence2D();
public abstract void setPulseSequence2D(String pulseSequence);
public abstract String getSolvent();
public abstract void setSolvent(String sol);
public abstract String getTemperature();
public abstract void setTemperature(String t);
public abstract void setInstitution(String institution);
public abstract String getInstitution();
public abstract String getChemicalFormula();
public abstract void setChemicalFormula(String chemicalFormula);
public abstract String getSystematicName();
public abstract void setSystematicName(String sName);
public abstract List<Name> getChemists();
public abstract void setChemists(List<Name> chemists);
public abstract Name getChemistName();
public abstract Name getSupervisor();
public abstract void setSupervisor(Name n);
public abstract IValidationDelegate getDelegate();
@InjectObject("spring:packageDAO")
public abstract DataPackageDAO getPackageDao();
@InjectObject("spring:packageManager")
public abstract DataPackageManager getPackageManager();
}
This is an automated message from the University of Cambridge's
central email virus filter.
The original email attachment "verify.js"
had an unacceptable file name or type, so it has been deleted and
replaced by this notice. For more information about the virus filter
and advice on what to do about this message, see
<http://www.cam.ac.uk/cs/email/scanner/filetype.html>
On Fri Jan 12 12:53:07 2007 the virus scanner said:
JScript Scripts are dangerous in email (verify.js)
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]