cocoon-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicole Hochleiter <hochlei...@seitenbau.com>
Subject CForms, binding with repeater, new element overwrites old element
Date Tue, 06 Jul 2004 15:21:29 GMT
In stepping through org.apache.cocoon.forms.binding.RepeaterJXPathBinding 
public void doSave(Widget frmModel, JXPathContext jxpc) throws BindingException

I got the impression, that my new added element overwrites an existing one.

I'm working with bean binding, cocoon.2.1.5, Java 1.4.2.

Is it a bug or did I miss something in the configuration?

I got the idea that this is a bug, because I could fix this 'bug' in my special
case in putting some lines into that class,  like:
(but I do not want to keep it)
[...]
  //register the factory!
  while (rowIterator.hasNext()) {
      Repeater.RepeaterRow thisRow = (Repeater.RepeaterRow)rowIterator.next();
      // Perform the insert row binding.
      this.insertRowBinding.saveFormToModel(repeater, repeaterContext);
      // -->  create the path to let the context be created

      // -------- My FIX: the pointer pointed always to the last element, 
      // whicht not automatically was the new one
      Pointer newRowContextPointer = null;
      for (int i=0 ; i <= indexCount; i++) {
        newRowContextPointer = 
          repeaterContext.createPath(this.rowPathForInsert + "[" + i + "]");
        Object valueObject = newRowContextPointer.getValue();
        // here is where I check if it really is new (but it only works 
        // with my objectmodel
        if (valueObject instanceof ONStructureElement) {
          if (((ONStructureElement)valueObject).isNew() && 
              ((ONStructureElement)valueObject)._id==null)
           break;
        }
      }                    

      // this was the original line
      /*Pointer newRowContextPointer = repeaterContext.createPath(
              this.rowPathForInsert + "[" + indexCount + "]"); */
      // -------- END My FIX

      JXPathContext newRowContext =
              repeaterContext.getRelativeContext(newRowContextPointer);
      if (getLogger().isDebugEnabled()) {
          getLogger().debug("inserted row at " + newRowContextPointer.asPath());
      }
      //    + rebind to children for update
      this.rowBinding.saveFormToModel(thisRow, newRowContext);
      getLogger().debug("bound new row");
      indexCount++;
  }

Is it really a bug or can I fix my problem in configuring something?
TNX,
Nicole


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@cocoon.apache.org
For additional commands, e-mail: users-help@cocoon.apache.org


Mime
View raw message