Problem with lookup field in browse window

Hi

I have problem with lookup field component This component is located in fieldgroup “Filter params” in browse window like on screen below.

obraz

Filter params fieldgroup uses collectionDatasource based on
not persistent entity like below

@MetaClass(name = "demoe$Report")
public class Report extends BaseUuidEntity {
	private static final long serialVersionUID = -6426338076228569084L;
	@Lookup(type = LookupType.DROPDOWN, actions = {"lookup", "clear"})
	@NotNull
	@MetaProperty(mandatory = true)
	protected Currencies currency;

	public void setCurrency(Currencies currency) {
		this.currency = currency;
	}

	public Currencies getCurrency() {
		return currency;
	}
}

Now I open currency browse and select item

obraz

but selected item not set currency field. Field currency is empty. Where is problem ?

Since your setup is not trivial (non-persistent entity, etc.), we cannot say anything without looking at a test project where the problem is reproduced.

Hi Konstantin

I prepared simple project which reproduce this problem Can you glance through options
Application -> Customers. Try select value in field currency. I’d like to use not persistent entity for create param in window like in this example because it’s convenient solution for me. test.zip (85.2 KB)

Hi

Any suggestion ?

Hi Andrzej

Thanks for the test project.
The problem in your code is that the reportsDs is empty when you trying to set an attribute of a Report entity. So there is just no entity to set the attribute value to.

First, it looks logical to me to replace collectionDatasource with datasource containing a single instance:

<datasource id="reportsDs" class="com.company.test.entity.Report"/>

Then, you need to put something to the datasource:

public class CustomerBrowse extends AbstractLookup {

    @Inject
    private Datasource<Report> reportsDs;

    @Inject
    private Metadata metadata;

    @Override
    public void init(Map<String, Object> params) {
        super.init(params);
        reportsDs.setItem(metadata.create(Report.class));
    }
}

Now when you select Currency, you will see it in the picker field.

The whole project:
test.zip (85.3 KB)

Konstantin, thanks of lot for resolve my problem.