Dims
Dims

Reputation: 50999

Can I access by property names in Velocity?

I got an example

#set($organizationId = $layout.getGroup().getOrganizationId())

can I rewrite it as

#set($organizationId = $layout.group.organizationId)

?

Will it be exactly the same?

Upvotes: 2

Views: 495

Answers (1)

Moritz Petersen
Moritz Petersen

Reputation: 13047

Yes. See here: Velocity User Guide - Property Lookup Rules which states:

As an example, $customer.address, the sequence is

  1. getaddress()
  2. getAddress()
  3. get("address")
  4. isAddress()

To be more precise, Velocity User Guide - Case Substitution:

$data.getRequest().getServerName()
## is the same as
$data.Request.ServerName

Upvotes: 3

Related Questions