[Tools] Possible to check StrutsLinkTool for an existing "forward"

Christopher Schultz <[email protected]> Mon, 30 Jan 2017 19:38:14 -0500
Newsgroups gmane.comp.jakarta.velocity.user
Message-ID <[email protected]>
All,

I've been using StrutsLinkTool with Struts 1.x for a very long time, and
I'm surprised this is the first time this has come up.

I'd like to check for the existence of a forward definition and, if it
exists, use it. Otherwise, I'd like to fall-back to a default.
Basically, I'm taking a Velocity template that is used in a bunch of
places to do one thing, and make it so that I can post a form to a
different (new) action in certain cases.

Normally, I'd do something like this:

#if($link.forward('maybe-exists'))
  <form action="$link.forward('maybe-exists')">
#else
  <form action="$link.forward('same-old-action')">
#end

Unfortunately, the $link.forward('maybe-exists'} will throw an error in
the cases that "maybe-exists" doesn't actually exist. Hence, my desire
to check for the existence of the forward declaration.

Is anything like that possible with the current 2.0 tools build? Can
anyone suggest an alternative without tossing something into the
Velocity context to act as a flag?

Thanks,
-chris
signature.asc (application/pgp-signature, 906 B)
-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQIcBAEBCAAGBQJYj9x4AAoJEBzwKT+lPKRYja8P/1mDGay8emc1CutWg5FeS3RI
7T9hmBfvKyacd2XpS9AuxjwgPEo6mcrOf6Io8F0YZeNO1P8E0K/T89rbYuKvdu2q
RPRmCVg4BG0Mhb019yqxatLbB6/9XJNq7WKN5B57jGM9Bl8s/T+zy40G3vRwU5Fv
dZ96LQPrkmL6drJA+Ix1/xPOUATuLs6ae/LX8LRngnv38MVWQxmQHwaYB28pMDhk
WIBuZAf8VcQgvEPIR9AB/6C5wpjIDMFVv1lLQRMQN4vY1mgvJYZBQqn37SShb9h9
66zwesPyeEYrDpGFrfv1WEHfMyYuJJ03dTFfjyLF5uXCjSv3a6ahsuKCntjPbXZY
IPMq3GjkAzr3aQ9IrriQh23WBIcgpD87LcXit0Df7a7SbP/Jk2Vmwub1POqP8sBJ
Sx6jkmA9vMYTl2n8YL1LFmGBNjLDHasy2SSq6VWhVUBnkCHxi6upxWNqO0HxlbA1
LeZFprfaesljcJfLXl4GC430eByVL2QdSwH6fCvUxPC/LotNevOaYqsXWBEDNHiT
uvFmE0KkhRlj9fh4ivKiR2wWHj8qG2I76dSuwZ4icBryG4QEs11nETimPSSly/4N
wC7BKycQhFt4bU+AusuWTNhtainT38K1OAmP5GMpIj3P5JqtEL7B+bgEZie++2IE
QistYejGbBeXjkH6lURZ
=8iic
-----END PGP SIGNATURE-----