abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Primmer" <david.prim...@gmail.com>
Subject Re: urlFor in RouteManager does not let you null out vars
Date Thu, 15 May 2008 22:12:10 GMT
I just tested another use case, for the situation where I'm sending in
a map with a nulled out param 'id=null' and in this case, I have send
a request with query params '/feed/1?format=atom' and in this case,
when it builds the link, it actually adds '?id=' onto the end of the
url that is created so '/feed/?id='. So this seems to get complicated
if there are query params already in the request context.


On Thu, May 15, 2008 at 2:10 PM, David Primmer <david.primmer@gmail.com> wrote:
> I was thinking that if you passed in null, the urlFor would not
> replace any of your tokens. But on the other hand, this behavior lets
> you get a url by just sending in one arg: the route name.
> I'm not sure off the top of my head how the Ruby and Python Routes
> libs handle this. It is hard to know what users would expect but at a
> minimum it should be in a code comment. As it is, if I have two tokens
> in my route and I only one one of them to be replaced with the request
> var, i can get this by sending in a map with only one of the params
> set to null for the one i don't want and the other one will magically
> get resolved. Seems a little to implicit to me.
> davep
> On Thu, May 15, 2008 at 2:02 PM, David Calavera
> <david.calavera@gmail.com> wrote:
>> Hi David, what do you think could be the expected behavior?
>> On Thu, May 15, 2008 at 5:09 PM, James M Snell <jasnell@gmail.com> wrote:
>>> Ok, we need to fix that. Want to open a jira issue?
>>> - James
>>> David Primmer wrote:
>>>> I need to correct myself here. After investigating the code more, I
>>>> was able to get the result I wanted by sending in a map with id=null
>>>> as params instead of sending in a null param arg. The code only pulls
>>>> in values from the request if they're not explicitly included in the
>>>> params map in urlFor. I still don't know if this is the desired
>>>> behavior. It's certainly not what I expected.
>>>> davep
>>>> On Wed, May 14, 2008 at 11:21 AM, David Primmer <david.primmer@gmail.com>
>>>> wrote:
>>>>> I'm trying to implement getHref in an adapter, which returns the url
>>>>> for the collection. I'm also using RouteManager and it's urlfor
>>>>>     for (String var : route.getVariables()) {
>>>>>       Object value = context.getTarget().getParameter(var);
>>>>>       if (!map.containsKey(var) && value != null) {
>>>>>         map.put(var, value);
>>>>>       }
>>>>>     }
>>>>> say my route is /feed/:id
>>>>> and my request is /feed/1
>>>>> if i'm doing urlFor("myroute", null), hoping that it produces /feed/
>>>>> as a url, but instead, the code above pulls the id out of the request
>>>>> context and fills in those params, giving me a url of /feed/1. I don't
>>>>> understand why it would do this and it limits the use of urlFor for
>>>>> generating collection urls.
>>>>> davep
>> --
>> David Calavera
>> http://www.thinkincode.net

View raw message