Hello! How to fix the exception? The passed model has ‘address’ key, but binder can’t get defaultValue.
This rendering array model:
${this.binder.model.projectDocumentsDeveloper ? repeat( this.binder.model.projectDocumentsDeveloper, (declarant) => { return html
<vaadin-text-field
…=${field(
declarant.model.organization.address.country
)}
>
; } ) : ""}
The error appearce when I try to add an element into array:
<vaadin-button @click=${() => { if (!this.binder.value.projectDocumentsDeveloper) { const declarant = TDeclarantModel.createEmptyValue(); declarant.organization = TOrganizationModel.createEmptyValue(); declarant.organization.address = TAddressModel.createEmptyValue(); this.binder.value.projectDocumentsDeveloper = [declarant]; } else { this.binder .for(this.binder.model.projectDocumentsDeveloper) .appendItem(); } this.requestUpdate(); }} > Add </vaadin-button>
This is Java model:
protected List<TDeclarant> projectDocumentsDeveloper;
this is console.error:
Encountered an uncaught exception that was thrown by a reaction or observer component, in: ‘Reaction[ConclusionView.update()]’ TypeError: Cannot read properties of undefined (reading ‘address’)
at get defaultValue [as defaultValue] (BinderNode.ts:153:26)
at g2.initializeValue (BinderNode.ts:422:73)
at new g2 (BinderNode.ts:94:10)
at b2 (Models.ts:23:26)