From: Niels Erik G. Nielsen Date: Tue, 14 May 2013 18:31:06 +0000 (-0400) Subject: Attempts to fix state handling accross XHTML pages. X-Git-Tag: v0.0.7~101 X-Git-Url: http://sru.miketaylor.org.uk/?a=commitdiff_plain;h=b33554a0bda4b59cdc0b4a5e69623d6150228d39;p=mkjsf-moved-to-github.git Attempts to fix state handling accross XHTML pages. Approach may also handle UI generated locationhashes - to be seen though. --- diff --git a/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java b/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java index ef6d2f7..5f5aaf4 100644 --- a/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java +++ b/src/main/java/com/indexdata/mkjsf/pazpar2/state/StateManager.java @@ -97,20 +97,29 @@ public class StateManager implements Serializable { } else { logger.debug("State key change. Was: [" + currentKey + "]. Will be ["+key+"]"); if (states.get(key)==null) { - logger.error("The back-end received an unknow state key: ["+ key +"]."); - } else { - if (states.get(key).getCommand("search").equals(states.get(currentKey).getCommand("search"))) { - logger.debug("No search change detected"); - } else { - hasPendingStateChange("search",true); - } - if (states.get(key).getCommand("record").equals(states.get(currentKey).getCommand("record"))) { - logger.debug("No record change detected"); + logger.error("The back-end received an unknow state key, probably UI generated: ["+ key +"]."); + if (key == null || key.length()==0) { + logger.info("Empty key received, treating it as identical to current key going forward."); + key = currentKey; } else { - hasPendingStateChange("record",true); + if (states.get(currentKey) != null) { + logger.info("Current search state cached under both of [" + key + "] and [" + currentKey + "]"); + states.put(key,states.get(currentKey)); + } } - currentKey = key; - } + } + + if (states.get(key).getCommand("search").equals(states.get(currentKey).getCommand("search"))) { + logger.debug("No search change detected"); + } else { + hasPendingStateChange("search",true); + } + if (states.get(key).getCommand("record").equals(states.get(currentKey).getCommand("record"))) { + logger.debug("No record change detected"); + } else { + hasPendingStateChange("record",true); + } + currentKey = key; } }