Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to write velocity templete in liferay

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 382
    Comment on it

    Hello guys

    I am writing a blog about Velocity, Which is an open source templating technology. Velocity is java technology based template engine.

    Here, We will take reference of objects/variable which is defined in Java code with the Velocity template language. A Velocity template is also used for user interface in web applications. Velocity templates helps to achieve the presentation layer and the business logic implementation in the liferay portal.

    Now, We will discuss about various Velocity template language (VTL) syntax below :


    Statements
    velocity template statements starts with # as below example

    #set ($temp = Bhagwan Singh)
    

    Conditional statements

    Below example help to understand Conditional statements in velocity.

    #set ($temp = 99)
    #if( $temp > 100 )
        <b>The variable is greater than </b>
    #elseif( $temp < 100 )
        <b>The variable is less than 100</b>
    #else
        <b>Not matching any conditions</b>
    #end
    

    Loop

    In below code collection is an arbitrary collection. In each iteration $obj holds the item.


    #set($collection = [100, "hello", 10, "Bhagwan"])
    #foreach( $obj in $collection )
        <br/>
        $obj
    #end
    

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: