You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bhorvat <ho...@gmail.com> on 2012/07/08 10:55:33 UTC

Problem with range operator

I have a strange problem with range operator, well it is eighter that or I
dont know how to use it.

I have tried the following 

 <t:loop t:source="1..31" t:value="day">
    //html code
 </t:loop>

this works but my problem is that the number 31 needs to be dynamic so I
have a property ${lastDayInMonth}

However if I try 

<t:loop t:source="1..${lastDayInMonth}" t:value="day">
    //html code
 </t:loop>

I get

A JSONArray text must start with '[' at character 1 of 1..31

and if I try 

<t:loop t:source="[1..${lastDayInMonth}]" t:value="day">
    //html code
 </t:loop>

I get

Caused by: java.lang.RuntimeException: Coercion of 1..31 to type
java.lang.Integer (via String --> Long, Long --> Integer) failed: For input
string: "1..31"

So what am I dont wrong, ideas?

cheers and tnx

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Problem-with-range-operator-tp5714339.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: Problem with range operator

Posted by bhorvat <ho...@gmail.com>.
yea this works. Great

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Problem-with-range-operator-tp5714339p5714345.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: Problem with range operator

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Sun, 08 Jul 2012 06:59:17 -0300, Dusko Jovanovski <du...@gmail.com>  
wrote:

> I made an oversight, try this:
>
> <t:loop t:source="1..lastDayInMonth" t:value="day">
>     //html code
> </t:loop>

Good catch, Dusko. This remembers me of remembering everyone to never,  
never, never ever use expansions (${xxx})  when passing parameters to  
Tapestry components.

-- 
Thiago H. de Paula Figueiredo

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


Re: Problem with range operator

Posted by Dusko Jovanovski <du...@gmail.com>.
I made an oversight, try this:

<t:loop t:source="1..lastDayInMonth" t:value="day">
    //html code
</t:loop>

On Sun, Jul 8, 2012 at 11:54 AM, bhorvat <ho...@gmail.com> wrote:

> Hm...Well it says here that it should
> http://tapestry.apache.org/property-expressions.html
>
> "The rangeOp creates a range object that will iterate between the two
> values. The upper and lower bounds may be literal integers, or property
> expressions"
>
> Also the expression is evaluated properly as it returns the number, but the
> conversion is wrong. :S
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Problem-with-range-operator-tp5714339p5714343.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: Problem with range operator

Posted by bhorvat <ho...@gmail.com>.
Hm...Well it says here that it should
http://tapestry.apache.org/property-expressions.html

"The rangeOp creates a range object that will iterate between the two
values. The upper and lower bounds may be literal integers, or property
expressions"

Also the expression is evaluated properly as it returns the number, but the
conversion is wrong. :S

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Problem-with-range-operator-tp5714339p5714343.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: Problem with range operator

Posted by Dusko Jovanovski <du...@gmail.com>.
I don't think you can use it like that, only with fixed values.

On Sun, Jul 8, 2012 at 11:35 AM, bhorvat <ho...@gmail.com> wrote:

> That is the option, but tapestry has this cool option so I would like to
> use
> it
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Problem-with-range-operator-tp5714339p5714341.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: Problem with range operator

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Sun, 08 Jul 2012 06:35:53 -0300, bhorvat <ho...@gmail.com>  
wrote:

> That is the option, but tapestry has this cool option so I would like to  
> use it

The range operator doesn't support dynamic ranges, so the cool option you  
describe doesn't exist. Just use what Dusko suggested.

-- 
Thiago H. de Paula Figueiredo

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


Re: Problem with range operator

Posted by bhorvat <ho...@gmail.com>.
That is the option, but tapestry has this cool option so I would like to use
it

--
View this message in context: http://tapestry.1045711.n5.nabble.com/Problem-with-range-operator-tp5714339p5714341.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: Problem with range operator

Posted by Dusko Jovanovski <du...@gmail.com>.
Why don't you just return an array from 1 to lastDayInMonth?

.tml
t:source="rangeOfDates"

.java
public List<Integer> getRangeOfDates()
{
List<Integer> list = new LinkedList<Integer>();

for(Integer i=1; i <=lastDayInMonth; i++)
   list.add(i);

return list;
}


On Sun, Jul 8, 2012 at 10:55 AM, bhorvat <ho...@gmail.com> wrote:

> I have a strange problem with range operator, well it is eighter that or I
> dont know how to use it.
>
> I have tried the following
>
>  <t:loop t:source="1..31" t:value="day">
>     //html code
>  </t:loop>
>
> this works but my problem is that the number 31 needs to be dynamic so I
> have a property ${lastDayInMonth}
>
> However if I try
>
> <t:loop t:source="1..${lastDayInMonth}" t:value="day">
>     //html code
>  </t:loop>
>
> I get
>
> A JSONArray text must start with '[' at character 1 of 1..31
>
> and if I try
>
> <t:loop t:source="[1..${lastDayInMonth}]" t:value="day">
>     //html code
>  </t:loop>
>
> I get
>
> Caused by: java.lang.RuntimeException: Coercion of 1..31 to type
> java.lang.Integer (via String --> Long, Long --> Integer) failed: For input
> string: "1..31"
>
> So what am I dont wrong, ideas?
>
> cheers and tnx
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Problem-with-range-operator-tp5714339.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
>
>