cancel
Showing results for 
Search instead for 
Did you mean: 

Clearing Model nodes

Former Member
0 Kudos

Hi there,

Sorry If i have asked it before.. But I am not sure again

Lets say I want to clear a model node which is bounded to a model,

do I use:

wdContext.nodeTest().invalidate?

(Won't it simply just update the nodes with the result values from the model instead of clearing it?)

The scenario is like this.. I have some model nodes containing some value of previous result and I want to clear all these values when the user click on "Return to Menu".

Accepted Solutions (1)

Accepted Solutions (1)

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

Yes you are right it will not delete the values instead it will take it to the initial state of when the model was executed.

Therefore most of time we prefer the model binded nodes and value nodes in combination if we require to do some tricks to the values of the feteched model.

I hope this helps..

Thanks and Regards

Pravesh

Former Member
0 Kudos

Do I need to rebind then? Or is there other methods to clear the model values?

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

Rebinding is not required.. Model binding of nodes should be done only once.

Why exactly yu want to delete the values of model node? What is your exact requirement, if you can share it with us?

Thanks and Regards

Pravesh

Former Member
0 Kudos

I want to do the following:

When the user click "Back to Menu" (after everything was executed), all the model nodes will be empty so when he goes through the screens, there will not be any 'left over' values inside.

I am thinking of the couple of followings:

1. Rebind the model nodes so when user onClick "Back to Menu" button, all will be empty values.

2. Call Controller.wdDoInit() (Is it possible? Since all my model binding methods are inside)

Thanks for any advice!

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

by your secind question you remind me of one of my projects I was handling earlier. I have similar requirement of calling the controller init method but dear unfortunately you should not do that and alos it is not possible. Against the Webdynpro framework architecture.

Webdynpro Framework automatically takes care of calling wdDoinit() of component controller.

This answers you 2nd question..

Regarding the 1st onde. I would suggest you to copy the model node value to the Value node as we have suggested to you in your earlier threads and then when you click on "Back to Menu" button just use the invalidate() on the value node.

Invalidate works on the Value node as deleting the values, but I guess you know it is not actually deletaing it is reinitialization of value node as well. But since there was no values in Value node in its initial state, so when you invalidate() it will remove all the node elements.

I hope this solves your issue!

Thanks and Regards

Pravesh

Former Member
0 Kudos

Thank you so much!! I think for this case I will just do a rebinding.

Murali_Shanmu
Active Contributor
0 Kudos

Hi Jason,

Just Delete the model instance at the end of the process



<Model> objModel = null;
			try {
				objModel =
					(<Model> ) WDModelFactory.getModelInstance(<Model> .class);
				objModel.disconnectIfAlive();
			} catch (Exception e) {
				IWDMessageManager msgMrg =
					wdThis.wdGetAPI().getComponent().getMessageManager();
				String msg = e.getLocalizedMessage();
				if ((msg == null) || (msg.length() == 0)) {
					msg = e.getMessage();
				}
				msgMrg.reportException(msg, true);
			} finally {
				objModel = null;
			}

Do let me know if it works.

Cheers

Murali.

Answers (0)