Hi,
How to get selected tokenlist values in cuba platform.
Hi,
I have use CUBA 6.10
In this case just invoke tokenList.getValue()
, but it just returns a value that is stored in datasource/entity property.
Ok thanks
Hi Daniil,
And if I need for tokenList Instance name?
tokenList.getValue return the id (uuid): 014dda99-etc.
But I need to return instance name
The TokenList
component is able to work only with entities, so it cannot return a UUID.
Could you share how TokenList is used on your screen?
Moreover, instance name is usually used as default caption in UI, not for component value.
I’ve put a logger and I saw that tokenList returns Transaction (entity) and tokenList.getValue returns Transaction id.
However my goal is to move into a table (column) the tokenList selected fields (Buyer 1 and Buyer 2) with the x Button as well. Is it possible?
I saw that it’s possible to set how many attributes (Buyer, Address, etc) can display in tokenList from Instance name. Is it so?
You can set ItemChangeHandler
and handle item remove:
tokenList.setItemChangeHandler(new ItemChangeHandler() {
void addItem(Object item) {
// "item added" hook
}
void removeItem(Object item) {
// "item removed" hook
}
});
it’s possible to set how many attributes (Buyer, Address, etc) can display in tokenList from Instance name…
You are able to configure whether instance name (configured for entity) or some property should be used as item caption:
// Instance name
tokenList.setCaptionMode(CaptionMode.ITEM);
// property
tokenList.setCaptionMode(CaptionMode.PROPERTY);
// the same for options
tokenList.setOptionsCaptionMode(CaptionMode.ITEM);
Regards,
Daniil
Can you be more specific pls?
How can I set, let say tokenList CaptionMode for buyer?
Also I’m interested if is there any possibility to hide tokenList caption fields?
Best Regards,
n
You cannot manage with component which properties will be used when entity instance name is used as caption. But you can set one property that will be used by component as caption.
Let’s look at an example:
// both properties are used for instance name
@NamePattern("%s %s|firstName, lastName")
public class MyEntity {
private String firstName;
private String lastName;
}
Configure TokenList selected values (tokens) captions:
// entity instance name will be used
tokenList.setCaptionMode(CaptionMode.INSTANCE);
// "firstName" property value will be used
tokenList.setCaptionMode(CaptionMode.PROPERTY);
tokenList.setCaptionProperty("firstName")
Configure lookup field options caption:
// entity instance name will be used
tokenList.setOptionsCaptionMode(CaptionMode.INSTANCE);
// "firstName" property value will be used
tokenList.setOptionsCaptionMode(CaptionMode.PROPERTY);
tokenList.setOptionsCaptionProperty("firstName")
hide tokenList caption fields
Could you clarify what fields are you talking about?
Regards,
Daniil
Hi @tsarev,
I want to set the values to the token list.
I tried to call tokenlist.setvalue(values…) it throws an UnsupportedOperationException
I want to pre set list of values
Regards,
Sanchit
Hello @sanchit.bhavsar
Unfortunately TokenList
doesn’t support setting value explicitly in CUBA 6.
Regards,
Daniil
Thanks for the reply.
So is it possible in CUBA 7?
Regards,
Sanchit
Yes, it is possible in new CUBA versions.