We have several domain objects with fields with a zero value. We read that hibernation requires an "unprocessed" object to display it correctly, so our recipients return options. Our domain objects are as follows:
public class User { private String firstName; private User boss; public Optional<String> getFirstName(){ .... } public Optional<User> getBoss() { ... } }
But now we have problems resolving / linking these fields in .jspx files. (Both displays, as well as form input fields). For primitive types and strings, we could get around this by specifying a custom OptionToStringConverter.
However, the problem is null references for other domain objects.
We examined several options, but are not really satisfied with any of them:
- Defining custom converters for all objects and domain types (will lead to many converters and does not work for input fields)
- Definition of optional and optional getters for each domain object (1. duplicate code, 2. we want fields with zero values ββto be clean, 3. do not feel clean to access optional and optional fields differently)
- Definition of a show command that returns "raw" or null (duplicate code)
- Defining a custom tag that handles additional parameters (when a domain object becomes optional, we will need to change the tagx)
We wondered if there is a good and clean way to enable options in jspx.
source share