Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api/src/org/labkey/api/data/BeanViewForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@
import org.apache.commons.beanutils.ConvertUtils;
import org.apache.commons.beanutils.DynaBean;
import org.apache.commons.beanutils.DynaClass;
import org.labkey.api.action.BaseViewAction.BeanUtilsPropertyBindingResult;
import org.labkey.api.action.HasBindParameters;
import org.labkey.api.action.NullSafeBindException;
import org.springframework.validation.BindException;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -86,6 +89,13 @@ public void setBean(K bean)
setTypedValues(factory.toMap(bean, null), false);
}

@Override
public BindException createErrors()
{
// Teaches Spring to resolve field names via string lookups instead of getters. e.g., errors.rejectValue().
return new NullSafeBindException(new BeanUtilsPropertyBindingResult(this, "form"));
}

@Override
public Map<String, Object> getValuesToBind()
{
Expand Down
9 changes: 7 additions & 2 deletions api/src/org/labkey/api/data/TableViewForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.labkey.api.action.NullSafeBindException;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.collections.CaseInsensitiveHashMap;
import org.labkey.api.ontology.Quantity;
import org.labkey.api.query.FieldKey;
import org.labkey.api.security.permissions.DeletePermission;
import org.labkey.api.security.permissions.InsertPermission;
Expand Down Expand Up @@ -897,10 +896,16 @@ else if (orig.getName().startsWith(ARRAY_MARKER) && orig.getValue()!=null)
setValueToBind(pv.getName(), pv.getValue());
}

BindException errors = new NullSafeBindException(this, "form");
BindException errors = createErrors();
validateBind(errors);
return errors;
}

// Construct and return a BindException that's appropriate for this form
public BindException createErrors()
{
return new NullSafeBindException(this, "form");
}
}


3 changes: 1 addition & 2 deletions api/src/org/labkey/api/query/UserSchemaAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import org.jetbrains.annotations.Nullable;
import org.labkey.api.action.FormViewAction;
import org.labkey.api.action.NullSafeBindException;
import org.labkey.api.action.SpringActionController;
import org.labkey.api.attachments.SpringAttachmentFile;
import org.labkey.api.audit.TransactionAuditProvider;
Expand Down Expand Up @@ -79,7 +78,7 @@ public BindException bindParameters(PropertyValues m) throws Exception
QueryUpdateForm command = new QueryUpdateForm(_table, getViewContext(), null);
if (command.isBulkUpdate())
command.setValidateRequired(false);
BindException errors = new NullSafeBindException(new BeanUtilsPropertyBindingResult(command, "form"));
BindException errors = command.createErrors();
command.validateBind(errors);
return errors;
}
Expand Down
4 changes: 3 additions & 1 deletion core/webapp/Ext.ux.form.LovCombo.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,10 @@ Ext.ux.form.LovCombo = Ext.extend(Ext.form.ComboBox, {
this.store.suspendEvents(true);
this.store.clearFilter();
this.store.each(function (r) {
// GH Issue 1266: String() (not JSON.stringify) so native RegExp.escape doesn't throw on a
// numeric valueField, while string values stay unquoted to match getCheckedValue() output.
var checked = !(!v.match(
'(^|' + this.separator + ')' + RegExp.escape(JSON.stringify(r.get(this.valueField)))
'(^|' + this.separator + ')' + RegExp.escape(String(r.get(this.valueField)))
+ '(' + this.separator + '|$)'));
r.set(this.checkField, checked);
}, this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1923,8 +1923,9 @@ public void testUpdateInstallationContainerScoping() throws Exception
public void testUpdateStackTraceContainerScoping() throws Exception
{
User admin = getAdmin();
Container folderA = createContainer("A");
Container folderB = createContainer("B");
MothershipModule module = ModuleLoader.getInstance().getModule(MothershipModule.class);
Container folderA = createContainer("A", module);
Container folderB = createContainer("B", module);

// An exception stack trace that lives in folder B (StackTraceHash is derived from the stack trace text)
ExceptionStackTrace st = new ExceptionStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
package org.labkey.study.pipeline;

import org.jetbrains.annotations.NotNull;
import org.labkey.api.action.BaseViewAction;
import org.labkey.api.action.NullSafeBindException;
import org.labkey.api.admin.PipelineJobLoggerGetter;
import org.labkey.api.assay.transform.DataTransformService;
Expand Down Expand Up @@ -114,7 +113,7 @@ else if (params.containsKey(DataTransformService.ORIGINAL_SOURCE_PATH))
for (String error : readerErrors)
_ctx.getLogger().error(error);

BindException errors = new NullSafeBindException(new BaseViewAction.BeanUtilsPropertyBindingResult(this, "pipeline"));
BindException errors = new NullSafeBindException(this, "pipeline");
boolean allowDomainUpdates = true;
if (_ctx.getProperties().containsKey(StudyImportContext.ALLOW_DOMAIN_UPDATES))
allowDomainUpdates = Boolean.parseBoolean(_ctx.getProperties().get(StudyImportContext.ALLOW_DOMAIN_UPDATES));
Expand Down
Loading