Skip to Content
avatar image
Former Member

WD Tut18: when to bind and when to addElement() ???

Hi All,

I am trying <b>Context Programming and Data Binding (18) tutorial</b>.

I am slight confused.. when to bind() and when to addElement()'s:

page 22>>

newCustomerNodeElement.nodeAddress().bind(newAddressNodeElement);

page 26>>

node.addElement(newOrderNodeElement);

page23 explanation >>

Note that, if you call the method bind (newCustomerNodeElement) instead of addElement(newCustomerNodeElement), only the last bound node element of the type Customer is contained in the list of node elements. That is, wdContext.nodeCustomers().bind(newCustomerNodeElement) overwrites the list of node elements of the type Customer.

Is it that .. when the cardinality is 0..1 (or) 1..1>> we have to <b>bind</b> elements and when cardinality 0..n (or) 1..n >> we have to <b>addElement();</b> ??

Also i didn't get the exact advantage of a supplyFunction.

Can any1 help me out ?? explain me .. more detailedly ???

Thank u very much in advance,

kanth.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • avatar image
    Former Member
    Sep 21, 2006 at 02:03 PM

    Beginner,

    In general, bind and addElement are interchangeable: you may either bind or addElement.

    For example, if cardinality is 0..1 you may add sole element or bind this element. If the cardinality is 0..n then you may either bind collection of elements or add elements one by one.

    Typically, bind is used when you populate node content initially, addElement is used when user adds/removes already populated node.

    VS

    Add comment
    10|10000 characters needed characters exceeded