cancel
Showing results for 
Search instead for 
Did you mean: 

JSONModel resets automatically after catching an business exception from backend

0 Kudos

Hi everyone,

I have a main view which shows an custom user table from backend. You can update the user information by clicking on a button inside the table row. Afterwards a fragment with an dialog opens which shows the details of the corresponding user. The controls inside the dialog are bound to an edit model (JSONModel) to transfer table data into the dialog and detach // it from the main model for temporary editing. If i change some informations like the department number and submit those changes i do validations on the backend side. In case the given department could not be found on backend side i raise an /iwbep/cx_mgw_busi_exception which is caught on the frontend via callback function. The callback function updates the valueState and the valueStateText to give the user informations about the cause of failure.

Here comes the problem: Somehow, the edit model resets itself to the inputs that were initially loaded from the table. The UI on the other hand still shows the incorrect userinputs. In this state i am able to submit the dialog a second time without changing anything and the update succeed (although without changing anything, because everything on the edit model was reset).

What am I doing wrong here?

Kind regards

Marvin

Accepted Solutions (0)

Answers (1)

Answers (1)

Sharathmg
Active Contributor

Due to binding the data in view gets updated in model.

As I understand, the challenge is to keep the data in modal popup separate from the table. The data in the table should be updated only after the service returns a success.

Why not maintain separate models for popup and table? or Reset the data in popup, in case the oData call results in error? Second option may be better, but you just need to hold the pre-edited data and reset the model back to pre-edited data in case of error.

Regards,

Sharath

0 Kudos

Hi Sharath,

thanks for your quick reply!

As I understand, the challenge is to keep the data in modal popup separate from the table. The data in the table should be updated only after the service returns a success.

exactly.

Why not maintain separate models for popup and table?

That's what i'm trying to do with my separate JSONModel which is bound to the fragment dialog.

or Reset the data in popup, in case the oData call results in error? Second option may be better, but you just need to hold the pre-edited data and reset the model back to pre-edited data in case of error.

That's what kind of happening right now, but this isn't the behavior i wanted to achieve. In case of an error on backend side the user inputs inside the dialog should be kept while marked as incorrect via ValueState / ValueState Text. Currently the UI does this, but the JSONModel bound to the Dialog resets itself and i don't know why.

Kind regards

Marvin