Is TokenList Support only for OneToManyRelationship Mapping
Hi,
the TokenList
component can be used in case of many-to-many relationship. For example:
<dsContext>
<datasource id="orderDs"
class="com.sample.sales.entity.Order"
view="order-edit">
<collectionDatasource id="productsDs" property="products"/>
</datasource>
<collectionDatasource id="allProductsDs"
class="com.sample.sales.entity.Product"
view="_minimal">
<query>select p from sales$Product p order by p.name</query>
</collectionDatasource>
</dsContext>
<layout>
<tokenList id="productsList" datasource="productsDs" inline="true" width="500px">
<lookup optionsDatasource="allProductsDs"/>
</tokenList>
Regards,
Gleb
Shall, I use TokenList for ManyToOneRelationship Mapping
No, for many-to-one the PickerField
, LookupField
or LookupPickerField
components are suitable.
OK.
For example,
I have Employee Entity with field name and USER(ManyToOneMapping),for user field I use TokenList Component for multiselect option it is not working.
Could please you describe in more details your question? A demo project in which the problem is reproduced is appreciated.
Regards,
Gleb
I can’t create an Employee, I get:
ClassCastException: com.haulmont.cuba.gui.data.impl.DatasourceImpl cannot be cast to com.haulmont.cuba.gui.data.CollectionDatasource
Could you please fix your demo project?
So, according to your demo project, I can see that the TokenList
field isn’t related with the editing entity and, as I said before, the TokenList
component is not intended to be used in case of the many-to-one relation. For the many-to-one relation, the PickerField
, LookupField
or LookupPickerField
components are used.
Just add <field property="user"/>
to your field group.
Regards,
Gleb
But, I need to select multiple user and it is not possible in PickerField,LookupField and LookupPickerField
You can’t select multiple users since you use the many-to-one relation. Only one user can be selected.