Example #1
0
 /**
  * Add a binding in the BindingNode of the specified path.
  *
  * @param path the path of the specified BindingNode in the tree.
  * @param binding the binding to be added to the specified BindingNode.
  * @param varnameSet set with all _var names
  */
 public void addBinding(String path, Binding binding, Set varnameSet) {
   final List nodeids = DataBinder.parseExpression(path, ".");
   if (nodeids.size() <= 0) {
     throw new UiException("Incorrect bean expression: " + path);
   }
   boolean var = varnameSet.contains(nodeids.get(0));
   BindingNode currentNode = this;
   for (final Iterator it = nodeids.iterator(); it.hasNext(); ) {
     final String nodeid = (String) it.next();
     if (nodeid == null) {
       throw new UiException("Incorrect bean expression: " + path);
     }
     BindingNode kidNode = currentNode.getKidNode(nodeid);
     if (kidNode == null) { // if not found, then add one
       if ("/".equals(currentNode._path)) {
         kidNode = new BindingNode(nodeid, var, nodeid, true);
       } else {
         kidNode = new BindingNode(currentNode._path + "." + nodeid, var, nodeid, false);
       }
       currentNode.addKidNode(nodeid, kidNode);
     } else {
       var = var || kidNode._var;
     }
     currentNode = kidNode;
   }
   if (currentNode == this) {
     throw new UiException("Incorrect bean expression: " + path);
   }
   currentNode.addBinding(binding);
   if ("_var".equals(binding.getAttr())) {
     currentNode._innerCollectionNode = DataBinder.hasTemplateOwner(binding.getComponent());
   }
 }
Example #2
0
 /**
  * Locate the BindingNode of the specified path.
  *
  * @param path the path of the specified BindingNode in the tree.
  */
 public BindingNode locate(String path) {
   BindingNode currentNode = this;
   final List nodeids = DataBinder.parseExpression(path, ".");
   for (final Iterator it = nodeids.iterator(); it.hasNext(); ) {
     final String nodeid = (String) it.next();
     if (nodeid == null) {
       throw new UiException("Incorrect format of bean expression: " + path);
     }
     currentNode = currentNode.getKidNode(nodeid);
     if (currentNode == null) {
       return null;
     }
   }
   return currentNode == this ? null : currentNode;
 }