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>
#end
CODE

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

{
  "catName": "Ingmar",
  "dogName": "Ingwer"
}
JAVA

The result would be:

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

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:

$parameters.get("catName")
JAVA

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))
CODE

This can be easily substituted by:

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

Which does the same trick.