## Licensed to the Apache Software Foundation (ASF) under one ## or more contributor license agreements. See the NOTICE file ## distributed with this work for additional information ## regarding copyright ownership. The ASF licenses this file ## to you under the Apache License, Version 2.0 (the ## "License"); you may not use this file except in compliance ## with the License. You may obtain a copy of the License at ## ## http://www.apache.org/licenses/LICENSE-2.0 ## ## Unless required by applicable law or agreed to in writing, ## software distributed under the License is distributed on an ## "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ## KIND, either express or implied. See the License for the ## specific language governing permissions and limitations ## under the License. Struts App2: Struts View Tools Demo

Struts App2: Struts View Tools Demo

A demonstration of the Velocity view tools provided for Struts support. Where available, the Velocity shorthand notation to method calls is shown as well.

MessageTool

\$text.title
\$text.title
$text.title
\$text.test.insert('bear','dog','cat') $text.test.insert('bear','dog','cat')
\$text.tutle.exists $text.tutle.exists

ErrorsTool

\$errors.exist() $errors.exist()
\$errors.exist('language') $errors.exist('language')
\$errors.getSize()
\$errors.size
$errors.getSize()
\$errors.getSize('language') $errors.getSize('language')
\$errors.getAll()
\$errors.all
[This is a String representation of the ArrayList that is returned]
$errors.getAll()
\$errors.get('language')
\$errors.language
[This is a String representation of the ArrayList that is returned]
$errors.language
\$errors.getMsgs()
\$errors.msgs
$errors.msgs
\$errors.getMsgs('language') $errors.getMsgs('language')
A Velocity macro to render all error messages:
#macro (errorMarkup)
  #if ($errors.exist() )
    <ul>
    #foreach ($e in $errors.all )
      $e
    #end
    </ul>
  #end
#end
#errorMarkup()
A Velocity macro to render error messages specific
to a property:
#macro (errorMarkup $property)
  #if ($errors.exist($property))
    <ul>
    #foreach ($er in $errors.get($property))
      $er
    #end
    </ul>
  #end
#end
#errorMarkupForProperty('language')

FormTool

\$form.getBean()
\$form.bean
$form.getBean()
\$form.getCancelName()
\$form.cancelName
$form.getCancelName()
\$form.getTokenName()
\$form.tokenName
$form.getTokenName()
\$form.getToken()
\$form.token
$form.getToken()

StrutsLinkTool

\$link.uri('template/login.vm') $link.uri('template/login.vm')
\$link.action.demo $link.action.demo  
\$link.forward.src $link.forward.src  
\$link.relative('examples/index.html') $link.relative('examples/index.html')
\$link.uri('index.html').param('key1', 'val 1') $link.uri('index.html').param('key1', 'val 1')
\$link.uri('index.html').param('key1', 'val 1').getURI()
\$link.uri('index.html').param('key1', 'val 1').URI
$link.uri('index.html').param('key1', 'val 1').getURI()
\$link.uri('/index.html').param('key1', 'val 1').getQueryData()
\$link.uri('/index.html').param('key1', 'val 1').queryData
$link.uri('/index.html').param('key1', 'val 1').getQueryData()
\$link.getContextURL()
\$link.contextURL
$link.getContextURL()
\$link.getContextPath()
\$link.contextPath
$link.getContextPath()
\$link.getBaseRef()
\$link.baseRef
$link.getBaseRef()
\$link.setURI('index.vm').toString() $link.setURI('index.vm').toString()

ActionMessagesTool

\$messages.exist() $messages.exist()
\$messages.exist('foobar') $messages.exist('foobar')
\$messages.getSize()
\$messages.size
$messages.getSize()
\$messages.getSize('foobar') $messages.getSize('foobar')
\$messages.getAll()
\$messages.all
[This is a String representation of the ArrayList that is returned]
$messages.getAll()
\$messages.get('foobar')
\$messages.foobar
[This is a String representation of the ArrayList that is returned]
$messages.get('foobar')
A Velocity macro to render all actiontext messages:
#macro (messageMarkup)
  #if ($messages.exist() )
    <ul>
    #foreach ($m in $messages.all )
      $m
    #end
    </ul>
  #end
#end
#messageMarkup()
A Velocity macro to render actiontext messages specific
to a property:
#macro (messageMarkup $property)
  #if ($messages.exist($property))
    <ul>
    #foreach ($m in $messages.get($property))
      $m
    #end
    </ul>
  #end
#end
#messageMarkupForProperty('foobar')