Hello Support Team,
I am trying to provide a default value that changes with the change of another field in an edit screen, so i am injecting the LookupPickerField with the id countryId in the edit screen controller but it’s not injected for some reason that i couldn’t find, my XML is:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<window xmlns="http://schemas.haulmont.com/cuba/window.xsd"
caption="msg://editorCaption"
class="com.company.vp.web.workschedule.WorkScheduleEdit"
datasource="workScheduleDs"
focusComponent="fieldGroup"
messagesPack="com.company.vp.web.workschedule">
<dsContext>
<datasource id="workScheduleDs"
class="com.company.vp.entity.WorkSchedule"
view="workSchedule-view"/>
<collectionDatasource id="countriesDs"
class="com.company.vp.entity.Country"
view="_local">
<query>
<![CDATA[select e from vp$Country e]]>
</query>
</collectionDatasource>
<collectionDatasource id="sectorsDs"
class="com.company.vp.entity.CountrySector"
view="_minimal">
<query>
<![CDATA[select e from vp$CountrySector e where e.country.id = :ds$countriesDs]]>
</query>
</collectionDatasource>
</dsContext>
<dialogMode height="600"
width="800"/>
<layout expand="windowActions"
spacing="true">
<fieldGroup id="fieldGroup"
datasource="workScheduleDs">
<column width="250px">
<field id="countryId"
optionsDatasource="countriesDs"
property="country"/>
<field id="sectorId"
optionsDatasource="sectorsDs"
property="sector"/>
<field property="name"/>
<field property="type"/>
<field property="noOfHours"/>
<field property="weekendDays"/>
<field property="startDate"/>
<field property="endDate"/>
</column>
</fieldGroup>
<frame id="windowActions"
screen="editWindowActions"/>
</layout>
</window>
my screen controller code is:
public class WorkScheduleEdit extends AbstractEditor<WorkSchedule> {
@Inject
private LookupPickerField countryId;
@Inject
private LookupPickerField sectorId;
@Override
public void init(Map<String, Object> params){
countryId.addValueChangeListener(
e -> getItem()
// getItem().setName
// (getItem().getCountry()
// .getName().concat(" - Work Schedule"))
);
}
}
the error message is:
java.lang.NullPointerException
at com.company.vp.web.workschedule.WorkScheduleEdit.init(WorkScheduleEdit.java:19)
line 19 is:
countryId.addValueChangeListener(
can you please help.