As mentioned in PocketQuery 4.x Upgrade Notes, PocketQuery now uses dynamic forms instead of static templates. Therefore, some functions you have been using in the previous version might be deprecated now. In this article, we provide examples that you can use to replace getValueFromMapEntry andgetParameterFromRequestOrMacro functions.

Example 1: getValueFromMapEntry

You can iterate a map/object using the following function:

#foreach($entry in $parameters.entrySet())
  <p>$entry.key - $entry.value</p>

Where $entry.key returns the key and $entry.value returns the value. Considering $parameters to be the following object:

  "catName": "Ingmar",
  "dogName": "Ingwer"

The result would be:

  <p>catName - Ingmar</p>
  <p>dogName - Ingwer</p>

If you want to obtain only a specific value, you can do it more efficiently. Instead of iterating the whole object, you can simply call the following function:


Which returns Ingmar 🐱.

Example 2: getParameterFromRequestOrMacro

This function can be replaced by $pocketQueryParameters. You can find more details in Velocity API Available In Templates. In PocketQuery 3.x, you might have been using:

#set ($reqParam = $PocketQuery.getParameterFromRequestOrMacro("param", $req, $queryParameters))

This can be easily substituted by:

#set ($reqParam = $pocketQueryParameters.get("param"))

Which does the same trick.