Polymer - cuba-service with params

Hello. Can you help me with sending params with ?

I have method:

@Override
public String someMethod(String s) {
return "Hello from middle part! " + s;
}

and realisation like this:

<cuba-entities view="some-browse-view" entity-name="erp$Entity" data="{{entity}}"></cuba-entities>
<cuba-entity view="some-browse-view" id="entityLoader" entity-name="erp$Entity" auto="false"
                     loading="{{entityLoading}}"></cuba-entity>
<table>
            <tr id="table-header">
                <th>My-info</th>
            </tr>
<template id="entityRepeater" is="dom-repeat" items="[[entity]]">

<tr>
                    <td>[[str]]</td>
</tr>

<cuba-service service-name="som_EntityService"
                              method="someMethod"
                              data="{{str}}"
                              handle-as="text"
                              params='{"s":"[[item.id]]"}'>
                </cuba-service>

      </template>
  </table>

I need to send uuid from all my entities like params, but have exception:

Uncaught (in promise) {message: "Failed to load data", errorData: {…}}
POST http://localhost:8080/som/rest/v2/services/som_EntityService/someMethod  500 ()

But if i send a request with static text like:

params=’{“s”:“some text”}’>

it`s works…

Can you halp me and show good example? thanks.

Hi, you should avoid using such kind of binding. Instead you can compute the whole params object in depend on item id in the following way:

<cuba-service service-name="som_EntityService"
                              method="someMethod"
                              data="{{str}}"
                              handle-as="text"
                              params="[[_computeParams(item.id)]]">
</cuba-service>

...

class MyElement extends PolymerElement {
...
  _computeParams(itemId) {
    return {s:itemId};
  }
...
}
1 Like

Thanks for help. This is a good solution to my problem!

Have some problem: if i insert “cuba-service” in “dom-repeat” all my request is good but in
<td>[[str]]</td>
i see info from last request.

How i can insert received value from each request?

Usually if you have some actions/logic in repeated stuff it’s better to move it (what is repeated) into a dedicated component.