javawicketwicket-7

Is passing objects to constructor better left as object or as serialized object in pageparameters?


I need to pass an object A to a constructor of class B. Usually its best practice to use Wickets PageParameters class to pass arguments, but PageParameters saves its parameter values as Strings, so an error accurs if the object is passed as it is. A solution I thought of is serializing the object A and saving it as a string parameter. So my question is which of the two sulutions is better practice concerning performance and security, passing directly an object A to class B or serializing it and passing the PageParameters.


Solution

  • Passing it as serialized parameter (in PageParameters) is a requirement only when you want your page to be fully instantiate-able by requesting a predefined url.

    If this page will be reachable only after navigating to another/previous page then passing a plain Object is better. This way it is definitely more secure because no one can see it from outside. And it is more performant too because there is no need to serialize it and later load.