while I’m new, I think I’ve pretty much exhausted the documenation on the method to set value options for LookUp and Picker fields. Unfortunately, I keep getting the same error:
ClassCastException: class com.company.planner.entity.SessionType cannot be cast to class java.lang.String (com.company.planner.entity.SessionType is in unnamed module of loader org.apache.catalina.loader.ParallelWebappClassLoader @773f7880; java.lang.String is in module java.base of loader ‘bootstrap’)
What I am trying to achieve is fairly simple: Set a text value in a record from a drop down list of values (picker or lookup) from another table. Both source and destination fields are String. To illustrate the propblem, I used the QuickStart Session Planner demo, and added a new entity of SesstionType. This has only 1 field in it “name” and the name pattern on the entity is @NamePattern(“%s|name”). I simply want to pick one of these values (SessionType.Name) in the table and store the text in the new field “type” on Session entity. (I don’t want an ID reference)
The field “type” shows up in the browser and edit screens for Session, but navigating to the Session-edit screen gives the error above. (prior to any data entry.)
The session-edit.xml file is below.
I have reviewed the Sampler docs (https://demo10.cuba-platform.com/sampler/#main/8/sample?id=related-entity-lookupfield) and the Manual docs (LookupField - CUBA Platform. Developer’s Manual) for both LookUp and PickerLookUp.
Am I missing something? Does something need injecting into the controller?
Thanks.
-Curt
<data>
<instance id="sessionDc"
class="com.company.planner.entity.Session" >
<view extends="_local">
<property name="speaker" view="_minimal"/>
</view>
<loader/>
</instance>
<collection id="typesDc" class="com.company.planner.entity.SessionType" view="_local">
<loader id="sessionTypesDl">
<query>
<![CDATA[select e from planner_SessionType e]]>
</query>
</loader>
</collection>
</data>
<dialogMode height="600"
width="800"/>
<layout expand="editActions" spacing="true">
<form id="form" dataContainer="sessionDc">
<column width="250px">
<textField id="topicField" property="topic"/>
<lookupField id="typeField" optionsContainer="typesDc" property="type" />
<dateField id="startDateField" property="startDate"/>
<textField id="durationField" property="duration"/>
<textArea id="descriptionField" property="description" rows="5"/>
<dateField id="endDateField" property="endDate"/>
<pickerField id="speakerField" property="speaker"/>
</column>
</form>
<hbox id="editActions" spacing="true">
<button action="windowCommitAndClose"/>
<button action="windowClose"/>
</hbox>
</layout>