Hello world,
I've posted a question in help forum (forum entry) for capturing url changes. bbakerman suggests me to use epng ExternalMonitor Compontent. It works for already created application instances, but if it is the first request to the application there comes a strange message. Then I've debugged the shit and saw that the best way to solve this problem is to generate an event in WindowHtmlService class. I've implemented the event like ExternalMonitor from epng does. Here is the patch if somebody is interested:
With this code you can create an WindowHtmlEventListener wich is fired if an already created instance get an SERVICE_ID_DEFAULT request... When you reload the application or change the url and press enter :-D
Greet germantux
For the record, the initial parameters of an application (at startup time that is) are available in an InitialParametersMap.
Yes, that's right. But when you click into the address bar and type something behind the uri or change some parameters the application is reloaded and the IntiialParamterMap is not updated, if the application already instantiated. The other problem is, that you are not able to receive an event if this occurs.
Why do I need this functionality? Simple, I want to code a shop with echo2. There I have some articles and the primary identifier for the article can be placed into the url to receive informations about this article.
Now there are to cases:
1. This is the first request to echo2. A new application is created and I parse the return of
WebRenderServlet.getActiveConnection().getRequest().getRequestURI().2. The application instance already created and an event is raised that the site was rendered from the beginning. Here I need to check if the URL was changed since last request or since application creation.
If there is a change to the URL I need to parse it. If it contains a valid article identifier I need to change the view of my application.
WindowHtmlEventMonitor wem = new WindowHtmlEventMonitor(); wem.addExternalEventListener(new WindowHtmlEventListener() { public void windowHtmlEvent(WindowHtmlEvent arg0) { System.out.println(arg0.getUri()); } }); some_column.add(wem);With the ExternalEventMonitor I had problems with the first request. The first request may not contain the ServiceId=ExternalEvent. This gives some problems. But further request to the application must contain the ServiceId=ExternalEvent. This make Problems to for someone who want to make a link to an article ... like search engines or else.
Is this still recommended
Hello all,
I'm interested in the functionality described here, but the post is old, from 2006, we are already past mid 2008.
I'm wondering if this is still what you have to do to capture URL changes.
I would prefer not to patch the framework but to work with what the framework provides.
I have played with ExternalEventMonitor but I get an infinite number of requests to the server.
Thanks
Jaime