cancel
Showing results for 
Search instead for 
Did you mean: 

SAP UI5 Master Detail - Bindelement does not work for the 2nd call

0 Kudos

Hi there,

I have a list page to show all the employees and when I click the first data, I can successfully get the odata with the right data, e.g employeeSet('001')

But when I pressed back to the list and select another employee, e.g employeeSet('002'), it's still referring to the first data, when I debugged, the ID already being called as '002'.

But the textbox still showing the 1st data (001), what should I do?

When I refresh the page manually, the 2nd data is appearing.

Here's my detail view and the controller

<mvc:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:html="http://www.w3.org/1999/xhtml"
	controllerName="app.employeeEmployee.controller.employee">
	<App>
		<pages>
			<Page title="page">
				<content>
					<VBox width="100%" direction="Column" id="__vbox0">
						<items>
							<Text text="{Firstname}" id="__text0"/>
							<Text text="{Lastname}" id="__text1"/>
						</items>
					</VBox>
				</content>
			</Page>
		</pages>
	</App>
</mvc:View><br>
		onInit: function() {
			var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
			oRouter.getRoute("employee").attachMatched(this._onRouteFound, this);
		},

	// Custom Method to bind the elements using the Event Arguments
		_onRouteFound: function(oEvt) {
			var oArgument = oEvt.getParameter("arguments");
			var oView = this.getView();
			oView.bindElement({
				path: "/employeesSet('" + oArgument.Kodeemp + "')",
				events: {
					change: this._onBindingChange.bind(this),
					dataRequested: function(oEvent) {
						oView.setBusy(true);
					},
					dataReceived: function(oEvent) {
						oView.setBusy(false);
					}
				}
			});
		},
		_onBindingChange: function(oEvent) {
			var oElementBinding = this.getView().getElementBinding();
			// No data for the binding
			if (oElementBinding && !oElementBinding.getBoundContext()) {
				this.getRouter().getTargets().display("notFound");
			}
		}
TobiT
Participant
0 Kudos

Dear Samuel,

could you please debug the value of oArgument.Kodeemp once you click on the second line?

What is the value? Is it called just once with the correct value or is ist maybe never called again?

Accepted Solutions (0)

Answers (2)

Answers (2)

ThorstenHoefer
Active Contributor

Hi Samuel,

try attachRoutePatternMatched instead of attachMatched.

TobiT
Participant
0 Kudos

Isn't the only different that matched informs about nested route matching as well and patternMatched only notifies for own patterns? Should be neglectable in this case.

0 Kudos

hi this has been resolved, the model binding mode change into oneWay from Onetime