Editor loading error: V 7.2.1

Noticed after migrating to platform version 7.2.1 that one of my editor screen (Journal) is not throwing an exception when I want to create or edit from browser. Here is the error:

java.lang.NullPointerException
at com.haulmont.cuba.gui.xml.layout.loaders.AbstractTableLoader.loadComponent(AbstractTableLoader.java:174)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponents(ContainerLoader.java:38)
at com.haulmont.cuba.gui.xml.layout.loaders.SplitPanelLoader.loadComponent(SplitPanelLoader.java:78)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponents(ContainerLoader.java:38)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:76)
at com.haulmont.cuba.gui.xml.layout.loaders.AbstractBoxLoader.loadComponent(AbstractBoxLoader.java:50)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponents(ContainerLoader.java:38)
at com.haulmont.cuba.gui.xml.layout.loaders.TabSheetLoader.loadComponent(TabSheetLoader.java:93)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponents(ContainerLoader.java:38)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:76)
at com.haulmont.cuba.gui.xml.layout.loaders.GroupBoxLayoutLoader.loadComponent(GroupBoxLayoutLoader.java:67)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponents(ContainerLoader.java:38)
at com.haulmont.cuba.gui.xml.layout.loaders.ScrollBoxLayoutLoader.loadComponent(ScrollBoxLayoutLoader.java:63)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponents(ContainerLoader.java:38)
at com.haulmont.cuba.gui.xml.layout.loaders.ContainerLoader.loadSubComponentsAndExpand(ContainerLoader.java:76)
at com.haulmont.cuba.gui.xml.layout.loaders.WindowLoader.loadComponent(WindowLoader.java:94)
at com.haulmont.cuba.web.sys.WebScreens.loadWindowFromXml(WebScreens.java:366)
at com.haulmont.cuba.web.sys.WebScreens.createScreen(WebScreens.java:233)
at com.haulmont.cuba.web.sys.WebScreens.create(WebScreens.java:175)
at com.haulmont.cuba.gui.builders.EditorBuilderProcessor.createScreen(EditorBuilderProcessor.java:285)
at com.haulmont.cuba.gui.builders.EditorBuilderProcessor.buildEditor(EditorBuilderProcessor.java:87)
at com.haulmont.cuba.gui.builders.EditorBuilder.build(EditorBuilder.java:359)
at com.haulmont.cuba.gui.actions.list.EditAction.execute(EditAction.java:301)
at com.haulmont.cuba.gui.actions.list.EditAction.actionPerform(EditAction.java:267)
at com.haulmont.cuba.web.gui.components.WebButton.buttonClicked(WebButton.java:67)
at com.haulmont.cuba.web.widgets.CubaButton.fireClick(CubaButton.java:76)
at com.vaadin.ui.Button$1.click(Button.java:57)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:153)
at com.vaadin.server.ServerRpcManager.applyInvocation(ServerRpcManager.java:115)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocation(ServerRpcHandler.java:431)
at com.vaadin.server.communication.ServerRpcHandler.handleInvocations(ServerRpcHandler.java:396)
at com.vaadin.server.communication.ServerRpcHandler.handleRpc(ServerRpcHandler.java:260)
at com.vaadin.server.communication.UidlRequestHandler.synchronizedHandleRequest(UidlRequestHandler.java:82)
at com.vaadin.server.SynchronizedRequestHandler.handleRequest(SynchronizedRequestHandler.java:40)
at com.vaadin.server.VaadinService.handleRequest(VaadinService.java:1578)
at com.vaadin.server.VaadinServlet.service(VaadinServlet.java:425)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.serviceAppRequest(CubaApplicationServlet.java:329)
at com.haulmont.cuba.web.sys.CubaApplicationServlet.service(CubaApplicationServlet.java:215)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:741)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:231)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.springframework.web.filter.CompositeFilter$VirtualFilterChain.doFilter(CompositeFilter.java:108)
at org.springframework.web.filter.CompositeFilter.doFilter(CompositeFilter.java:74)
at com.haulmont.cuba.web.sys.CubaHttpFilter.doFilter(CubaHttpFilter.java:93)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96)
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92)
at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74)
at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343)
at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408)
at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66)
at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:861)
at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1579)
at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61)
at java.lang.Thread.run(Thread.java:748)

Thanks for any clue to fix it.

Hello,

It seems something wrong with dsContext. Could you share the screen descriptor and controller? Or if it is possible, please share a small demo project with your problem.

Hi Roman

Please find here the xml file:

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>

<window xmlns="http://schemas.haulmont.com/cuba/screen/window.xsd"
        caption="msg://editorCaption"
        focusComponent="docDateField"
        messagesPack="com.inteacc.erp.web.acct.journal">
    <data>
        <instance id="journalDc"
                  class="com.inteacc.erp.entity.acct.Journal"
                  view="journal-view">
            <loader/>
            <collection id="journalLineDc" property="journalLine"/>
            <collection id="journalAttachmentDc" property="journalAttachment"/>
        </instance>
        <collection id="companiesDc" class="com.inteacc.erp.entity.acct.Company" view="companyCoa-view">
            <loader id="companiesLc">
                <query>
                    <![CDATA[select e from erp$Company e where e.active = true]]>
                </query>
            </loader>
        </collection>
        <collection id="financialYearsDc" class="com.inteacc.erp.entity.acct.FinancialYear" view="financialYear-view">
            <loader id="financialYearsLc">

                    <query><![CDATA[select e from erp$FinancialYear e
                              where e.company = :container_companiesDc]]>

                </query>
            </loader>
            <collection id="financialPeriodsDc" property="financialPeriod"/>
        </collection>
        <collection id="currenciesDc" class="com.inteacc.erp.entity.acct.Currency" view="_minimal">
            <loader id="currenciesLc">
                <query>
                    <![CDATA[select e from erp$Currency e]]>
                </query>
            </loader>
        </collection>
        <collection id="costCentresDc" class="com.inteacc.erp.entity.acct.CostCentre" view="_minimal">
            <loader>
                <query>
                    <![CDATA[select e from erp$CostCentre e join e.costCentreCompany co where co.extendedToCompany = TRUE and co.company = :container_companiesDc]]>
                </query>
            </loader>
        </collection>
        <collection id="accountsDc" class="com.inteacc.erp.entity.acct.Account" view="accountSub-view">
            <loader id="accountsDl">
                <query>
                    <![CDATA[select e from erp$Account e where e.accountHeader = false and e in (select line.account from  erp$ChartOfAccountLine line join
        line.chartOfAccount coa where coa.id = :coa)]]>
                </query>
            </loader>
            <collection id="accountSubsDc" property="accountSub"/>
        </collection>

    </data>
    <dialogMode height="600"
                width="800"/>
    <facets>
          <dataLoadCoordinator auto="true"/>
    </facets>
    <layout expand="scrollBox" spacing="true">
        <scrollBox id="scrollBox" spacing="true">
            <form id="form" dataContainer="journalDc">
                <column width="250px">
                    <textField id="docNumberField" property="docNumber" editable="false"/>
                    <dateField id="docDateField" property="docDate"/>
                    <lookupPickerField id="companyField" optionsContainer="companiesDc" property="company" editable="false"
                    >
                        <actions>
                            <action id="lookup" type="picker_lookup"/>
                            <action id="open" type="picker_open"/>
                        </actions>
                    </lookupPickerField>
                    <textArea id="descriptionField" property="description" rowspan="3" colspan="3" width="100%"/>
                </column>
                <column>
                    <lookupPickerField id="financialYearField" optionsContainer="financialYearsDc"
                                       property="financialYear">
                        <actions>
                            <action id="open" type="picker_open"/>
                        </actions>
                    </lookupPickerField>
                    <lookupPickerField id="financialPeriodField" optionsContainer="financialPeriodsDc"
                                       property="financialPeriod"/>
                    <lookupField id="transactionStatusField" property="transactionStatus"/>
                </column>
                <column>
                    <textField id="totalDebitField" property="totalDebit" editable="false"/>
                    <textField id="totalCreditField" property="totalCredit" editable="false"/>
                    <lookupPickerField id="currencyField" optionsContainer="currenciesDc" property="currency">
                        <actions>
                            <action id="lookup" type="picker_lookup"/>
                            <action id="open" type="picker_open"/>
                        </actions>
                    </lookupPickerField>
                </column>
            </form>
            <form dataContainer="journalDc" width="100%">
                <column>
                </column>
            </form>
            <groupBox id="journalLineBox" caption="msg://com.inteacc.erp.entity.acct/Journal.journalLine">
                <tabSheet>
                    <tab id="tabLines" caption="Entry">
                        <table id="journalLineTable" dataContainer="journalLineDc" width="100%" height="100%" editable="true">
                            <actions>
                                <action id="create" type="create"/>
                                <action id="remove" type="remove"/>
                            </actions>
                            <columns>
                                <column id="lineNumber"/>
                                <column id="account" editable="true" optionsContainer="accountsDc"/>
                                <column id="accountSub" optionsContainer="accountSubsDc"/>
                                <column id="costCentre" editable="true" optionsContainer="costCentresDc"/>
                                <column id="reference" editable="true"/>
                                <column id="debit" editable="true"/>
                                <column id="credit" editable="true"/>
                                <column id="debitFc"/>
                                <column id="creditFc"/>
                            </columns>
                            <buttonsPanel>
                                <button action="journalLineTable.create"/>
                                <button action="journalLineTable.remove"/>
                            </buttonsPanel>
                        </table>
                    </tab>
                    <tab id="tabAttachment" caption="Attachments">
                        caption="DOCUMENTS">
                        <split id="split1"
                               dockable="true"
                               height="100%"
                               orientation="horizontal"
                               pos="70"
                               responsive="true"
                               width="100%">
                            <table id="journalAttachmentsTable"
                                   height="100%"
                                   width="100%">
                                <actions>
                                    <action id="removeFile"
                                            invoke="onRemoveFile"
                                            trackSelection="true"/>
                                </actions>
                                <columns>
                                    <column id="attachment.name"/>
                                    <column id="attachment.extension"/>
                                    <column id="attachment.size"/>
                                    <column id="attachment.createDate"/>
                                    <column id="attachment"
                                            collapsed="true"/>
                                </columns>
                                <rows datasource="journalAttachmentDc"/>
                                <buttonsPanel>
                                    <multiUpload id="multiUploadField"/>
                                    <button id="btnDownloadFile"
                                            caption="Download"
                                            description="Download attached file"
                                            icon="font-icon:DOWNLOAD"
                                            invoke="onDownloadButtonClick"/>
                                    <button id="btnRemoveFile"
                                            action="journalAttachmentsTable.removeFile"
                                            caption="Remove file"/>
                                    <button id="btnDisplay"
                                            caption="Show"
                                            description="Display file"
                                            icon="font-icon:EYE"
                                            invoke="onShowButtonClick"/>
                                </buttonsPanel>
                            </table>
                            <scrollBox id="scrollBoxDoc"
                                       height="100%">
                                <image id="imageView"
                                       height="100%"
                                       width="100%"/>
                                <embedded id="pdfView"
                                          height="100%"
                                          width="100%"/>
                            </scrollBox>
                        </split>
                    </tab>
                </tabSheet>
            </groupBox>
        </scrollBox>
        <hbox id="editActions" spacing="true">
            <button action="windowCommitAndClose"/>
            <button action="windowClose"/>
        </hbox>
    </layout>
</window>

and Here is the Controller

@UiController("erp$Journal.edit")
@UiDescriptor("journal-edit.xml")
@EditedEntityContainer("journalDc")
@LoadDataBeforeShow
public class JournalEdit extends StandardEditor<Journal> {

    @Inject
    private InteaccUtilService inteaccUtilService;
    @Inject
    private UserSessionSource userSessionSource;
    @Inject
    private NumberGenerationService numberGenerationService;
    @Inject
    private AccountsService accountsService;
    @Inject
    private TimeSource timeSource;
    @Inject
    private UiComponents uiComponents;
    @Inject
    private Notifications notifications;
    @Inject
    private InstanceContainer<Journal> journalDc;

    @Inject
    private Table<JournalLine> journalLineTable;
    @Inject
    private LookupPickerField<Company> companyField;
    @Inject
    private CollectionPropertyContainer<JournalLine> journalLineDc;
    @Inject
    private CollectionContainer<AccountSub> accountSubsDc;

    @Inject
    private CollectionContainer<CostCentre> costCentresDc;
    @Inject
    private CollectionLoader<Account> accountsDl;
    @Inject
    private CollectionContainer<Account> accountsDc;
    @Inject
    private CollectionContainer<FinancialYear> financialYearsDc;
    @Inject
    private CollectionPropertyContainer<JournalAttachment> journalAttachmentDc;
    @Inject
    private Image imageView;
    @Inject
    private Embedded pdfView;
    @Inject
    private Table journalAttachmentsTable;
    @Inject
    private DataContext dataContext;

    @Subscribe
    private void onAfterInit(AfterInitEvent event) {

        initTableColumnListeners();
        initComboColums();

    }

    @Subscribe
    public void onAfterShow(AfterShowEvent event) {
        Company defaultCompany = userSessionSource.getUserSession().getAttribute("defaultCompany");
        if (defaultCompany != null) {
            getEditedEntity().setCompany(defaultCompany);
            getEditedEntity().setCurrency(userSessionSource.getUserSession().getAttribute("defaultCurrency"));
            getEditedEntity().setFinancialYear(inteaccUtilService.getFinancialYearFromCurrentDate(defaultCompany));
            getEditedEntity().setFinancialPeriod(inteaccUtilService.getFinancialPeriodFromCurrentDate(defaultCompany));

        }

        if (PersistenceHelper.isNew(getEditedEntity())) {
            getEditedEntity().setCompany(defaultCompany);
            getEditedEntity().setCurrency(getEditedEntity().getCompany().getBaseCurrency());
        }

        //companyField.setEditable(true);
        getEditedEntity().setTransactionStatus(TransactionStatus.NEW);
        getEditedEntity().setDocDate(timeSource.currentTimestamp());

        //sortLines();

        if (getEditedEntity().getCompany() != null) {
            loadChartOfAccount();
            loadFinancialYearList();
        }

    }

    @Subscribe("docDateField")
    public void onDocDateFieldValueChange(HasValue.ValueChangeEvent<Date> event) {
        if(getEditedEntity().getDocDate()!=null)
            showFinancialYear();
    }

    

    @Subscribe
    protected void onBeforeCommit(BeforeCommitChangesEvent event) {

        calculateAmount();
    }


    private void sortLines() {
        //       bankTranLineTable.sortBy(bankTranLineDs.getMetaClass().getPropertyPath("entryNumber"), true);
    }


    @Subscribe("journalLineTable.create")
    private void onJournalLineTableCreate(Action.ActionPerformedEvent event) {
        addNewRow(null);
    }


    @Override
    protected void validateAdditionalRules(ValidationErrors errors) {

        if(getEditedEntity().getJournalLine()==null){
            errors.add("Sorry, there was no detail transactions found in the table, can't Save..");
        }else {
            BigDecimal received = BigDecimal.ZERO;
            BigDecimal paid = BigDecimal.ZERO;

            //deleting empty row
            if (journalLineDc.getMutableItems().size() > 0) {
                List<JournalLine> toRemove = new ArrayList<>();
                Iterator<JournalLine> iteratorLineList = getEditedEntity().getJournalLine().iterator();
                while (iteratorLineList.hasNext()) {
                    JournalLine line = iteratorLineList.next();
                    if (((line.getDebit() == null) || (line.getCredit() == BigDecimal.ZERO)) && ((line.getCredit() == null) || (line.getCredit() == BigDecimal.ZERO))) {
                        toRemove.add(line);
                    }
                }

                for (JournalLine line : toRemove) {
                    journalLineDc.getMutableItems().remove(line);
                    dataContext.remove(line);
                }
            }

            for (JournalLine line : getEditedEntity().getJournalLine()) {

                if (line.getAccount() == null) {
                    errors.add("Invalid Account");
                }

                if (line.getAccount().getHavingSubAccount() == true)
                    if (line.getAccountSub() == null)
                        errors.add("Sorry, Sub-account field is empty");

            }
        }
    }


    private void calculateAmount() {
        //Calculate total
        getEditedEntity().setTotalDebit(getEditedEntity().getJournalLine().stream().map(JournalLine::getDebit)
                .reduce(BigDecimal.ZERO, BigDecimal::add));
        getEditedEntity().setTotalCredit(getEditedEntity().getJournalLine().stream().map(JournalLine::getCredit)
                .reduce(BigDecimal.ZERO, BigDecimal::add));
    }

    private void proposeDebitOrCreditAmount() {
        if (journalLineDc.getMutableItems().size() > 1) {
            //Calculate the total of Debit and Credit
            /*
            BigDecimal dr = BigDecimal.ZERO;
            BigDecimal cr = BigDecimal.ZERO;
            for (JournalLine line : journalLineDs.getItems()) {
                if(line.getDebit() != null) {
                    dr = dr.add(line.getDebit());
                }
                if(line.getCredit() !=null) {
                    cr = cr.add(line.getCredit());
                }
            }
*/

            BigDecimal dr = getEditedEntity().getJournalLine().stream().map(JournalLine::getDebit)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);
            BigDecimal cr = getEditedEntity().getJournalLine().stream().map(JournalLine::getCredit)
                    .reduce(BigDecimal.ZERO, BigDecimal::add);

            JournalLine i = Iterables.getLast(journalLineDc.getItems());
            if (((i.getDebit() == null) || (i.getCredit() == BigDecimal.ZERO)) && ((i.getCredit() == null) || (i.getCredit() == BigDecimal.ZERO))) {
                BigDecimal net = BigDecimal.ZERO;

                if (dr.doubleValue() >= cr.doubleValue()) {
                    dr = dr.subtract(cr);
                    journalLineDc.getItem().setCredit(dr);
                } else {
                    cr = cr.subtract(dr);
                    journalLineDc.getItem().setDebit(cr);
                }

            }

            if (i.getAccount().getAccountSub().size() > 0) {
                i.setAccountSub(null);
                //accountSubsDl.load();
                // set focus on the first cell of the added row
                journalLineTable.requestFocus(i, "accountSub");

            } else {
                //i.setCostCentre(null);
                //costCentresDs.refresh();
                journalLineTable.requestFocus(i, "costCentre");
            }
        }
    }


    private void addNewRow(CostCentre costCentre) {
        if (okToCreate()) {
            JournalLine line = dataContext.create(JournalLine.class);
            line.setJournal(getEditedEntity());
            line.setCostCentre(costCentre);
            line.setDebit(BigDecimal.ZERO);
            line.setCredit(BigDecimal.ZERO);
            line.setDebitFc(BigDecimal.ZERO);
            line.setCreditFc(BigDecimal.ZERO);

            //creating lineNumber
            int max = 0;

            Integer lastNum = journalLineDc.getItems().stream()
                    .map(JournalLine::getLineNumber)
                    .max(Integer::compareTo)
                    .orElse(0);
            line.setLineNumber(lastNum + 1);

            journalLineDc.getMutableItems().add(line);

            journalLineTable.setSelected(line);

            //       sortLines();

            // set focus on the first cell of the added row
            journalLineTable.requestFocus(line, "account");
            journalLineTable.scrollTo(line);
        } else {

            notifications.create(Notifications.NotificationType.HUMANIZED).withDescription("Please select the company first").show();
        }
    }

    private boolean okToCreate() {
        boolean ok = true;
        if (getEditedEntity().getCompany() == null) ok = false;
        if (getEditedEntity().getDocDate() == null) ok = false;
        if (getEditedEntity().getFinancialYear() == null) ok = false;
        if (ok == false)
            notifications.create(Notifications.NotificationType.WARNING).withDescription("Sorry, please update the required fields before inserting a row").show();
        return ok;
    }

    private void fixEntryNumbers() {
        int num = 1;
        for (JournalLine line : journalLineDc.getItems()) {
            line.setLineNumber(num++);
        }
    }

    private void initComboColums() {

        journalLineTable.addGeneratedColumn("accountSub", entity -> {
            if (entity.getAccount() != null) {
                if (entity.getAccount().getHavingSubAccount() == true) {
                    LookupField<AccountSub> lookupField = uiComponents.create(LookupField.of(AccountSub.class));
                    lookupField.setWidth("100%");
                    lookupField.setOptions(new ContainerOptions<>(accountSubsDc));
                    lookupField.setValue(entity.getAccountSub());

                    lookupField.addValueChangeListener(e -> entity.setAccountSub((e.getValue())));

                    return lookupField;

                } else {

                    return null;
                }
            } else {
                return null;
            }
        });

    }


    private void initTableColumnListeners() {

        journalLineDc.addItemPropertyChangeListener(e -> {
            if ("account".equals(e.getProperty())) {
                /*
                if (e.getItem().getAccount().getAccountSub().size() > 0) {
                    e.getItem().setAccountSub(null);
                    //accountSubsDl.load();
                    // set focus on the first cell of the added row
                    journalLineTable.requestFocus(e.getItem(), "accountSub");

                } else {
                    e.getItem().setCostCentre(null);
                    //costCentresDs.refresh();
                    journalLineTable.requestFocus(e.getItem(), "costCentre");
                }
*/


                proposeDebitOrCreditAmount();
/*
            } else if ("accountSub".equals(e.getProperty())) {

                if (e.getItem().getAccount().getHavingSubAccount() == Boolean.TRUE) {
                    if (e.getItem().getAccountSub() == null) {

                        notifications.create(Notifications.NotificationType.WARNING).withDescription("Incorrect Data entry, Please select the sub-account").show();
                    }
                }
                */

            }else if ("costCentre".equals(e.getProperty())) {

                journalLineTable.requestFocus(e.getItem(), "reference");
            }else if ("accountSub".equals(e.getProperty())) {

                journalLineTable.requestFocus(e.getItem(), "costCentre");

            } else if ("debit".equals(e.getProperty())) {
                if (e.getItem().getDebit().longValue() > 0) {
                    e.getItem().setCredit(new BigDecimal(0));

                    //if (Iterables.getLast(journalLineDs.getItemIds()) == e.getItem().getId()) {
                    JournalLine i = Iterables.getLast(journalLineDc.getItems());
                    if (i.getId() == e.getItem().getId()) {
                        CostCentre costCentre = null;
                        if( e.getItem().getCostCentre()!=null)
                            costCentre = e.getItem().getCostCentre();

                        addNewRow(costCentre);

                    }
                } else {
                    //get the balanance of Credit
                    BigDecimal d = getEditedEntity().getTotalDebit();
                    BigDecimal c = getEditedEntity().getTotalCredit();

                    e.getItem().setCredit(getEditedEntity().getTotalDebit().subtract(getEditedEntity().getTotalCredit()));

                }
            } else if ("credit".equals(e.getProperty())) {
                if (e.getItem().getCredit().longValue() > 0) {
                    e.getItem().setDebit(new BigDecimal(0));

                    JournalLine i = Iterables.getLast(journalLineDc.getItems());
                    if (i.getId() == e.getItem().getId()) {
                    //if (Iterables.getLast(journalLineDc.getItemIds()) == e.getItem().getId()) {
                        CostCentre costCentre = null;
                        if( e.getItem().getCostCentre()!=null)
                            costCentre = e.getItem().getCostCentre();

                        addNewRow(costCentre);

                    }
                }
            }

        });
    }

    private void loadChartOfAccount() {

        accountsDc.getMutableItems().clear();
        //load chart of account of the selected company

        //Company company = getEditedEntity().getCompany();

        List<Account> accountList = accountsService.getAccountListFromCompany(getEditedEntity().getCompany(), "accountSub-view");
        accountsDc.setItems(accountList);

//        for (Account account : accountList) {
  //          accountsDc.getMutableItems().add(account);
    //   }


     //ToDO
        /*select e from erp$Account e
        where e.accountHeader = FALSE and e in (select line.account from  erp$ChartOfAccountLine line
                where line.chartOfAccount = :coa)
        */

       // accountsService.getChartOfAccount();
      // accountsDl.setParameter("coa", getEditedEntity().getCompany().getChartOfAccount().getId());
      // accountsDl.load();

    }

    private void loadFinancialYearList() {
        financialYearsDc.getMutableItems().clear();
        //load chart of account of the selected company
        Company company = getEditedEntity().getCompany();
        List<FinancialYear> financialYearAllList = accountsService.getFinancialYearAllList(company, "financialYear-view");
        for (FinancialYear financialYear : financialYearAllList) {
            financialYearsDc.getMutableItems().add(financialYear);
        }

    }


    private void showFinancialYear() {
        Date date = getEditedEntity().getDocDate();
        Company company = getEditedEntity().getCompany();
        if (date != null) {
            if (company != null) {
                FinancialYear financialYear = inteaccUtilService.getFinancialYearFromDate(company, date);

                if (financialYear != null) {
                    getEditedEntity().setFinancialYear(financialYear);
                    getEditedEntity().setFinancialPeriod(inteaccUtilService.getFinancialPeriodFromDate(company, date));
                } else {

                    notifications.create(Notifications.NotificationType.WARNING).withDescription("Sorry, the date is invalid, no financial year exists").show();
                    getEditedEntity().setDocDate(null);
                    getEditedEntity().setFinancialYear(null);
                }

            }
        }
    }

    public void onRemoveFile(Component source) {
        if (journalAttachmentDc.getItem() != null) {
            journalAttachmentDc.getMutableItems().remove(journalAttachmentDc.getItem());
        }
    }

    public void onDownloadButtonClick(Component source) {
        //FileDescriptor fd = journalAttachmentsTable.getSingleSelected().getAttachment();
        JournalAttachment journalAttachment = (JournalAttachment) journalAttachmentsTable.getSingleSelected();
        FileDescriptor fd = journalAttachment.getAttachment();
        if (fd!=null){
  //          AppConfig.createExportDisplay(JournalEdit.this).show(fd,null);
        }
    }

    public void onShowButtonClick(Component source) {
        //FileDescriptor fd = journalAttachmentsTable.getSingleSelected().getAttachment();
        JournalAttachment journalAttachment = (JournalAttachment) journalAttachmentsTable.getSingleSelected();
        FileDescriptor fd = journalAttachment.getAttachment();
        if (fd != null) {
            if (fd.getExtension().equalsIgnoreCase("pdf")) {
/*
                pdfView.setSource(String.format("%s.pdf", fd.getUuid()), new FileDataProvider(fd));
                pdfView.setType(Embedded.Type.BROWSER);
*/
                imageView.setVisible(false);
                pdfView.setVisible(true);

                pdfView.setSource(String.format("pdf-preview%s.pdf", UUID.randomUUID()),
                        new FileDataProvider(fd));

            } else {
                imageView.setSource(FileDescriptorResource.class).setFileDescriptor(fd);
                pdfView.setVisible(false);
                imageView.setVisible(true);
            }
        }
}

I have reproduced it when I create the screen in Studio 13 & platform 7.2.x from the Entity I have created in older version of the platform i.e. Entity like erp$Journal vs. erp_Journal

Hi, remove

<rows datasource="journalAttachmentDc"/>

and specify dataContainer in the table

<table id="journalAttachmentsTable" dataContainer="journalAttachmentDc"
1 Like

Thank you.