Package org.lazan.t5.stitch.demo.pages

Examples of org.lazan.t5.stitch.demo.pages.GridDecoratorDemo$Item


    return String.valueOf(value.getCategory().getCategoryId());
  }
 
  public ItemTreeNode toValue(String clientValue) {
    Long categoryId = Long.parseLong(clientValue);
    Category category = (Category) session.get(Category.class, categoryId);
    List<ItemTreeNode> nodes = findCategoryNodes(null,  category);
    if (nodes.size() == 1) {
      return nodes.get(0);
    }
    throw new IllegalStateException(
View Full Code Here


      "group by " +
        "childCategory.categoryId, childCategory.name, childCategory.parentCategory " +
      "order by childCategory.name";
   
    String whereClause;
    Category param = null;
    if (childCategory != null) {
      whereClause = "childCategory = ?";
      param = childCategory;
    } else if (parentCategory != null) {
      whereClause = "childCategory.parentCategory = ?";
      param = parentCategory;
    } else {
      whereClause = "childCategory.parentCategory is null";
    }
    String hql = String.format(hqlTemplate, whereClause);
    Query query = session.createQuery(hql);
    if (param != null) {
      query.setParameter(0, param);
    }
    List<Object[]> results = query.list();
    for (Object[] row : results) {
      Category current = (Category) row[0];
      int grandChildCategoryCount = ((Number) row[1]).intValue();
      int itemCount = ((Number) row[2]).intValue();
     
      ItemTreeNode treeNode =
          new ItemTreeNode(current, grandChildCategoryCount, itemCount);
View Full Code Here

  private void addItems(Map<String, Category> catCache, String[] items) {
    for (String itemString : items) {
      String[] row = itemString.split("\\|");

      Category category = catCache.get(row[0]);
      Item item = new Item();
      item.setCategory(category);
      item.setName(row[1]);
      item.setPrice(new BigDecimal(row[2]));
      item.setDescription(row[3]);
      session.save(item);
    }
  }
View Full Code Here

 
  @Inject
  private Block itemBlock;
 
  public TreeModel<ItemTreeNode> getTreeModel() {
    ItemTreeSource source = new ItemTreeSource(session);
    return new LazyTreeModel<ItemTreeNode>(source, source);
  }
View Full Code Here

  }
 
  void onValidateFromGenericField(String value) {
    if (value == null || !value.toLowerCase().startsWith("a")) {
      String fieldName = getFieldName(genericField.getControlName());
      Field fieldSnapshot = new FieldSnapshot(genericField);
      form.recordError(fieldSnapshot, fieldName + " must start with 'a'");
    }
  }
View Full Code Here

    }
    return new CollectionGridDataSource(allRecords);
  }
 
  public PagerModel getPagerModel() {
    return new DefaultPagerModel(2, 1, 2);
  }
View Full Code Here

  /**
   * Set the background color of every cell
   */
  public GridCellDecorator getCellDecorator() {
    return new GridCellDecorator() {
      public void decorate(Element cellElement, Object rowObject, int rowIndex, String propertyName, int colIndex) {
        String color;
        if (rowIndex % 2 == 0) {
          color = colIndex % 2 == 0 ? YELLOW : RED;
        } else {
View Full Code Here

 
  /**
   * Display an alert when any row is clicked
   */
  public GridRowDecorator getRowDecorator() {
    return new GridRowDecorator() {
      public void decorate(Element element, Object rowValue, int rowIndex) {
        Item item = (Item) rowValue;
        String script = String.format("alert('value=%s, rowIndex=%s')", item.value, rowIndex);
        element.attribute("onclick", script);
      }
View Full Code Here

  public BeanModel<Object> getPeopleModel() {
    // initially construct a BeanModel for object (no properties)
    BeanModel<Object> beanModel = beanModelSource.createDisplayModel(Object.class, messages);
   
    // add MapPropertyConduits for each map entry
    beanModel.add("firstName", new MapPropertyConduit("firstName", String.class));
    beanModel.add("lastName", new MapPropertyConduit("lastName", String.class));
    beanModel.add("age", new MapPropertyConduit("age", int.class));
   
    return beanModel;
  }
View Full Code Here

  Object onAjaxEvent() {
    return captureBlock;
  }
 
  public MarkupHandler getCountToTenHandler() {
    return new MarkupHandler() {
     
      // fired as the captureBlock renders
      public void handle(String markup) {
        jss.addScript("alert('%s')", markup.trim());
      }
View Full Code Here

TOP

Related Classes of org.lazan.t5.stitch.demo.pages.GridDecoratorDemo$Item

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.