I have lost all the morning searching for this problem on internet and nobody seems to face this problem.
My GWT application navigate very well. But as a logic requirement on my application it generates an email with a link to my application. The link is something like this:
http://server#place:token
Well, it navigate always to the same DefaultPlace i declare on initialization.
I have write a lot of logs in the client side. And it ignores completely the request. Even if i type this url in the browser, it loads default place.
My application navigates very well between places internally but now i realize that it happens not only with one particular place, but any place.
Could some one help me to realize what would be the problem. I could write the code if any want to see.
This is my PlacehistoryMapper:
#WithTokenizers({DefaultPlace.Tokenizer.class,
AuthenticationPlace.Tokenizer.class,
ProcessSnCallbackPlace.Tokenizer.class,
GatherUserInfoPlace.Tokenizer.class,
LoadProfilePlace.Tokenizer.class,
RegisterPlace.Tokenizer.class})
public interface AppPlacesHistoryMapper extends PlaceHistoryMapper
}
This is my ActivityMapper in getActivity override:
#Override
public Activity getActivity(Place place) {
Provider provider = getProvider(place);
if (provider == null) {
browserUtils.log("Error: " + place.getClass().getCanonicalName() + " Place is not mapped.");
return null;
}
return (Activity) provider.get();
}
And all activities all injected by GIN and works fine. But always when debug the default place is the only i see in those line. However if i change the place by goTo it works fine.
Thanks in advance.
Cheers
Albert.
Related
I've been given this old Apache Wicket 1.5 web application.
All the URLs seem to end in ?xxx, where xxx is a number. This seems to be a Wicket "feature" that allows you to version / cache previously shown webpages. As nice as it might sound, in practical terms this is nothing more than a headache for all users involved, as even if the underlying data shown on the page changes and the user forces a page refresh, the old, stale page is still reloaded.
I've browsed online and in Wicket's docs it seems to be referred as "versioning".
I've tried to disable it by calling setVersioned(false) but it was of no avail -- I see no observable difference. Does anyone know how to get this to work?
Thanks
The problem is that your application caches the data into the models. In Wicket terminology this is called a static model.
For example:
Person person123 = personService.get(123);
// a static model
page.add(new Label("personMood", new Model(person123.getMood())));
Here the Label will always show the mood of the person at the time of instantiation of the Label. The person may change his/her mood in the next second but the Label will still show the old/cached value.
// a dynamic model
page.add(new Label("personMood", new Model<String>() {
#Override public String getObject() {
return person123.getMood();
}
}));
here the Label will render the current mood of the person at every render of this label/page.
The pageId in the url tells Wicket which stateful page to lookup and load from the page store. Only stateful pages have such id. If you want to get rid of it then you should use only stateless components and behaviors in your page. There is wicket-devutils module which provides StatelessChecker to help you identify the reason when a Page becomes stateful by accident.
In your case I am not sure which solution would be easier - to rework the Model(s) or to make the page stateless. Usually the first is easier.
We have developed a dashboard in GWT that contains some custom widgets for displaying customer's data in various graphical forms. We now want to move to a more custom / user specific approach where each customer who logs into the dashboard can see a different perspective of the dashboard. Some widgets will be available for some users, for some others not and with different initialization parameters.
We are trying to find an efficient strategy to do this. A potential solution would be to have the client side request all this information during EntryPoint loading and then use that incoming configuration to build itself and make further requests for the data. A more efficient solution would also allow downloading to the browser only those widgets relevant to the user.
Does GWT have any design pattern for this scenario? If not, what would a good high level solution be for this case?
Thank you.
Yes there is atleast one mechanism that can be useful to achieve your requirements
Code Splitting :- The idea is to split the particular section of code and download it in independent async call. Using this approach you can reduce the size of primary javascript file making initial page load faster. This approach allow GWT to skip inclusion of all those widgets which have references only inside GWT.runAsync() method in primary js file. Such widgets and code gets downloaded when application runs that code in independent call. you can use this approach and avoid download of additional dashboard charts based on some conditions like user type and so. Here is sample code from GWT reference website
public class Hello implements EntryPoint {
public void onModuleLoad() {
Button b = new Button("Click me", new ClickHandler() {
public void onClick(ClickEvent event) {
GWT.runAsync(new RunAsyncCallback() {
public void onFailure(Throwable caught) {
Window.alert("Code download failed");
}
public void onSuccess() {
Window.alert("Hello, AJAX");
}
});
}
});
RootPanel.get().add(b);
}
}
I don't want to use the Codename One designer/gui builder, but I want to make my app with manual code. I have gained familiarity with Netbeans over the past three or four months, but when I opened a Codename One project I was confused and am not even sure where to start. This is some of the starting code when opening a new Codename One project:
public void start() {
if(current != null){
current.show();
return;
}
Form hi = new Form("Hi World");
hi.addComponent(new Label("Hi World"));
hi.show();
}
public void stop() {
current = Display.getInstance().getCurrent();
}
public void destroy() {
}
Does any one know where I can find a resource for the Codename One API? (found it) Can someone share some example code with working button on the start screen that takes the user to another screen that might have another button that takes them back to the start screen? (I think some example code would be very helpful to me in figuring out how to build my own application in Netbeans with Codename One.) Also, is there any better/easier way to build an app in Netbeans beside Codename One?
Please don't ask me to post what I have so far so you can help me, because I have nothing so far (in terms of code) -- only an idea of what I want the app to do.
They are all in subversion. You can check it out directly from Google code.
e.g. svn checkout https://codenameone.googlecode.com/svn/trunk/Demos/
I’m trying to create a backend for a homepage with GWT. I created a Google Web Application in Eclipse without sample code and now I would like to add the service, but the developer Google guide doesn’t help me. I’m not sure, where to add the interface and how it exactly works.
If I understand the google documentation correctly, I have to add a module and an entry point class, is that correct? It would be great if you could give me some tips and help how to create a rpc service.
If you create a new GWT project in the Eclipse "New Project" wizard, with "Generate project sample code" checked, it will include a fully functioning RPC service with a sample method, which you can then adapt or copy according to your needs.
Out of memory, don't have eclipse in front of me.
First do create a test project with generated testcode, you can delete it afterward.
Yes you will have to add a module.
Create in client the two interfaces for the async calls, inherit it on server side.
Hope I understood your question right.
I'm not sure what would help you the most. Google developer guide was enough for me (at least when I started using it on version 1.6) to create RPC services for my GWT application.
General APP
Module: is the .gwt.xml file. Yes, you'll need it. The GWT compiler will find it automagically and try to compile all the GWT code (the <source> element will tell which subpackage contains Java code that will be converted to JS). It will tell also which class implements the EntryPoint interface. The onModuleLoad will be the code executed when javascript runs in the client page.
RPC
Well, you should first try UI things and only then, when you're confident enough, try the server thing. Anyway the scheme is:
interface MyService extends RemoteService {
List<String> doSomething(String sample, int other);
}
#RemoteServiceRelativePath("../path/to/servlet") // see later
intercace MyServiceAsync {
void doSomething(String sample, int other, AsyncCallback<List<String>> callback);
}
These are the interfaces. Later is the async one. That's what you'll use from client side. Always calling and passing an implementation of AsyncCallback which will receive (sometime later, you don't know when) the result.
First interface is the syncrhonous one. That is what you need to implement on server. You must inherit from RemoteServiceServlet class (it is an implementation of servlet that already does all the values handling), and implement your interface. GWT code does the rest (almost).
public class ServiceImpl extends RemoteServiceServlet implements MyService
{
// implement the method normally
}
From client you'll need to create the service proxy:
private static MyServiceAsync MY_SERVICE = GWT.create(MyService.class);
Yes. I know it's weird how GWT knows MyserviceAsync and MyService work together. Don't worry about that. It works :)
Just use the service like this:
MY_SERVICE.doSomething("value", 111, new AsyncCallback<List<String>>() {
// note that this code executes some time in the future when response from server is back
public void onSuccess(List<String> result) {
Window.alert("Server answered with " + result.size() + " elements!");
}
public void onFailure(Throwable t) {
Window.alert("Server failed: " + t.getMessage());
}
}
Path to server
You'll have to configure your app to make that servlet implementation listen to URL indicated in #RemoteServiceRelativePath. That's the way client knows where to make the request, and the server knows which servlet attends that request. I'd suggest using:
../my-service.gwt as relative path (GWT module gets published in <ROOT>/module_name
and
configuring your web app to use the servlet for /my-service.gwt
But it's entirely upon your preferences :)
Anyway I think Google tutorials are the best. So please copy&paste. Try&modify until you get to understand the whole thing.
I've divided my GWT app into multiple modules, what's the best way to navigate between them?
Currently I'm using Window.Location.assign("foo.html#bar") but is there a better way?
History.newItem only works for history within the current module. To change to another page I think the best way is to use Window.Location.assign.
I don't fully remember the issue (and perhaps it has been fixed now), but in our application we stopped using relative URLs as they would sometimes break (we have a comment referencing http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/f79e7d5e002b48f6).
To this end we had a method that did the following:
public void goToRelativePage(final String relativeURL) {
Window.Location.assign(GWT.getHostPageBaseURL() + relativeURL);
}