Skip to Content

SAPUI5 - Text Area not updating for newly created model entry

Hi All.

I'm having an issue with a Text area that I've added onto my Detail screen of a master-detail app. I've bound a read-only Text area to a key in the model:

Detail.view.xml (partial showing property binding)
<TextArea id="TASOR" editable="false" width="100%" wrapping="Hard" value="{Comment}"/>

Detail.controller.js (partial showing Element Binding at M-D object matching)

_onObjectMatched: function(oEvent) { ...

oTASumORA = this.getView().byId("TASOR"), //Text Area
oTASumORA.bindElement(this.getModel().createKey("/ZMBRComments", this.oProperties));

I then have a pop-up dialog to update the text which is also bound to the model:

SummaryCommentDialog.js (partial - apologies for the formatting)
openDialog: function(oButtonEvent) { ...

// Create a key to the Comment
var sCommentPath = this.getModel().createKey("/ZMBRComments", oProperties);
// Does this entry exist in the model already?
this.oCommentContext = this.getModel().getContext(sCommentPath); // Get Context to Comment
var sComment = this.getModel().getProperty("Comment", this.oCommentContext);
//Copy comment into variable
if (!sComment) {
//No Existing Comment - so create entry
this.oCommentContext = this.getModel().createEntry("/ZMBRComments", { properties: oProperties });
// Rebind the Text Area on the Detail View as well - Otherwise may not refresh if new comment
var oTextArea = this._oParentView.byId("TASOR"); oTextArea.bindElement(this.getModel().createKey("/ZMBRComments", oProperties));

//Bind the Comment Content Area to the comment context
var oContent = this._oParentView.byId("commentNoteSum"); //Get a reference to the Content Area oContent.setBindingContext(this.oCommentContext);
// open the dialog window;

This all works perfectly if the comment record already exists on the backend. The problems occur when the the comment record doesn't exist yet and needs to be created.

1. I get a "Resource not found for segment 'ZMBRComment' " error. This is a minor issue as it doesn't stop processing - just logs it in the gateway error log.

2. The pop-up creates the new Model record and binds it correctly to the updateable text area - which subsequently updates the model value. But the value of the display only text area on the Detail screen does NOT update with the new value (stays blank). If I re-open the pop-up the new value is there and if I change it a second time - the value on the detail screen now gets updated.

I'm sure it's probably a timing thing - it looks as if the creation of the binding of the Detail View text area ("TASOR") during the creation of the pop-up dialog event does not trigger the view to re-evaluate the "Value" property of the text area. Is there a way to force the re-evaluation?


Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers