Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    How to use objects in velocity template ?

    Hi,

    I put an object into the session properties with:

    Code:
    session.setAttribute("myObject", new MyClass());
    MyClass is just a testClass with a method returning a Long and expecting an argument (DSRequest):
    Code:
    public class MyClass {
       public Long getLong(DSRequest dsRequest) {
          return 4l;
       }
    }
    In my template I put the following:
    Code:
    <operationBinding operationType="fetch">
            <whereClause><![CDATA[
                    employeeId = ((com.smartgwt.sample.server.MyClass)$session.get("myObject")).getLong($dsRequest)
            ]]></whereClause>
            </operationBinding>
    But I get:

    Code:
    SELECT COUNT(*) FROM employeeTable WHERE 
                    employeeId = ((com.smartgwt.sample.server.MyClass)'com.smartgwt.sample.server.MyClass@41c7d866').getLong('com.isomorphic.datasource.DSRequest@18ad63cb')
    So how to do this ? Call the method getLong() and give as an argument the DSRequest.

    Using smartgwt 6.1p power

    #2
    Velocity doesn't use the Java compiler, so the typecast is not needed and the parens you applied end up making Velocity not see the second method invocation.

    Comment

    Working...
    X