WICKET-5429 ResourceReference's properties are not preserved when using reference replacement

(cherry picked from commit 2ced99eac4f85c9c59be978b198a9368aeaeff20)