Example #1
0
 public void hintsToPageParameters(Map<String, String> hints, PageParameters pageParameters) {
   if (hints.isEmpty()) {
     return;
   }
   MementoServiceDefault vms = new MementoServiceDefault();
   Memento memento = vms.create();
   Set<String> hintKeys = hints.keySet();
   for (String key : hintKeys) {
     String safeKey = key.replace(':', '_');
     Serializable value = hints.get(key);
     memento.set(safeKey, value);
   }
   String serializedHints = memento.asString();
   PageParameterNames.ANCHOR.addStringTo(pageParameters, serializedHints);
 }
Example #2
0
 public void pageParametersToHints(
     final PageParameters pageParameters, Map<String, String> hints) {
   String hintsStr = PageParameterNames.ANCHOR.getStringFrom(pageParameters);
   if (hintsStr != null) {
     try {
       Memento memento = new MementoServiceDefault().parse(hintsStr);
       Set<String> keys = memento.keySet();
       for (String safeKey : keys) {
         String value = memento.get(safeKey, String.class);
         String key = safeKey.replace('_', ':');
         hints.put(key, value);
       }
     } catch (RuntimeException ex) {
       // fail gracefully, ie ignore.
       System.err.println(ex);
     }
   }
 }