Re: Combining default! and ?number

"Klotz, Leigh" <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <E254B0A7E0268949ABFE5EA97B7D0CF404C0358A@USA7061MS01.na.xerox.net>
I apologize for the disturbance.  I was testing against the wrong JAR
file.
I'll be more careful in the future.
Leigh. 

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of
Jonathan Revusky
Sent: Tuesday, April 29, 2008 10:52 AM
To: [email protected]
Subject: Re: [FreeMarker-user] Combining default! and ?number

Klotz, Leigh wrote:
> In FM 2.3.12, I'd like to assign a variable to be a number which is 
> either parsed from a string parameter (perhaps from a query string), 
> or default it to a fixed constant.  I'm not sure if there's a concise 
> syntax for doing this.
> 
> The first code I saw to do this was like this:
>  <#assign page>${pageArg!1}</#assign>			[1]
> 
> But then all users from then on had to do
>     page?number + 1
> to refer to it.  Unfortunately, that fails because page is now a 
> number, and next time, page?number will fail.
> 
> So I changed it to this:
> 
> <#assign page = pageArg!1 />
> 
> This works when pageArg isn't specified, as does this
>    page + 1
> work properly on every iteration.
> 
> However, when pageArg it specified, it turns page into a string, so it

> fails again.

Hold on a sec. You're running into a bug in 2.4. I just checked and

${12?number}

works in 2.3 but fails in 2.4 because somehow, it thinks the lhs has to
be a string, which is kind of true, but actually, if the lhs is already
a number, it should just return the number.

So the above should work, it's a bug.

JR


------------------------------------------------------------------------
-
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't
miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/j
avaone
_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.