cancel
Showing results for 
Search instead for 
Did you mean: 

Data Binding from GW to UI5

0 Kudos

Hello All -

I am facing an issue in binding data fetched from Gateway to an Input element (<select>....</select>).  As shown below, in my detail view, I have added an input element called "Company Code".  I need this drop down to be populated with the Company Codes fetched from gateway.

Added the able input field using XML view (currenlty 1001 has been hardcoded - needs to be replaced with data fetched from gateway)

In Component.JS, I have written the following code to connect to gateway service:

I do not know how to bind the data fetched from GW to my input element.  Appreciate if someone can help me getting this data attached.

Note: In Eclipse, I created a separate Gateway Starter Application Project to check if data is fetched successfully.  I was able to get the required data from GW.

Thanks,

Vijay

Accepted Solutions (1)

Accepted Solutions (1)

jmoors
Active Contributor
0 Kudos

You need to bind to the items in the xml view.

<Select
  items="{ path: '/ProductCollection' }">
    <core:Item key="{ProductId}" text="{Name}" />
</Select>
0 Kudos

Hello Jason -

In your code, the values are actually coming from JSON.txt for Product ID and Product Collection (believe this was from CD168 example).  In my case, since the values are being fetched from Gateway, what do I need to pass here?  I have only 1 field fetched from the Gateway - which is Company Code.  I am confused on what needs to passed instead of "{ path: '/ProductCollection' }"> 

Thanks,

Vija

jmoors
Active Contributor
0 Kudos

Hi Vijay,

Are you able to post the output of the gateway response, it's easier to help if we can see that actual structure.

Thanks,

Jason

0 Kudos

Hi Jason - I am not sure how to post the output of the gateway response.  Could you please tell me regarding that?  The only gateway part in the code is the below:

I tried debugging this piece, but not sure where to find the fetched records.

Thanks,

Vijay

Former Member
0 Kudos

Hi Vijay,

In your Gateway Service you will find the collection which provides you the value for all company codes.

Use that collection.

Also check out this link for further clarifications.

Regards,

Sharique

0 Kudos

Hi Sharique -

I tried the following, but could not bind it to my input element.

Is the above correct?  If yes, apart from this, do I need to do anything else to bind the data?

Thanks,

Vijay

jmoors
Active Contributor
0 Kudos

The binding will depend on the structure of the content returned from Gateway.

Do you have Google Chrome installed? If so you can get the reponse by enabling the developer tools (ctrl+shift+i) and checking the reponse under the network tab. If you click on line for the the Z_CUSTOMER_SRV http request and click on the response table on the right hand side it should provide the response from the gateway service, if you can post the data we should be able to provide the correct binding.

Regards,

Jason

0 Kudos

Hi Jason -

I believe I am close to the solution.  When I click on the dropdown, it shows me a long empty list (was not happening earlier).  When I debugged in Chrome, I observe that Gateway connectivity and data fetch is going fine.  However I get the below error:

"Uncaught Error: Controller name ('sName' parameter) is required"

The F4 help now shows an empty list - which was not happening earlier:

Thanks,

Vijay

0 Kudos

Hi -

I am finally able to get my data from Gateway and bind it to the dropdown box.  I had made a mistake of not setting the text part in <core:Item />.  Had only put the Key part.  This was the right syntax:

<core:Item key = "{CompanyCode}" text = "{CompanyCode}"/>

Thank You Sharique and Jason for guiding me to the solution.  Your help is greatly appreciated.

Thanks,

Vijay

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Vijay,

You have to bind the collection first to the Icon TabBar and then bind the property to the respective fields.

Regards,

Sharique

0 Kudos

Hi - Appreciate if I could get a sample code.

Thanks,

VIjay