cancel
Showing results for 
Search instead for 
Did you mean: 

Difference between node.invalidate() and node.removeElement()

Former Member
0 Kudos

Hi,

I was going through some code recently and came across the concept of removing the elements from a node to clear the node as a substitute for node.invalidate().

For eg:

If we have a node X which we need to clear, the following is the code user for removing the elements:

CASE 1:

if (wdContext.nodeX() != null && wdContext.nodeX().size() > 0) {

for (int iCtr = (wdContext.X.size() - 1); iCtr >= 0; iCtr--)

wdContext.nodeX().removeElement( wdContext.nodeX().getElementAt(iCtr));

}

CASE 2:

wdContext.nodeX().invalidate();

I am not sure I fully understand how this would help and in what way the two cases would be different. It would be great if someone could throw some light on the same.

Also, as you can see in CASE 1, the if() condition checks for

---> wdContext.nodeX() != null

---> wdContext.nodeX().size() > 0

Wouldn't checking just one of the above conditions be sufficient? How are the 2 conditions different when there are no elements in the node.

Thanks in advance.

Regards,

Priyanka Parmar.

Accepted Solutions (1)

Accepted Solutions (1)

former_member185086
Active Contributor
0 Kudos

Hi

Both has different use cases let go one by one

1. Remove : A node filled with set of element and want to remove particular based on certain conditions.

2. Invalidate : It does the same thing but all at once ,This method invalidates all elements of the node. i.e all elements and subnode instances are deleted. after this the status of the node is as it is in its initial state.

you can say that How to empty a value node now if some condition is there with particular value then we use remove else invalidate .

Example : Whenever we deal with Model Node(rfc/ejb) we always invalidate the response node so that it will ready to hold new values .

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Satish,

I was going through the post as even I had same question in my mind but I got bit confused

we invalidate the model node after we executing the RFC model no not before that mean after the model node data is populated in that case how come we get the return values in same node after invalidating the node.

Thanks

former_member185086
Active Contributor
0 Kudos

Hi

Good questions guys

We invalidate the response node so that it will adapt the change and return the latest values there in data base

consider one example : You call a model node which create one record by using say

createEmployees(name,age...),before this call getAllEmployess() method contain say 3 record

now once we execute the createEmployees method one record is added to the database , and we have invalidate the

response node so that whenever next time we will call getAllEmp method we will get 4 records

Second point : we never deal with response node either for creation or deletion edit of get all, we can say its internally

synchronize the values which is there in database.

Priyanka: I think u r confused with attribute and element , A node having attribute (similar a table has some Column)

which contain values that could be 0--100 and if i clear the values attribute will be there which will ready to hold new

values (create analogy with table and its column).

Yes , when we call invalidate it remove 10 element and of course in terms of table rows

Hope it clear now

Best Regards

Satish Kumar

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Expet,

This is good question for every body..

I mean first case you would control over the removing element one by one.suppose you want to delete one perticular row in you mind then you can use FIRST CASE..this not good pratice removing one bye one..it take some time...upto all element removed.

SecondCase--i mean its better for invalidete or refresh the node again create element.its standard method of Web-dynpro process..some times it will not work .then you have to follow First case.

Basically it wiil use for after excuting model input node.supose you have OUtPUT node in RFC having 2 sub node.it will use for Refresh OUTPUT NODE as well as Child node of output node

thanks

jati

yogesh_galphade
Contributor
0 Kudos

Hi

Invalidate just clears the Node, and remove Element removes the element as well as the visible row from the table.

Former Member
0 Kudos

Yes, I am aware of that. But are we saying that invalidate() just clears off the data from the elements of the node, but does not delete the elements itself?

Let us take the example of a table(Node T) in a view with 5 columns(attribute1,attribute2,attribute3,attribute4,attribute5) and this table has 10 rows as an output obained from an RFC.

When we say wdContext.nodeT.invalidate(); it does not remove the 10 elements (10 rows) of the table, but instead just clears the 10 rows, retaining the elements?