How to hold multiple values in lookupfield picker

Hi,

I have this below editor screen which have a lookup field, when I pick multiple values from lookup field , it will only apply it for first selected value. How can I hold all the values which I select.

image

Thanks,
Saurabh

Hi,

Unfortunately, LookupPickerField is a single select component and does not support multiple selection. You could use TokenList instead.

Thanks for TokenList suggestion. But I have implemented like it mentioned in the topic and its giving me below exception:
image

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
        caption="msg://editorCaption"
        class="com.sompo.intl.legal.loa.web.restclassins.RestClassInsEdit"
        datasource="restClassInsDs"
        focusComponent="fieldGroup"
        messagesPack="com.sompo.intl.legal.loa.web.restclassins">
    <dsContext>
        <datasource id="restClassInsDs"
                    class="com.sompo.intl.legal.loa.entity.RestClassIns"
                    view="RestClassIns-screen-view">
            <collectionDatasource id="subIDs"
                                  property="subID"/>
        </datasource>
        <collectionDatasource id="underwritersInsesDs"
                              class="com.sompo.intl.legal.loa.entity.UnderwritersIns"
                              view="UnderwritersIns-screen-view">
            <query>
                <![CDATA[select e from loa$UnderwritersIns e]]>
            </query>
        </collectionDatasource>
    </dsContext>
    <dialogMode height="600"
                width="800"/>
    <layout expand="windowActions"
            spacing="true">
        <tokenList id="underwritersTokenList"
                   caption="Underwriters"
                   datasource="subIDs"
                   property="subID"
                   width="500px">
            <addButton icon="USER_PLUS"/>
            <lookup inputPrompt="Select Underwriters"
                    optionsDatasource="underwritersInsesDs"/>
        </tokenList>
        <fieldGroup id="fieldGroup"
                    datasource="restClassInsDs">
            <column width="250px">
                <field caption="Restriction"
                       property="restriction"
                       rows="5"/>
                <field caption="Order"
                       property="orderNum"/>
            </column>
        </fieldGroup>
        <frame id="windowActions"
               screen="editWindowActions"/>
    </layout>
</window>

Can you please help me with this little sample project. Problem here I think is I am listing entity in the token list while in the topic it was only few string records.

Here is my sample project. saveTabs.zip (758.9 KB)

In this project , I need this below lookup as to be token list.

image

You can find tokenlist on cuba sampler.

https://demo.cuba-platform.com/sampler/#!

Hi,

I have gone through this above topic, but for me looking up records as a ‘entity’ and holding it is the issue.

Hello, @saurabh60292

The TokenList component should be bound with the property that is represented by some collection: List or Set. Please check whether the subID property is a collection or not.

Regards,
Daniil.

Hi @tsarev

As you can see SubID is entity type. So in this case can’t we use TokenList?

image

No, you cannot bound TokenList with this property. And of course you cannot hold multiple values in this property.

Ok, So in this case how can I edit some records for multiple users if I want. because I think this can be a common requirement in some case using Cuba. Any suggestions?
I had attached sample project in above post if required.

So, if you want to store multiple values you have to use some collection as a type for a property.

In your case the subID property should have the List<UnderwritersIns> or Set<UnderwritersIns> type. And then you will be able to use TokenList with this property.