You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Tobias Wehrum <Le...@dragonlab.de> on 2007/11/06 18:02:05 UTC
T5: Loop with variables
Hi all,
I am currently working with the tutorial 1 at the Tapestry 5 homepage (
http://tapestry.apache.org/tapestry5/tutorial1/hilo.html ).
Now, one of the further tasks there is "As we guess, we're identifying
ranges of valid and invalid numbers. Can you only show valid guesses to
the user?"
...so, setting a loop (which counted before simply from 1 to 10) to
count from one variable to another variable.
My guess was that I just have to replace
<t:loop source="1..10" value="guess">
(which works) with
<t:loop source="${rangeStart}..${rangeEnd}" value="guess">
Well, seems to be wrong. I get the following application exception:
org.apache.tapestry.ioc.internal.util.TapestryException
Failure writing parameter value of component Guess:loop: Coercion of
1..10 to type int (via String --> Long, Long --> Integer) failed: For
input string: "1..10"
(marked is the line shown above).
So, he DOES replace the variables right, but that doesn't seem to be the
same as "1..10" anymore.
How can I solve this problem?
Thanks in advance,
Tobias
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: T5: Loop with variables
Posted by Tobias Wehrum <Le...@dragonlab.de>.
Hi Howard,
thanks for the fast answer, IntegerRange solved the problem. Maybe you
could suggest this in your tutorial.
Keep up the great work,
Tobias
Howard Lewis Ship schrieb:
> The x...y syntax is limited to constant values for x and y. I think a
> future release of Tapestry will increase the power of the built-in
> expression language, but for the moment, there you go.
>
> The x..y syntax is ultimately converted into an instance of
> IntegerRange, so one way would be to create a getter method that
> created and returned an instance of IntegerRange directly, then change
> the source parameter of the Loop component to point to this property.
>
> However, IntegerRange is an internal class, so be aware that it is
> free to change at any time.
>
> Or you could return a List<Integer> or int[] of the desired values
> from the method.
>
> On Nov 6, 2007 9:02 AM, Tobias Wehrum <Le...@dragonlab.de> wrote:
>
>> Hi all,
>>
>> I am currently working with the tutorial 1 at the Tapestry 5 homepage (
>> http://tapestry.apache.org/tapestry5/tutorial1/hilo.html ).
>>
>> Now, one of the further tasks there is "As we guess, we're identifying
>> ranges of valid and invalid numbers. Can you only show valid guesses to
>> the user?"
>> ...so, setting a loop (which counted before simply from 1 to 10) to
>> count from one variable to another variable.
>>
>> My guess was that I just have to replace
>> <t:loop source="1..10" value="guess">
>> (which works) with
>> <t:loop source="${rangeStart}..${rangeEnd}" value="guess">
>>
>> Well, seems to be wrong. I get the following application exception:
>>
>> org.apache.tapestry.ioc.internal.util.TapestryException
>> Failure writing parameter value of component Guess:loop: Coercion of
>> 1..10 to type int (via String --> Long, Long --> Integer) failed: For
>> input string: "1..10"
>> (marked is the line shown above).
>>
>> So, he DOES replace the variables right, but that doesn't seem to be the
>> same as "1..10" anymore.
>>
>> How can I solve this problem?
>>
>> Thanks in advance,
>> Tobias
>>
>> ---------------------------------------------------------------------
>> 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: Loop with variables
Posted by Howard Lewis Ship <hl...@gmail.com>.
The x...y syntax is limited to constant values for x and y. I think a
future release of Tapestry will increase the power of the built-in
expression language, but for the moment, there you go.
The x..y syntax is ultimately converted into an instance of
IntegerRange, so one way would be to create a getter method that
created and returned an instance of IntegerRange directly, then change
the source parameter of the Loop component to point to this property.
However, IntegerRange is an internal class, so be aware that it is
free to change at any time.
Or you could return a List<Integer> or int[] of the desired values
from the method.
On Nov 6, 2007 9:02 AM, Tobias Wehrum <Le...@dragonlab.de> wrote:
> Hi all,
>
> I am currently working with the tutorial 1 at the Tapestry 5 homepage (
> http://tapestry.apache.org/tapestry5/tutorial1/hilo.html ).
>
> Now, one of the further tasks there is "As we guess, we're identifying
> ranges of valid and invalid numbers. Can you only show valid guesses to
> the user?"
> ...so, setting a loop (which counted before simply from 1 to 10) to
> count from one variable to another variable.
>
> My guess was that I just have to replace
> <t:loop source="1..10" value="guess">
> (which works) with
> <t:loop source="${rangeStart}..${rangeEnd}" value="guess">
>
> Well, seems to be wrong. I get the following application exception:
>
> org.apache.tapestry.ioc.internal.util.TapestryException
> Failure writing parameter value of component Guess:loop: Coercion of
> 1..10 to type int (via String --> Long, Long --> Integer) failed: For
> input string: "1..10"
> (marked is the line shown above).
>
> So, he DOES replace the variables right, but that doesn't seem to be the
> same as "1..10" anymore.
>
> How can I solve this problem?
>
> Thanks in advance,
> Tobias
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
--
Howard M. Lewis Ship
Partner and Senior Architect at Feature50
Creator Apache Tapestry and Apache HiveMind
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org