Saving components settings by UserSetting service

Hi

I see then any components save settings by UserSetting service.
These components implement HasSettings interface. Is there any
way than set this feature for other components e.g date component. Obviously in choose case. I need this for saving values in my custom filter panel.

Hi,

You can use UserSettingService right from your screen:

@Inject
UserSettingService userSettingService;
...

String demoValue = userSettingService.loadSetting(ClientType.WEB, "demoValue");

Please note, that settings must have unique name across all UI screens.

Also, you can override saveSettings and applySettings methods in a screen to save and load custom setting values. See AbstractWindow - CUBA Platform. Developer’s Manual

I see then I have little problem because I have to convert to xml entity object.
Is there any way for simple convert value to xml. I attach my case

public class MyBrowse extends BasicBrowse {
	@Inject
	private LookupPickerField ledger;
        @Override
	public void saveSettings() {
		Ledgers ledgerValue = ledger.getValue();
		Element xmlDescriptor = getSettings().get(ledger.getId());
		xmlDescriptor.addAttribute("ledger",  <convert to xml>);
		super.saveSettings();
	}

	@Override
	public void applySettings(Settings settings) {
		super.applySettings(settings);
		Element xmlDescriptor = settings.get(ledger.getId());
		if (xmlDescriptor.attribute("ledger") != null) {
			xmlDescriptor.attributeValue("ledger"); --- > convert from xml to entity
		}
	}

You do not need to store an entity in XML. Just store ID and load it back using DataManager.