Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: WebContent ClassCastException
Hi!I try load an assetList. This list contains webcontent that has an options field. The assetList give error when loading list:
In WebContent class while parsing dynamic-elements StringWithOptionsField's getCurrentValue() method is returning ArrayList<Option> not a String.
What can I do?
E/LiferayScreens: Error loading list
java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList
at com.liferay.mobile.screens.ddl.model.StringWithOptionsField.getCurrentValue(StringWithOptionsField.java:108)
at com.liferay.mobile.screens.ddl.model.StringWithOptionsField.getCurrentValue(StringWithOptionsField.java:29)
at com.liferay.mobile.screens.webcontent.WebContent.<init>(WebContent.java:74)
at com.liferay.mobile.screens.asset.AssetFactory.createInstance(AssetFactory.java:34)
at com.liferay.mobile.screens.asset.list.interactor.AssetListInteractor.createEntity(AssetListInteractor.java:115)
at com.liferay.mobile.screens.asset.list.interactor.AssetListInteractor.execute(AssetListInteractor.java:63)
at com.liferay.mobile.screens.base.list.interactor.BaseListInteractor.online(BaseListInteractor.java:173)
at com.liferay.mobile.screens.base.interactor.BaseCacheReadInteractor$1.run(BaseCacheReadInteractor.java:65)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:764)</init>
if (ddmStructure.getFieldCount() > 0) {
html = (String) ddmStructure.getField(0).getCurrentValue();
}
In WebContent class while parsing dynamic-elements StringWithOptionsField's getCurrentValue() method is returning ArrayList<Option> not a String.
@Override
public ArrayList<option> getCurrentValue() {
ArrayList</option><option> options = super.getCurrentValue();
if (options == null) {
options = new ArrayList<>();
}
return options;
}</option>
What can I do?
It's definitely an error... I don't know why that code is there, it doesn't make any sense. I can release a new version filling the html field when it makes sense... but what do you want to render? a custom view with the fields or the raw html (you need a template for that)
Hi! Sorry, I was on holiday. We want to render a text field with fixed values. I see on gitHub you fixed that issue.
Copyright © 2025 Liferay, Inc
• Privacy Policy
Powered by Liferay™