on 07-22-2013 8:47 AM
Hi All,
I have developed a Sencha Extjs application in which i am using ODATA (from Tcode SEGW) to get the data from the backend and in the GET_ENTITYSET of data provider class method i am initially getting data from dbtable into global variable (class attribute).
and now when i update the data from the front-end and save it. the UPDATE_ENTITY method is called . and here i want to access the data stored in that global variable save in the GET_ENTITYSET method ( instead of getting from the database again )
Here, the odata is stateless.How can i maintain its state to stateful.?
And here i provide a small piece of my code.
METHOD carrid_get_entityset.
IF mt_test IS INITIAL.
SELECT * FROM ztest2 INTO CORRESPONDING FIELDS OF TABLE mt_test.
ENDIF.
ENDMETHOD.
METHOD carrid_update_entityset.
" Now i want to access data in mt_test here but it is initial.
ENDMETHOD.
Any help could be appreciated. Thanks in advance.
Regards,
Shiva
Shiva,
Just to extend Andre's answer,
You cannot retain data between a get_entity set call and update entity call. (That is stateless. Each call is on its own and independent).
You need to pass the data to be updated as request body ( also called as payload) of your update request.
Thanks
Krishna
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andre and Krishna,
Thanks for your response.
Yes, i am able to perform the update operations in the database by writing the UPDATE statement in the update_entity method.
But in that update_entity method i want to make some validations for the new entry(in the grid) by checking it with my old entries , which i am not able to retain it (from the get_entity method).
As i think i have two options of doing this task done.
1. Doing validations in the front-end and send data to update request only if valid.
2. Get the data from the database by writing SELECT statement in the update method every time. (Performance Problem).
Is there any way by which i can get my old entries from the grid in the update_ entity method.?
Regards,
Shiva
Hi Krishna,
Client-side validation with OData is possible but I would not suggest it as best practice. Part of the concept of OData services is the openness of data transport and the separation of business logic, so you can request the input of any data you wish. Without server side validation this is extremely risky.
The validation on client side will normally be simple, i.e. do we have the complete data that we think the request requires and are the values valid as far as we know? (In this case I can't see how "validation" is possible by simply comparing old and new)
This might be supplemented by some function imports that provide lookup tables, but otherwise I would expect the business rules to execute on the BEP server which is also the system of record in most cases. If the data is not acceptable, a BUSI exception should be raised by the update/create method - that is what it is there for.
@ Shiva: OData is not a replacement for Web application frameworks; if the application is that complex, consider using one of the integrated frameworks like WD or BSP which will allow embedded MVC behaviour and better integration with the business logic.
Regards
Ron.
Hi Shiva,
the OData protocol is meant to be stateless.
What you can do however is to maintain the state on client side.
Best Regards,
Andre
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.