From b33554a0bda4b59cdc0b4a5e69623d6150228d39 Mon Sep 17 00:00:00 2001 From: "Niels Erik G. Nielsen" Date: Tue, 14 May 2013 14:31:06 -0400 Subject: [PATCH] Attempts to fix state handling accross XHTML pages. Approach may also handle UI generated locationhashes - to be seen though. --- .../mkjsf/pazpar2/state/StateManager.java | 33 +++++++++++++------- 1 file changed, 21 insertions(+), 12 deletions(-) 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; } } -- 1.7.10.4