Repository: empire-db Updated Branches: refs/heads/master ab2aadc69 -> d511fc0c2
EMPIREDB-232 Bugfix: Submitted value is stored wrongly on requst Project: http://git-wip-us.apache.org/repos/asf/empire-db/repo Commit: http://git-wip-us.apache.org/repos/asf/empire-db/commit/d511fc0c Tree: http://git-wip-us.apache.org/repos/asf/empire-db/tree/d511fc0c Diff: http://git-wip-us.apache.org/repos/asf/empire-db/diff/d511fc0c Branch: refs/heads/master Commit: d511fc0c2043be637f4e9d660a30e5c89297ca69 Parents: ab2aadc Author: Rainer Döbele <[email protected]> Authored: Wed Feb 24 12:51:26 2016 +0100 Committer: Rainer Döbele <[email protected]> Committed: Wed Feb 24 12:51:26 2016 +0100 ---------------------------------------------------------------------- .../empire/jsf2/controls/InputControl.java | 51 +++++++++++--------- 1 file changed, 28 insertions(+), 23 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/empire-db/blob/d511fc0c/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java ---------------------------------------------------------------------- diff --git a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java index 8d1820b..4ab753a 100644 --- a/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java +++ b/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/controls/InputControl.java @@ -232,7 +232,15 @@ public abstract class InputControl // Get value from Input Object value; if (submitted) - { // get submitted value + { // check disabled + if (ii.isDisabled()) + { // Ignore submitted value + InputControl.log.debug("Ignoring submitted value for disabled field {}.", ii.getColumn().getName()); + input.setSubmittedValue(null); + // throw new FieldIsReadOnlyException(ii.getColumn()); + return null; + } + // get submitted value value = input.getSubmittedValue(); if (value == null && input.isLocalValueSet()) // required for MyFaces! { // take local value @@ -244,27 +252,6 @@ public abstract class InputControl value = ""; } } - // Value supplied? - if (value != null) - { // Check Disabled - if (ii.isDisabled()) - { // Ignore submitted value - InputControl.log.debug("Ignoring submitted value for disabled field {}.", ii.getColumn().getName()); - input.setSubmittedValue(null); - // throw new FieldIsReadOnlyException(ii.getColumn()); - return null; - } - // Save submitted value - FacesContext fc = FacesContext.getCurrentInstance(); - Map<String, Object> reqMap = fc.getExternalContext().getRequestMap(); - // Save submitted value - String clientId = input.getClientId(); - if (reqMap.containsKey(clientId)) - { - InputControl.log.debug("Replacing submitted value from '{}' to '{}' for " + clientId, reqMap.get(clientId), value); - } - reqMap.put(clientId, value); - } // debug if (log.isDebugEnabled()) log.debug("Submitted value for {} is {}", comp.getClientId(), value); @@ -278,9 +265,27 @@ public abstract class InputControl public Object getConvertedValue(UIComponent comp, InputInfo ii, Object submittedValue) { + // Value supplied? + if (submittedValue != null) + { // Save submitted value in request-map + FacesContext fc = FacesContext.getCurrentInstance(); + Map<String, Object> reqMap = fc.getExternalContext().getRequestMap(); + // Save submitted value + UIInput input = getInputComponent(comp); + String clientId = input.getClientId(); + if (reqMap.containsKey(clientId)) + { Object oldValue = reqMap.get(clientId); + if (ObjectUtils.compareEqual(oldValue, submittedValue)==false) + InputControl.log.debug("Replacing submitted value from '{}' to '{}' for " + clientId, oldValue, submittedValue); + } + reqMap.put(clientId, submittedValue); + } // Convert if ((submittedValue instanceof String) && ((String) submittedValue).length() > 0) - { + { // debug + if (log.isDebugEnabled()) + log.debug("Converting value for colum {}. Value is {}", ii.getColumn().getName(), submittedValue); + // parse return parseInputValue((String) submittedValue, ii); } return submittedValue;
