cancel
Showing results for 
Search instead for 
Did you mean: 

Initialising of fields for bindin of Context to Model (Adaptive Webservice)

Former Member
0 Kudos

Hi there,

I understand that we need to initiatlise all elements in a model before it can be binded to the context node. However one of my model has as MANY as 20+ fields. That means I need to initiate all these one by one?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi expert,

I do not thing all attribute is initial all your view side...those thing you want show your view that much you need to bind at view context....

thanks

s jati

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Jackson,

Initialization of model will be required if you wish to give some input parameters from the UI. If you dont initialize, the input fields will come as disabled.

(You can refer thread )

Also, you will need to provide all the mandatory fields before execution.

Hope this solves your query.

Kind Regards,

Nitin

Former Member
0 Kudos

Hi there!

Thanks guys so much! I guessed you guys fixed my confusion.

I have always thought that before binding, all model object need to be initialised. But this is not true. Now I realise only those that you need to use for your UI you need to initialise, if not the UI will be greyed out after you do the binding.

P/S: !!! I have initialised everything up to now!! #$@#$%# 😛

former_member185086
Active Contributor
0 Kudos

Hi

1.Model doesn't need any initialization at all ,but need a execution with its required input to perform operation in database.

2.If a model require 20 input to execute to proceed, so u have to provide 20 input from view and then execute it

Best Regards

Satish Kumar

Former Member
0 Kudos

Hi Thanks for your reply.

Can you explain?

Because for webservice, If i don't initiate like below:

// Initialise model objects and relations for Get_SalesOrg

Request_Get_SalesOrgs request9 = new Request_Get_SalesOrgs(model1);

Get_SalesOrgs getSalesOrg = new Get_SalesOrgs(model1);

getSalesOrg.setLanguage("");

request9.setGet_SalesOrgs(getSalesOrg);

wdContext.nodeRequest_Get_SalesOrgs().bind(request9);

(If i don't setLanguage to "")

I won't be able to bind context to model.

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

As far as I know the initializationis not required as such. Why you are not able to bind the result to the context node is probably due to the BAPI definition. May be it is required that Language cannot be null, it should be initialized with some value.

Thats the only reason why you need to initialize this languiage parameter.

In general you directly execute the model and bind the context node with the result. And this works.

I hope this helps!

Regards,

Pravesh

former_member185086
Active Contributor
0 Kudos

Hi

This is not initialization but setting a field into model attributes..

Let I explain from one example

Suppose u have to create one student record with name ,class ,age ,DOB etc.For this one Standard Service is there (Model) say createStudent(String name,int age,String class ,Date dob).So All these filed are there in your UI ok ,and end user will provide all the input (name ,class,age,dob) ,now he/she is about to press SAVE button

Form here your coding role is started :

1. You will get all the record from user(UI input field)

like this

String name = wdContext.currentStudentNodeElement().getName();
		String age = wdContext.currentStudentNodeElement().getAge();
		String sutclass = wdContext.currentStudentNodeElement().getClass();
		String dob = wdContext.currentStudentNodeElement().getDob();

2. You have to set these field age,name...... to the model attribute

modelData.setName(name);
modeData.setAge(age)

and so on.

3. Now u have to execute the model to make data in database.

Hope it will help you to understand.

Best Regards

Satish Kumar

Former Member
0 Kudos

Hey Satish,

Thank you so much for your detailed explanation. That is the way I am doing right now.. just that there is some confusion is what is required to be initialised when i do the model-context binding.

Former Member
0 Kudos

Hi there,

Instead of doing this:

String name = wdContext.currentStudentNodeElement().getName();

String age = wdContext.currentStudentNodeElement().getAge();

String sutclass = wdContext.currentStudentNodeElement().getClass();

String dob = wdContext.currentStudentNodeElement().getDob();

Is it possible I SET a whole node, eg: nodeStudentNode (with all attributes inside) into the model before executing the model? (instead of setting each individual attributes seperately?)

Former Member
0 Kudos

Hi, Because I intended to do this:

// Copy from model node into model node

// WDCopyService.copyElements(wdContext.nodeHeader(), wdContext.nodeHeader3());

// Copy from model node into model node

// WDCopyService.copyElements(wdContext.nodeSa_Item(), wdContext.nodeSa_Item3());

(both are model node for source and target)

Then execute:

wdContext

.currentRequest_Sa_ChangeElement()

.modelObject()

.execute();

wdContext.nodeSa_Return2().invalidate();

CopyService and Execution was successful, however when I check the result, there was no result at all.. just blank.. any advice on this?

pravesh_verma
Active Contributor
0 Kudos

Hi Jackson,

You have invalidated the node after execution of the model. Executing the model has returned you the values. However just after that you have invalidated the node. This has resulted in the removal of all the records of this node. Invalidate function will bring the initial status of the node. Try and remove this line of code and then check.


wdContext.nodeSa_Return2().invalidate();

Thanks and Regards

Pravesh

Edited by: Pravesh Verma on Mar 13, 2009 2:53 AM

HI Jackson,

Have you tried this? Or is your issue resolved?

Regards,

Pravesh