RE: WebContent ClassCastException

László Tóth, modified 6 Years ago. Junior Member Posts: 36 Join Date: 5/9/19 Recent Posts
Hi!I try load an assetList. This list contains webcontent that has an options field. The assetList give error when loading list:
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() &gt; 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&lt;&gt;();
		}

		return options;
	}</option>


What can I do?
thumbnail
Javier Gamarra, modified 6 Years ago. Expert Posts: 348 Join Date: 2/12/15 Recent Posts
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)
László Tóth, modified 6 Years ago. Junior Member Posts: 36 Join Date: 5/9/19 Recent Posts
Hi! Sorry, I was on holiday. We want to render a text field with fixed values. I see on gitHub you fixed that issue.