Comments (11)
I don't understand your question.
On one side we declare an interface that will be called to make a REST call (for example in a presenter). On the other hand, it is the server side, which will receive it and return the response and content, depending on the case.
Could you clarify a little bit more what implementation you are expecting?
from gwtp-samples.
"In the carstore sample project, the only resource that uses RestAction"
It's probably because we didn't change the other services to this more idiomatic way of doing things. ;)
The general principle is that Rest-Distpach (client-side) uses an interface. As we also do our backends in Java, we put that interface (for example StatisticsResource) in a shared package.
That way, we can implement that interface on the server-side (StatisticsResourceImpl).
But Rest-Dispatch is a client-side library, so your backend could be in any language that you want.
from gwtp-samples.
Yes absolutly, i will detail to be clear enougth.
I followed the documentation to use your Rest-Dispatch module. If i read well, in this documentation you cover the project configurations, the dependencies, the definition of the service (interface), and the usage in the presenter, but nothing on the way to implement the service on the server side.
So, i have no problems with the interface that define what the service provides, on the client side, which could be:
@Path(FOO)
@Produces(MediaType.APPLICATION_JSON)
public interface FooResource {
@GET
RestAction<FooDTO> getFoo();
}
nor with the usage of RestDispatch in a presenter:
@Inject RestDispatch dispatcher;
@Inject FooResource fooResource;
...
dispatcher.execute(fooResource.getFoo(), new AsyncCallback<FooDTO>() {
@Override
public void onFailure(Throwable throwable) {
}
@Override
public void onSuccess(FooDTO fooDto) {
}
});
But, on the server side, how do i implements the service and return RestAction ?
So I reviewed your project to determine how you implemented the services.
As far as i can tell, in the carstore project, the RestAction interface is used only one time in the https://github.com/ArcBees/GWTP-Samples/blob/master/carstore/src/main/java/com/gwtplatform/carstore/shared/api/StatisticsResource.java interface.
But the interface isn't used, even in a module e.g.:
bind(FooResource.class).to(FooResourceImpl.class);
In place of something like that i've found a simili-implementation (the interface isn't implemented) (https://github.com/ArcBees/GWTP-Samples/blob/master/carstore/src/main/java/com/gwtplatform/carstore/server/api/StatisticsResourceImpl.java) and this binding:
public class ApiModule extends AbstractModule {
@Override
protected void configure() {
...
bind(StatisticsResourceImpl.class);
...
}
}
Moreover in the presenter that uses this StatisticsResource, you are using the ResourceDelegate extension.
So my question is in fact how do i implement a service that is providing RestAction on the server side ? (without using Response and DelegateResource extension)
Thanks
from gwtp-samples.
Thanks for your second comment, i think that my previous comment will explain better what is my problem.
But when you say: "It's probably because we didn't change the other services to this more idiomatic way of doing things"
I assume it's not, since you are using ResourceDelegate in every presenters, and also because the RestDispatch is expecting RestAction:
public interface RestDispatch {
<A extends RestAction<R>, R> DispatchRequest execute(A var1, AsyncCallback<R> var2);
}
from gwtp-samples.
One important thing that @Chris-V just reminded me is that there is a lot of magic that is generated by the Rest-Dispatch library.
from gwtp-samples.
I'm not sure to understand ^^
Sure there is a lot of magic behind the rest-library, but my only consideration is to implement the resource interface, in order to bind the interface to its implementation on the server side:
bind(FooResource.class).to(FooResourceImpl.class);
Long story short: how can i return a RestAction object
Clue (i don't know): i've seen in previous releases a RestService interface in rest-dispatch shared package, which seems to make the bind possible between a RestAction and a FooDTO, but it's no longer available in the current release
from gwtp-samples.
To achieve that, you need to use the dispatch-rest-delegates extension : https://github.com/ArcBees/gwtp-extensions/tree/master/dispatch-rest-delegates.
This will allow you to reuse your interfaces on the server-side. You can take a look at the CarStore for some examples : https://github.com/ArcBees/GWTP-Samples/tree/master/carstore
from gwtp-samples.
Indeed, i already make it work with the ResourceDelegate module, but like you announce it in the presentation of the extension, the type safety is not ensured by the language level.
I could go for ResourceDelegate, but it would be nicer for me to use the original strategy (i already said that i'm not willing to use ResourceDelegate).
Please re-read my comments, i think it's clear enough. Maybe, i'm looking for something which didn't exist already.
Thanks in advance
from gwtp-samples.
dispatch-rest is a client only library, that's why there's no information on how to implement it on the server-side. At the moment, the dispatch-rest-delegates is the only way you can use the same interfaces on both the client and the server. In fact the motivation behind the dispatch-rest-delegates was to do exactly what you want to do.
from gwtp-samples.
I understand that rest-dispach is a client only library (i was blind).
There was previously two package, client and shared for rest-dispatch. So there was a part that could be used by the server.
This is why i was confused, i probably digged to much, looking for something more like rpc.
Thanks for your time.
ps: i still believe that ResourceDelegate is a partial solution, are you working on something else ?
Great work though
from gwtp-samples.
What are your thoughts? There's a couple of road that could be taken, but few leads to where we wanted to go. If you have anything on your mind that could help us think about another direction that we might have not think about, you're more than welcome :D
from gwtp-samples.
Related Issues (19)
- Tune the crawler and add it to the demo HOT 2
- Is there any sample to using ltgt maven plugin?
- Add an editors sample or editors in an example HOT 2
- Add PresenterFactory to one of the samples. HOT 3
- Some class are missing HOT 8
- In Sample Tabs widgets change css to resources HOT 2
- Update and clean pom HOT 1
- GWTP-Samples doesn't compile HOT 1
- GWT-POLYMER sample works fine with chrome, android but doesn't work with ios, safari, firefox HOT 13
- carstore not works HOT 1
- admin/querty does not work as password in carstore HOT 2
- Carstore server and client use conflicting versions of Jackson
- gwtp-sample-tab Doesn't work in Chrome/Firefox HOT 2
- gwtp-sample-tab Dialogs tab IllegalArgumentException HOT 1
- Readme link to archetypes is invalid (404) HOT 3
- samples not in sync with tutorial part 2 HOT 2
- Bad authentication response: 404 Not Found on mvn deploy to GAE
- Gwtpsample.gwt.xml missing from classpath
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gwtp-samples.