You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Matt Raible <ma...@raibledesigns.com> on 2003/10/24 18:10:33 UTC

Template doesn't recognize boolean values

I'm putting a groupQuoteForm (a Struts ActionForm) into my context and 
then using a velocity template to render its values.  My form has a 
boolean property with getters and setters.  However, my template 
doesn't pick it up - even though the property is set to true.  If I 
print out my form, it's true, but in the template it's false.  Any 
ideas?  I tried both $object.property and $object.getProperty(), but 
neither works.

Thanks,

Matt


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Template doesn't recognize boolean values

Posted by Nathan Bubna <na...@esha.com>.
Matt Raible said:
> I'm putting a groupQuoteForm (a Struts ActionForm) into my context and
> then using a velocity template to render its values.  My form has a
> boolean property with getters and setters.  However, my template
> doesn't pick it up - even though the property is set to true.  If I
> print out my form, it's true, but in the template it's false.  Any
> ideas?  I tried both $object.property and $object.getProperty(), but
> neither works.

i'm confused.  when you do $form.property is the output "false" or
"$form.property"?  at one point it sounds like you're saying Velocity is
flipping the value of the boolean, and at the other it sounds like you can't
access the property method.  the former case (which would output "false") is
hard to imagine.

remember, Velocity only works with public methods in public classes.  make
sure that both your ActionForm subclass and your getters/setters are declared
public.

Nathan Bubna
nathan@esha.com


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org


Re: Template doesn't recognize boolean values

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On Friday, October 24, 2003, at 12:10 PM, Matt Raible wrote:

> I'm putting a groupQuoteForm (a Struts ActionForm) into my context and 
> then using a velocity template to render its values.  My form has a 
> boolean property with getters and setters.  However, my template 
> doesn't pick it up - even though the property is set to true.  If I 
> print out my form, it's true, but in the template it's false.  Any 
> ideas?  I tried both $object.property and $object.getProperty(), but 
> neither works.
>

What does the accessor look like?  i.e. what are the methods that are 
implemented by the class to get that property?  You can't just access 
fields in a class via Velocity :

public class Foo
{
      public String fooval;
}

you can't just do a

    $foo.fooval

you need

public class Foo
{
      public String fooval;

	public String getFooval()
     {
        return fooval;
     }
}

and then $foo.fooval will work (as will $foo.getFooval())

-- 
Geir Magnusson Jr                                   203-247-1713(m)
geirm@optonline.net


---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org