You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Angelo Chen <an...@yahoo.com.hk> on 2009/11/09 14:24:21 UTC

t5: Link s addParameter and null

Hi,

I have a query string that I need to append to a  Link object, the query
string is:

?gender=M&country=

I got two questions:

1) is there a simple way to append this string to a Link object instead of
using addParameter?

2) if I do a lnk.addParameter("country", null) and I got following:

 RequestExceptionHandler Unexpected runtime exception: Parameter value was
null or contained only whitespace.

and I need to make the country part of query string even it is null, any
idea? thanks,

A.C.
-- 
View this message in context: http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266356.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: Link s addParameter and null

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
Em Mon, 09 Nov 2009 11:24:21 -0200, Angelo Chen  
<an...@yahoo.com.hk> escreveu:

> Hi,

Hi!

> 2) if I do a lnk.addParameter("country", null) and I got following:
>  RequestExceptionHandler Unexpected runtime exception: Parameter value  
> was null or contained only whitespace.

Please post a JIRA about it. I think that you use of a query parameter  
without a value is valid, but the framework thinks otherwise now.

-- 
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,  
and instructor
Owner, software architect and developer, Ars Machina Tecnologia da  
Informação Ltda.
http://www.arsmachina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: Link s addParameter and null

Posted by Angelo Chen <an...@yahoo.com.hk>.
I need that to be in the url so it can be captured by Google Analytics.

Alexey Hanin wrote:
> 
> Don't have an opportunity to check this but as I know Tapestry treats
> empty parameters as nulls. Just curious, why do you want empty
> parameter in query string? Conceptually, parameters not being set
> makes it null.
> 
> On Mon, Nov 9, 2009 at 3:50 PM, Angelo Chen <an...@yahoo.com.hk>
> wrote:
>>
>> Hi,
>> Thanks for the reply, but it does not work, still same error, i check the
>> LinkImpl:
>>
>>  public void addParameter(String parameterName, String value)
>>    {
>>        Defense.notBlank(parameterName, "parameterName");
>>        Defense.notBlank(value, "value");
>>
>>        if (parameters == null)
>>            parameters = CollectionFactory.newMap();
>>
>>        parameters.put(parameterName, value);
>>    }
>>
>> it is making sure the value is not blank, but I believe query string
>> having
>> blank value is often.
>>
>>
>> Alexey Hanin wrote:
>>>
>>> Just make it empty string when it's null:
>>>
>>> lnk.addParameter("country", country == null ? "" : country);
>>>
>>> On Mon, Nov 9, 2009 at 3:24 PM, Angelo Chen <an...@yahoo.com.hk>
>>> wrote:
>>>>
>>>> Hi,
>>>>
>>>> I have a query string that I need to append to a  Link object, the
>>>> query
>>>> string is:
>>>>
>>>> ?gender=M&country=
>>>>
>>>> I got two questions:
>>>>
>>>> 1) is there a simple way to append this string to a Link object instead
>>>> of
>>>> using addParameter?
>>>>
>>>> 2) if I do a lnk.addParameter("country", null) and I got following:
>>>>
>>>>  RequestExceptionHandler Unexpected runtime exception: Parameter value
>>>> was
>>>> null or contained only whitespace.
>>>>
>>>> and I need to make the country part of query string even it is null,
>>>> any
>>>> idea? thanks,
>>>>
>>>> A.C.
>>>> --
>>>> View this message in context:
>>>> http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266356.html
>>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>>
>>
>> --
>> View this message in context:
>> http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266715.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26267129.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: Link s addParameter and null

Posted by Alexey Hanin <ga...@gmail.com>.
Don't have an opportunity to check this but as I know Tapestry treats
empty parameters as nulls. Just curious, why do you want empty
parameter in query string? Conceptually, parameters not being set
makes it null.

On Mon, Nov 9, 2009 at 3:50 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
> Thanks for the reply, but it does not work, still same error, i check the
> LinkImpl:
>
>  public void addParameter(String parameterName, String value)
>    {
>        Defense.notBlank(parameterName, "parameterName");
>        Defense.notBlank(value, "value");
>
>        if (parameters == null)
>            parameters = CollectionFactory.newMap();
>
>        parameters.put(parameterName, value);
>    }
>
> it is making sure the value is not blank, but I believe query string having
> blank value is often.
>
>
> Alexey Hanin wrote:
>>
>> Just make it empty string when it's null:
>>
>> lnk.addParameter("country", country == null ? "" : country);
>>
>> On Mon, Nov 9, 2009 at 3:24 PM, Angelo Chen <an...@yahoo.com.hk>
>> wrote:
>>>
>>> Hi,
>>>
>>> I have a query string that I need to append to a  Link object, the query
>>> string is:
>>>
>>> ?gender=M&country=
>>>
>>> I got two questions:
>>>
>>> 1) is there a simple way to append this string to a Link object instead
>>> of
>>> using addParameter?
>>>
>>> 2) if I do a lnk.addParameter("country", null) and I got following:
>>>
>>>  RequestExceptionHandler Unexpected runtime exception: Parameter value
>>> was
>>> null or contained only whitespace.
>>>
>>> and I need to make the country part of query string even it is null, any
>>> idea? thanks,
>>>
>>> A.C.
>>> --
>>> View this message in context:
>>> http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266356.html
>>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266715.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: Link s addParameter and null

Posted by Angelo Chen <an...@yahoo.com.hk>.
Hi,
Thanks for the reply, but it does not work, still same error, i check the
LinkImpl:

  public void addParameter(String parameterName, String value)
    {
        Defense.notBlank(parameterName, "parameterName");
        Defense.notBlank(value, "value");

        if (parameters == null)
            parameters = CollectionFactory.newMap();

        parameters.put(parameterName, value);
    }

it is making sure the value is not blank, but I believe query string having
blank value is often.


Alexey Hanin wrote:
> 
> Just make it empty string when it's null:
> 
> lnk.addParameter("country", country == null ? "" : country);
> 
> On Mon, Nov 9, 2009 at 3:24 PM, Angelo Chen <an...@yahoo.com.hk>
> wrote:
>>
>> Hi,
>>
>> I have a query string that I need to append to a  Link object, the query
>> string is:
>>
>> ?gender=M&country=
>>
>> I got two questions:
>>
>> 1) is there a simple way to append this string to a Link object instead
>> of
>> using addParameter?
>>
>> 2) if I do a lnk.addParameter("country", null) and I got following:
>>
>>  RequestExceptionHandler Unexpected runtime exception: Parameter value
>> was
>> null or contained only whitespace.
>>
>> and I need to make the country part of query string even it is null, any
>> idea? thanks,
>>
>> A.C.
>> --
>> View this message in context:
>> http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266356.html
>> Sent from the Tapestry - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
> 
> 
> 

-- 
View this message in context: http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266715.html
Sent from the Tapestry - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: t5: Link s addParameter and null

Posted by Alexey Hanin <ga...@gmail.com>.
Just make it empty string when it's null:

lnk.addParameter("country", country == null ? "" : country);

On Mon, Nov 9, 2009 at 3:24 PM, Angelo Chen <an...@yahoo.com.hk> wrote:
>
> Hi,
>
> I have a query string that I need to append to a  Link object, the query
> string is:
>
> ?gender=M&country=
>
> I got two questions:
>
> 1) is there a simple way to append this string to a Link object instead of
> using addParameter?
>
> 2) if I do a lnk.addParameter("country", null) and I got following:
>
>  RequestExceptionHandler Unexpected runtime exception: Parameter value was
> null or contained only whitespace.
>
> and I need to make the country part of query string even it is null, any
> idea? thanks,
>
> A.C.
> --
> View this message in context: http://old.nabble.com/t5%3A-Link-s-addParameter-and-null-tp26266356p26266356.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org