Is TokenList Support only for OneToManyRelationship Mapping
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>
Shall, I use TokenList for ManyToOneRelationship Mapping
No, for many-to-one the
LookupPickerField components are suitable.
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.
I attached my demo project.tokenlist.zip (83.4 KB)
In that,I need to persist data into database.
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?
fixed the issue.tokenlist.zip (82.5 KB)
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
LookupPickerField components are used.
<field property="user"/> to your field group.
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.