-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Registering routing at component level #687
Comments
This is a quite common need while developing applications using 3rd party components. Response dataUsing a prado callback to make the request and ResponseData to return the data, that then will need to be parsed in javascript, as implemented in TJuiAutoComplete.
External serviceAdding an external service in application.xml (eg. TJsonService, TSoapService, ..) that exports a few methods that will be called directly by javascript using ajax.
The solution you propose is intriguing, being a mix of these two approaches. |
Hi @ctrlaltca "DataTable" is a very bad name :-D
I was thinking to that new approach to be able to integrate very well javascript framework like Vue.js or Angular. I was thinking to have somenthing like a TAngualarPage or TVueJsPage to make SPA development very easy using prado component template syntax to reuse both js code on frontend and php code on backed for event based processing of events. But in the mean time let's simply start with a datatable... |
Frequently we are facing the issue to integrate a javascript library/componets into Prado and most of those use "simple" rest api call to interact with backend. Most of the time I wrap those call with a Prado Callback call but I was thinking that can be good to have a Prado Page and any components to handle a rest call (GET/POST) internally simply registering a route "relative" to the page where the component is placed.
As exampla:
A component during init can do something like:
$this->registerRoute("/datatable" + $this->getControlId() + "/getdata", **a callable **); Callable can be also a method/event of the component. PageState/ComponentState can be an issue, maybe can be passed as request paramenters or those handler will have limited access to pagestate.
if this component is inserted into a page with friendly-url enabled
/myapp/page/mypage
the rest call to url
/mypage/page/mypage/datatable/dt1245/getdata
will be handled by the specific code of the component.
This approach can make easier handling integration of third party library or manage some asynchronous loading of component contents or having only small part of the page code executed. To make things more complex a "page state" can be passed or not depending if the component need to interact with other components or not.
I would like to share my idea with the community to have feedback and suggestions and have opionions from more valuable developers.
The text was updated successfully, but these errors were encountered: