velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vanith...@lntinfotech.com
Subject Re: boolean value
Date Sun, 07 Apr 2002 16:34:38 GMT

Hi,

    Its working..... Thanks alot.

One more problem i faced...

   In a  data class , a method returns a character array.

public char[] getUsedSubsystemTypes()
  {
    return m_chSubsystemType;
  }

In the vm , i tried to print each and every character

#foreach ( $Subsystem in $Sub.getUsedSubsystemTypes())

Character = $Subsystem

#end

It doesnt seem to work.., so i used wrapper class  in getUsedSubsystemTypes
() method so it returns Character[] instead of char[]
 and it works fine.

Is there any way to print the characters without using Wrapper class.

Thanks.

regards
Vanitha



                                                                                         
                         
                    "Geir                                                                
                         
                    Magnusson Jr."       To:     velocity-user@jakarta.apache.org        
                         
                    <geirm@optonli       cc:                                          
                            
                    ne.net>              Subject:     Re: boolean value               
                            
                                                                                         
                         
                    07/04/2002                                                           
                         
                    09:13 PM                                                             
                         
                    Please respond                                                       
                         
                    to "Velocity                                                         
                         
                    Users List"                                                          
                         
                                                                                         
                         
                                                                                         
                         




On 4/7/02 11:46 AM, "Vanitha.S@lntinfotech.com" <Vanitha.S@lntinfotech.com>
wrote:

>
> hi,
>
>
> The data class looks like
>
> public class data
> {
> String name;
> String address;
> boolean flag = true;
> public void setName(String name)
> {
> this.name=name;
> }
> public void setAddress(String address)
> {
> this.address=address;
> }
> public void getAddress()
> {
> return address;
> }
> public void getName()
> {
> return name;
> }
> }

You mean

  public String getAddress()

And

  public String getName()


>
> so in my servlet if i put
>
>                Context.put("Data",data);
>
> and in my Mytemp.vm if i try to access the flag of Data class, it prints
>
> $Data.flag
>
> how to handle this problem..


Velocity won't introspect for public fields.

The solution is to add a simple getter method :

  public boolean getFlag()
  {
    return flag;
  }


And

  $Data.flag

Will work...
--
Geir Magnusson Jr.                                      geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



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






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


Mime
View raw message