You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Mark Wassermann <mw...@mw-net.com> on 2007/02/18 13:10:03 UTC
selectinbox problem
hi list
I have a problem with a macro that should build a ht ml select element.
The macro is as follows:
-- CODE --
#macro( selectionbox $class $name $selection $list )
<select class="$class" name="$name" size="1">
#foreach( $entry in $list )
#if( $entry.getId() == $selection )
<option value="$entry.getId()" selected>$entry.getValue()</option>
#else
<option value="$entry.getId()">$entry.getValue()</option>
#end
#end
</select>
#end
-- CODE --
$list is a list of torque objects
$selection is an int value representing the current selected item of the
list
The problem is, that the line
#if( $entry.getId() == $value )
never returns true and there is no selected item in the selectionbox
(the box always shows the first element)
I do not understand the reason for this behavior.
What did I miss?
thx for help
Mark
--
Mark Wassermann @: mwassermann@mw-net.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: selectinbox problem
Posted by Mark Wassermann <mw...@mw-net.com>.
Robert Koberg schrieb:
> You can just use $entry.id, BTW. And you are sure that both $entry.id
> and $selection are ints (not long or not Integer if using jdk < 1.5),
> right?
what do you mean with "BTW"?
My target system is java 5 (it is a server on witch I have no root
permission).
Is there some other way to solve this
thx
Mark
--
Mark Wassermann @: mwassermann@mw-net.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: selectinbox problem
Posted by Robert Koberg <ro...@koberg.com>.
On Sun, 18 Feb 2007 07:10:03 -0500, Mark Wassermann
<mw...@mw-net.com> wrote:
> #if( $entry.getId() == $selection )
<snip/>
>
> The problem is, that the line
> #if( $entry.getId() == $value )
You mean $selection, right?
You can just use $entry.id, BTW. And you are sure that both $entry.id and
$selection are ints (not long or not Integer if using jdk < 1.5), right?
It should work.
best,
-Rob
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: selectinbox problem
Posted by Mark Wassermann <mw...@mw-net.com>.
Hi
Thanks for your hints!
I have upgraded to velocity 1.5 B2
now it seams to work fine.
Mark
Claude Brisson schrieb:
> Try with :
>
> #if("$entry.id" == "$selection")
>
> (explicit string comparison)
>
> Note that $entry.getId() and $entry.getValue() can be written $entry.id
> and $entry.value
>
>
> Claude
>
> -- CODE --
>> #macro( selectionbox $class $name $selection $list )
>> <select class="$class" name="$name" size="1">
>> #foreach( $entry in $list )
>> #if( $entry.getId() == $selection )
>> <option value="$entry.getId()" selected>$entry.getValue()</option>
>> #else
>> <option value="$entry.getId()">$entry.getValue()</option>
>> #end
>> #end
>> </select>
>> #end
>> -- CODE --
>>
>
>
> Le dimanche 18 février 2007 à 13:10 +0100, Mark Wassermann a écrit :
>> hi list
>>
>> I have a problem with a macro that should build a ht ml select element.
>>
>> The macro is as follows:
>>
>> -- CODE --
>> #macro( selectionbox $class $name $selection $list )
>> <select class="$class" name="$name" size="1">
>> #foreach( $entry in $list )
>> #if( $entry.getId() == $selection )
>> <option value="$entry.getId()" selected>$entry.getValue()</option>
>> #else
>> <option value="$entry.getId()">$entry.getValue()</option>
>> #end
>> #end
>> </select>
>> #end
>> -- CODE --
>>
>> $list is a list of torque objects
>> $selection is an int value representing the current selected item of the
>> list
>>
>> The problem is, that the line
>> #if( $entry.getId() == $value )
>> never returns true and there is no selected item in the selectionbox
>> (the box always shows the first element)
>>
>> I do not understand the reason for this behavior.
>> What did I miss?
>>
>> thx for help
>> Mark
--
Mark Wassermann @: mwassermann@mw-net.com
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org
Re: selectinbox problem
Posted by Claude Brisson <cl...@renegat.net>.
Try with :
#if("$entry.id" == "$selection")
(explicit string comparison)
Note that $entry.getId() and $entry.getValue() can be written $entry.id
and $entry.value
Claude
-- CODE --
> #macro( selectionbox $class $name $selection $list )
> <select class="$class" name="$name" size="1">
> #foreach( $entry in $list )
> #if( $entry.getId() == $selection )
> <option value="$entry.getId()" selected>$entry.getValue()</option>
> #else
> <option value="$entry.getId()">$entry.getValue()</option>
> #end
> #end
> </select>
> #end
> -- CODE --
>
Le dimanche 18 février 2007 à 13:10 +0100, Mark Wassermann a écrit :
> hi list
>
> I have a problem with a macro that should build a ht ml select element.
>
> The macro is as follows:
>
> -- CODE --
> #macro( selectionbox $class $name $selection $list )
> <select class="$class" name="$name" size="1">
> #foreach( $entry in $list )
> #if( $entry.getId() == $selection )
> <option value="$entry.getId()" selected>$entry.getValue()</option>
> #else
> <option value="$entry.getId()">$entry.getValue()</option>
> #end
> #end
> </select>
> #end
> -- CODE --
>
> $list is a list of torque objects
> $selection is an int value representing the current selected item of the
> list
>
> The problem is, that the line
> #if( $entry.getId() == $value )
> never returns true and there is no selected item in the selectionbox
> (the box always shows the first element)
>
> I do not understand the reason for this behavior.
> What did I miss?
>
> thx for help
> Mark
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@velocity.apache.org
For additional commands, e-mail: user-help@velocity.apache.org