svetlo / gwt-platform

Automatically exported from code.google.com/p/gwt-platform
0 stars 0 forks source link

Route like placenames #412

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Full description can be found at:
=====================
https://groups.google.com/forum/?fromgroups#!topic/gwt-platform/O4hNzXTJkoE

Abstract:
=======
I would like to have placenames with variable content parts.

For instance: place
#!/de/index
and
#!/en/index

should be handled by the very same presenter.

Solution:
=======
James (james@jazzy.id.au) and I just worked out a solution that
allows you to use route like place names containing parameters.

Something like
#!/profile/{name}

now works and allows nice for "restful" urls.

It involves using a custom TokenFormatter and a custom PlaceRequest.

The code is at:
https://gist.github.com/2252190
and
https://gist.github.com/f65acbd818abbcd6ad62

We would really love to see that kind of ability built into gwtp at a
certain point. Let us know what you think!

Original issue reported on code.google.com by raphael....@gmail.com on 10 Apr 2012 at 8:12

GoogleCodeExporter commented 9 years ago
I really like this TokenFormatter! I'm going to review the code more carefully 
later, but correct me if I'm wrong, but all functionalities (even hierarchical 
places) are still working, right?

Also, is it as simple as to bind your tokenformatter instead? Can both place 
request and ParametrizedPlaceRequest be fired on with your Tokenformatter?

This also removes all ;!

I'm really going to use this :D

Original comment by christia...@arcbees.com on 11 Apr 2012 at 3:20

GoogleCodeExporter commented 9 years ago
Regarding hierarchical places:
- They work. As long as the separator does not collide with the "/"

Regarding one TokenFormatter to rule them all:
- That works. Our TokenFormatter is a drop in replacement for the original one.
eg we are using: 
bind(TokenFormatter.class).to(ParameterizedParameterTokenFormatter.class);

Original comment by raphael....@gmail.com on 11 Apr 2012 at 8:23

GoogleCodeExporter commented 9 years ago
Hi Raphael,

Could you post sample code that uses your custom TokenFormatter and 
PlaceRequest?  I am thinking about using this code; it would be much 
appreciated.

Additionally, I have noticed that the tokens you gave as examples contain 
locale settings.  Are you changing the locale dynamically depending on the 
token?  If so, how are you dynamically switching the locale using GWT?

Many thanks!

Cheers,
Jean

Original comment by jeanjea...@gmail.com on 14 Apr 2012 at 5:11

GoogleCodeExporter commented 9 years ago
Could you add the code review link here too please? thanks

Original comment by goudreau...@gmail.com on 23 May 2012 at 2:25

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Comments welcome :) 
http://codereview.appspot.com/6257054/

Original comment by raphael....@gmail.com on 25 May 2012 at 9:38

GoogleCodeExporter commented 9 years ago
appreciated for this feature

Original comment by travalle...@gmail.com on 10 Jun 2012 at 5:46

GoogleCodeExporter commented 9 years ago
Where can I find the code for the last PR? Do you have a public clone somewhere?

I want to merge this in the project and test it locally.

Original comment by goudreau...@gmail.com on 9 Jul 2012 at 6:16

GoogleCodeExporter commented 9 years ago
i tested out. the sample work ok but got null pointer on     String val =
params.get(key); //can be improve 
20:26:47.791 [ERROR] [gwtpsample] Uncaught exception escaped
java.lang.NullPointerException: null
    at
com.gwtplatform.mvp.client.proxy.ParameterizedPlaceRequest.getParameter(Paramete
rizedPlaceRequest.java:187)
    at
com.gwtplatform.samples.basic.client.UserPresenter.prepareFromRequest(UserPresen
ter.java:76)
    at
com.gwtplatform.mvp.client.proxy.ProxyPlaceAbstract$3$1.execute(ProxyPlaceAbstra
ct.java:205)
    at
com.google.gwt.core.client.impl.SchedulerImpl$Task$.executeScheduled$(SchedulerI
mpl.java:50)
    at
com.google.gwt.core.client.impl.SchedulerImpl.runScheduledTasks(SchedulerImpl.ja
va:228)
    at
com.google.gwt.core.client.impl.SchedulerImpl.flushPostEventPumpCommands(Schedul
erImpl.java:388)
    at
com.google.gwt.core.client.impl.SchedulerImpl$Flusher.execute(SchedulerImpl.java
:78)
    at
com.google.gwt.core.client.impl.SchedulerImpl.execute(SchedulerImpl.java:138)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172
)
    at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessagesWhileWaitingForRetu
rn(BrowserChannelServer.java:337)
    at
com.google.gwt.dev.shell.BrowserChannelServer.invokeJavascript(BrowserChannelSer
ver.java:218)
    at
com.google.gwt.dev.shell.ModuleSpaceOOPHM.doInvoke(ModuleSpaceOOPHM.java:136)
    at com.google.gwt.dev.shell.ModuleSpace.invokeNative(ModuleSpace.java:561)
    at
com.google.gwt.dev.shell.ModuleSpace.invokeNativeObject(ModuleSpace.java:269)
    at
com.google.gwt.dev.shell.JavaScriptHost.invokeNativeObject(JavaScriptHost.java:9
1)
    at com.google.gwt.core.client.impl.Impl.apply(Impl.java)
    at com.google.gwt.core.client.impl.Impl.entry0(Impl.java:213)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.jav
a:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.google.gwt.dev.shell.MethodAdaptor.invoke(MethodAdaptor.java:103)
    at com.google.gwt.dev.shell.MethodDispatch.invoke(MethodDispatch.java:71)
    at
com.google.gwt.dev.shell.OophmSessionHandler.invoke(OophmSessionHandler.java:172
)
    at
com.google.gwt.dev.shell.BrowserChannelServer.reactToMessages(BrowserChannelServ
er.java:292)
    at
com.google.gwt.dev.shell.BrowserChannelServer.processConnection(BrowserChannelSe
rver.java:546)
    at
com.google.gwt.dev.shell.BrowserChannelServer.run(BrowserChannelServer.java:363)
    at java.lang.Thread.run(Thread.java:680)

Original comment by travalle...@gmail.com on 23 Sep 2012 at 12:34

GoogleCodeExporter commented 9 years ago
Hi all,
    I did below changes to ParameterizedPlaceRequest in order to make it work.  When can this checkin into trunk?

  @Override
  public String getParameter(String key, String defaultValue) {
//    String val = params.get(key);
//    if (val != null) {
//      return val;
//    }
//    val = pathParams.get(key);
//    if (val != null) {
//      return val;
//    }
//    return defaultValue;

        String val = defaultValue;

        if (params != null)
            val = params.get(key);

        if (val != null) {
            return val;
        }

        if (pathParams != null)
            val = pathParams.get(key);

        if (val != null) {

            return val;
        }

        return defaultValue;
  }

  @Override
  public Set<String> getParameterNames() {

//    return params.keySet();

      if(params !=null)
          return params.keySet();

      return null;

  }

Original comment by travalle...@gmail.com on 4 Oct 2012 at 8:42

GoogleCodeExporter commented 9 years ago
Just a little bit more work before merging, could you ask a pull request on git 
hub with the latest changes?

We're moving everything to GIT for the next release. Let's do this for this 
issue.

https://github.com/ArcBees/GWTP

Thanks

Original comment by christia...@arcbees.com on 15 Oct 2012 at 4:33

GoogleCodeExporter commented 9 years ago
any update on this?

Original comment by travalle...@gmail.com on 15 Dec 2013 at 9:37

GoogleCodeExporter commented 9 years ago
this issue is not updated in github issue tracking

Original comment by travalle...@gmail.com on 15 Dec 2013 at 9:46

GoogleCodeExporter commented 9 years ago
https://github.com/ArcBees/GWTP/wiki/Route-Place-Tokens

Original comment by j...@barop.de on 28 Dec 2013 at 10:56