Package org.apache.shindig.gadgets

Examples of org.apache.shindig.gadgets.UserPrefs


      if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
        String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
        prefs.put(prefName, req.getParameter(paramName));
      }
    }
    return new UserPrefs(prefs);
  }
View Full Code Here


      if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
        String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
        prefs.put(prefName, req.getParameter(paramName));
      }
    }
    return new UserPrefs(prefs);
  }
View Full Code Here

    Iterator i = prefs.keys();
    while (i.hasNext()) {
      String key = (String)i.next();
      p.put(key, prefs.getString(key));
    }
    return new UserPrefs(p);
  }
View Full Code Here

      if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
        String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
        prefs.put(prefName, req.getParameter(paramName));
      }
    }
    return new UserPrefs(prefs);
  }
View Full Code Here

                 "</Module>";
    GadgetSpec spec = new GadgetSpec(Uri.parse("#"), xml);
    GadgetContext context = new GadgetContext() {
      @Override
      public UserPrefs getUserPrefs() {
        return new UserPrefs(ImmutableMap.of("foo", "shindig"));
      }
    };

    spec = substituter.substitute(context, spec);
View Full Code Here

  }

  @Test
  public void testSubstitutions() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, USER_VALUE, OVERRIDE_NAME, OVERRIDE_VALUE);
    final UserPrefs prefs = new UserPrefs(map);
    GadgetContext context = new GadgetContext() {
        @Override
        public UserPrefs getUserPrefs() {
            return prefs;
        }
View Full Code Here

  }

  @Test
  public void testEscaping() throws Exception {
    Map<String, String> map = ImmutableMap.of(USER_NAME, UNESCAPED_USER_VALUE);
    final UserPrefs prefs = new UserPrefs(map);
    GadgetContext context = new GadgetContext() {
        @Override
        public UserPrefs getUserPrefs() {
            return prefs;
        }
View Full Code Here

      if (paramName.startsWith(USERPREF_PARAM_PREFIX)) {
        String prefName = paramName.substring(USERPREF_PARAM_PREFIX.length());
        prefs.put(prefName, req.getParameter(paramName));
      }
    }
    return new UserPrefs(prefs);
  }
View Full Code Here

  // Overrideable method to add extra logic to append user preferences. The default implementation
  // will simply read from the gadget spec for inline user prefs.
  protected void addAllUserPrefs(UriBuilder uri, Gadget gadget, View view, boolean useTpl) {
    GadgetContext context = gadget.getContext();

    UserPrefs prefs = context.getUserPrefs();
    for (UserPref up : gadget.getSpec().getUserPrefs().values()) {
      String name = up.getName();
      String data = prefs.getPref(name);
      if (data == null) {
        data = up.getDefaultValue();
      }

      boolean upInFragment = !view.needsUserPrefSubstitution();
View Full Code Here

* Substitutes user prefs into the spec.
*/
public class UserPrefSubstituter implements Substituter {

  public void addSubstitutions(Substitutions substituter, GadgetContext context, GadgetSpec spec) {
    UserPrefs values = context.getUserPrefs();

    for (UserPref pref : spec.getUserPrefs().values()) {
      String name = pref.getName();
      String value = values.getPref(name);
      if (value == null) {
        value = pref.getDefaultValue();
        if (value == null) {
          value = "";
        }
View Full Code Here

TOP

Related Classes of org.apache.shindig.gadgets.UserPrefs

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.