I have a criterion in a search page that is a boolean
.
Since it is not mandatory, I can't use a checkbox, because I may want to skip it;
JSP
<s:select list = '#{ "":"Make your choice...", true:"FOO", false:"BAR" }'
name = "myBooleanCriterion" />
Action
private Boolean myBooleanCriterion;
/* Getter and Setter */
We know that boolean
defaults to false
, while Boolean
defaults to null
, then the first time the page is rendered, it is ok ("Make your choice" is displayed).
After the POST, however, Struts instantiates the Boolean
property (defaulting it to false
) even when it finds ""
as value, so when I come back to the JSP, the value is preselected to false
("BAR").
How can I instruct Struts to not create an instance of that variable if the value is ""
, leaving it to its original, null
state ? Do I need to create a Converter, or to specify something in the .properties
file ? (I've basically the same code as in example .2 from this answer)
I'm using (a slightly custom) paramsPrepareParamsStack
Interceptor Stack.
I feel like if I'm missing something stupid.