public void processRender(WebuiRequestContext context) throws Exception {
    ResourceBundle res = context.getApplicationResourceBundle();
    UIForm uiForm = getAncestorOfType(UIForm.class);
    String formId = null;
    if (uiForm.getId().equals("UISearchForm")) formId = uiForm.<UIComponent>getParent().getId();
    else formId = uiForm.getId();

    Writer w = context.getWriter();
    w.write("<select class=\"selectbox\" id=\"");
    w.write(getId());
    w.write("\" name=\"");
    w.write(name);
    w.write("\"");
    renderHTMLAttributes(w);
    if (onchange_ != null) {
      w.append(" onchange=\"").append(renderOnChangeEvent(uiForm)).append("\"");
    }

    if (isMultiple_) w.write(" multiple=\"true\"");
    if (size_ > 1) w.write(" size=\"" + size_ + "\"");

    if (isDisabled()) w.write(" disabled ");

    w.write(">\n");

    for (SelectItem item : options_) {
      String label = item.getLabel();
      if (item instanceof SelectOption) {
        try {
          label = res.getString(formId + ".label.option." + ((SelectOption) item).getValue());
        } catch (MissingResourceException ex) {
          label = formId + ".label.option." + ((SelectOption) item).getValue();
        }
        w.write(renderOption(((SelectOption) item), label));

      } else if (item instanceof SelectOptionGroup) {
        label = item.getLabel();
        try {
          label = res.getString(getFrom().getId() + ".optionGroup.label." + label);
        } catch (MissingResourceException ex) {
          log.info("Could not find: " + getFrom().getId() + ".optionGroup.label." + label);
        }
        w.write("<optgroup label=\"");
        w.write(label);
        w.write("\">\n");
        for (SelectOption opt : ((SelectOptionGroup) item).getOptions()) {
          label = opt.getLabel();
          try {
            label = res.getString(formId + ".label.option." + opt.getValue());
          } catch (MissingResourceException ex) {
            label = formId + ".label.option." + opt.getValue();
          }
          w.write(renderOption(opt, label));
        }
        w.write("</optgroup>\n");
      }
    }
    w.write("</select>\n");
    if (this.isMandatory()) w.write(" *");
  }
 @Override
 public void visit(PlainSelect plainSelect) {
   firstRun = true;
   counter = 0;
   aliases.clear();
   for (SelectItem item : plainSelect.getSelectItems()) {
     item.accept(this);
   }
   firstRun = false;
   for (SelectItem item : plainSelect.getSelectItems()) {
     item.accept(this);
   }
 }
Example #3
0
 @Override
 public void visit(WithItem withItem) throws Exception {
   // TODO: Redo this later. What's withItem list.
   // Add with name here.
   if (withItem.getName() != null) {
     this.withTableNameList.add(withItem.getName());
   }
   withItem.getSelectBody().accept(this);
   if (withItem.getWithItemList() != null) {
     for (SelectItem selectItem : withItem.getWithItemList()) {
       selectItem.accept(this);
     }
   }
 }
Example #4
0
  /** @brief The following functions override functions of the interfaces. */
  public void visit(PlainSelect plainSelect) throws Exception {
    if (plainSelect.getFromItem() != null) {
      if (plainSelect.getFromItem().getAlias() != null) {
        this.aliasTableNameList.add(plainSelect.getFromItem().getAlias().getName());
      }
      plainSelect.getFromItem().accept(this);
    }

    if (plainSelect.getJoins() != null) {
      for (Iterator joinsIt = plainSelect.getJoins().iterator(); joinsIt.hasNext(); ) {
        Join join = (Join) joinsIt.next();
        if (join.getRightItem().getAlias() != null) {
          this.aliasTableNameList.add(join.getRightItem().getAlias().getName());
        }
        if (join.getOnExpression() != null) {
          join.getOnExpression().accept(this);
        }
        join.getRightItem().accept(this);
      }
    }

    // Select selectItem From fromItem, joinItem Where whereClause.
    if (plainSelect.getSelectItems() != null) {
      for (SelectItem selectItem : plainSelect.getSelectItems()) {
        selectItem.accept(this);
      }
    }

    if (plainSelect.getWhere() != null) {
      plainSelect.getWhere().accept(this);
    }

    if (plainSelect.getGroupByColumnReferences() != null) {
      for (Iterator groupByIt = plainSelect.getGroupByColumnReferences().iterator();
          groupByIt.hasNext(); ) {
        Expression groupBy = (Expression) groupByIt.next();
        groupBy.accept(this);
      }
    }

    if (plainSelect.getClusterByElements() != null) {
      for (Iterator clusterByit = plainSelect.getClusterByElements().iterator();
          clusterByit.hasNext(); ) {
        ClusterByElement clusterByElement = (ClusterByElement) clusterByit.next();
        visit(clusterByElement);
      }
    }

    if (plainSelect.getDistributeByElements() != null) {
      for (Iterator distributeByIt = plainSelect.getDistributeByElements().iterator();
          distributeByIt.hasNext(); ) {
        DistributeByElement distributeByElement = (DistributeByElement) distributeByIt.next();
        visit(distributeByElement);
      }
    }

    if (plainSelect.getOrderByElements() != null) {
      for (Iterator orderByIt = plainSelect.getOrderByElements().iterator();
          orderByIt.hasNext(); ) {
        OrderByElement orderByElement = (OrderByElement) orderByIt.next();
        orderByElement.accept(this);
      }
    }

    if (plainSelect.getSortByElements() != null) {
      for (Iterator sortByIt = plainSelect.getSortByElements().iterator(); sortByIt.hasNext(); ) {
        SortByElement sortByElement = (SortByElement) sortByIt.next();
        visit(sortByElement);
      }
    }

    if (plainSelect.getHaving() != null) {
      plainSelect.getHaving().accept(this);
    }
  }