on 03-01-2011 5:11 PM
Hi,
can someone explain me the difference between using .invalidate() and using a loop to remove all the node elements from a node? (distinguishing the case of a value node and of a model node).
node.invalidate();
vs.
while (node.size() > 0)
node.removeElementAt(0);
Thank you,
Pietro
>
> Hi,
> can someone explain me the difference between using .invalidate() and using a loop to remove all the node elements from a node? (distinguishing the case of a value node and of a model node).
>
>
node.invalidate();
> vs.
>
while (node.size() > 0) > node.removeElementAt(0);
>
> Thank you,
> Pietro
Invalidate will remove all node elements from a value node.
On a model node, invalidate will synchronize the context with the model. This is why you always invalidate the model node
after calling an RFC.
To remove elements from a model node, you have to loop through it and remove an element at each iteration.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You can't use a for loop and then reevaluate the ending condition using .size() each time.
You have to use a while loop like I wrote in the first post.
If you use your For loop, this is what happens:
i = 0; is 0 < size? Yes, remove element 0 --> You have now (size -1) elements
i = 1; is 1 < (size - 1)? Yes, remove element 1 --> You have now (size -2) elements
...
i = size /2; is size/2 < size/2? No, end the cycle.
.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for your reply.
Still, I can't figure out why sometimes the model node get cleared and sometimes not. What is the reason of this behaviour?
Pietro
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
if u use inavlide it will delete the all values of context atrributes in that node .(cordinality 1:1 here )
where as if u use loop u are getting a chance to delete particulr element attribute value (cordnality is 0-n or 1-n) .
Regards,
Govindu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.