Package de.odysseus.calyxo.forms.view

Examples of de.odysseus.calyxo.forms.view.ListModel


  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.taglib.html.AbstractTag#getBodyContent()
   */
  public String getBodyContent() throws Exception {
    ListModel listModel = selectTag.getListModel();
    GroupModel groupModel = selectTag.getGroupModel();

    int order = getListModelOrder();
    boolean descend = sort.startsWith("-");
    Locale locale = I18nSupport.getInstance(pageContext).getLocale(pageContext);
    Iterator values = listModel.getValues(order, descend, locale);

    StringBuffer s = new StringBuffer();
    while (values.hasNext()) {
      Object value = values.next();
      String key = listModel.getKey(value);
      s.append("<option");
      s.append(" value=\"");
      s.append(key);
      s.append("\"");
      if (groupModel.isSelected(key)) {
        s.append(" selected=\"selected\"");
      } else if (!groupModel.isSelectionAvailable()) {
        if (key.equals(this.key) || keys != null && keys.contains(key)) {
          s.append(" selected=\"selected\"");
        }
      }
      appendAttributes(s);
      s.append(">");
      s.append(listModel.getLabel(value, locale));
      s.append("</option>");
    }
    return s.toString();
  }
View Full Code Here


  protected String getBodyContent() throws Exception {
    if (getValue() == null) { // 'default option' mode
      return null;
    }
    // get label from list model
    ListModel listModel = selectTag.getListModel();
    Object value = listModel.getValue(getValueAttribute());
    Locale locale = I18nSupport.getInstance(pageContext).getLocale(pageContext);
    return listModel.getLabel(value, locale);
  }
View Full Code Here

  /*
   * (non-Javadoc)
   * @see de.odysseus.calyxo.base.access.DynamicMapAccessor#get(javax.servlet.http.HttpServletRequest, java.lang.Object)
   */
  protected Object get(HttpServletRequest request, Object key) {
    ListModel model = (ListModel)key;
    if (model == null) {
      throw new AccessException("No list model!");
    }
    return new ListModelBean(model, i18n.getLocale(request));
  }
View Full Code Here

              object = context.getServletContext().getAttribute(attribute);
              break;
      case UNKNOWN:  throw new RuntimeException("Unknown scope '" + scope + "'!");
    }

    ListModel result = null;
    if (property == null) {
      result = (ListModel)object;
    } else {
      try {
        result = (ListModel)PropertyUtils.getNestedProperty(object, property);
View Full Code Here

  /* (non-Javadoc)
   * @see de.odysseus.calyxo.forms.Converter#parse(javax.servlet.http.HttpServletRequest, java.lang.String)
   */
  public Object parse(HttpServletRequest request, String key) throws ParseException {
    ListModel listModel = getListModel(request);
    if (!listModel.containsKey(key)) {
      if (key == null || key.length() == 0) {
        if (listModel.getKey(null) != null) {
          throw new ParseException("Cannot parse empty/null input", 0);
        }
        return null;
      }
      throw new ParseException("Unknown list model key", 0);
    }
    return listModel.getValue(key);
  }
View Full Code Here

TOP

Related Classes of de.odysseus.calyxo.forms.view.ListModel

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.