setting value to collection datasource from component

I am trying to generate some records when the user is hitting a button in the screen. It is creating and showing the records in the table. However, I need to set the data from the screen (header) for the detail (collection datasource). Not sure how can I!

I am appending below my controller code. the question is, how to get the value of TextField finaYear in the screen while i need it in the controller, see the ??? below:

public class FinancialYearEdit extends AbstractEditor<FinancialYear> {
    private CollectionDatasource<FinancialPeriod, UUID> financialPeriodDs;

    protected TextField finaYear;

    private Metadata metadata;

    public void onSave() {
        if (validateAll()) {
            showNotification(getMessage("changesSaved"), NotificationType.HUMANIZED);

    public boolean validateAll() {
        for (FinancialPeriod task : financialPeriodDs.getItems()) {
            if (task.getPeriod() == null ) {
                showNotification(getMessage("fillRequiredFields"), NotificationType.TRAY);
                return false;
        return super.validateAll();

    public void onLoad(Component source) {
        Calendar gc1 = Calendar.getInstance();
        Date date = new Date();
        gc1.set(Calendar.YEAR, 2016);
        gc1.set(Calendar.MONTH, 0);
        gc1.set(Calendar.DAY_OF_MONTH, 1);
        long p=0;
        //remove existing items from data source

        //populate periods
        for (long i=0;i<12;i++){

            FinancialPeriod pd = metadata.create(FinancialPeriod.class);

            //long month = gc1.get(Calendar.MONTH);
            gc1.set(Calendar.DAY_OF_MONTH, gc1.getActualMinimum(Calendar.DAY_OF_MONTH));
            gc1.set(Calendar.DAY_OF_MONTH, gc1.getActualMaximum(Calendar.DAY_OF_MONTH));


            gc1.add(Calendar.MONTH, 1);

        //order by Period


If the TextField is associated with an entity attribute through a datasource, or if a datatype is assigned in the XML descriptor, the field will return a value of the specific type (e.g. Integer). Otherwise it returns String.

Thanks. I tried but no value is saved in the field FinaYear. No error found though. Any clue?

Set breakpoint to the


line and ensure the field returns a value.

I did and found it is returning null value and when I run the program, getting null pointer exception

financialPeriodDs = {CollectionPropertyDatasourceImpl@11397} "financialPeriodDs{modified=false, parent=null}"
finaYear = null

What could be the reason why the finaYear is returning null value. I have entered value at the component level on the screen representing finaYear.