Prasanna Raman wrote:
1) Show a yes/no check box on the front end
2) Show an error if the user doesn't make a selection
Prasanna Raman wrote:Thank you, Bear. I don't think I'm allowed to do that because there are a lot of other radio buttons and they are not designed that way. Is there an alternative?
Prasanna Raman wrote:They don't have any default values selected.
Also, the form is allowed to "true/false" values only to the server.
Bear Bibeault wrote:But, to go back to an earlier question: yes, you must validate on the server. You can never trust anything that happens on the client.
Prasanna Raman wrote:Thank you. I am curious to know what kind of server validation needs to be done for boolean fields? In fact, the reason for my original question was to know this. How would I validate it? Supposing it's a required field, is there a risk that someone could manipulate the HTML or javascript to pass in an empty value?
As for the other validations, I don't think they've done it right. They've made the other fields Boolean, and are checking for null values. It doesn't feel right to me.
Prasanna Raman wrote:Thank you, Dave. So you're saying using the wrapper class and checking for null is the right approach?
Prasanna Raman wrote:
When you said it needs to be validated on the server side, is this what you always had in mind?
Prasanna Raman wrote:
I don't think I quite understand why I need to check for null if I use a primitive?
Is there a possibility that someone could manipulate the html/javascript to pass null? I am trying to understand if this a possibility.
Also, if the above is possible, when the field is accessed, is the default not set to false in any case if the user doesn't select an option?
Prasanna Raman wrote:If the user selects yes, the form will send true. If no is selected, a value of false is sent to the server.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Prasanna Raman wrote:Winston, what should be used ideally then?
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:I'm no expert on this, but the mere idea of using a radio button to effect a boolean (or Boolean) value strikes me as an odd way to do things...
Prasanna Raman wrote:They are using Spring Web flow here, and it passes the user information to the model. So, if nothing is passed from the front end for just this field and if it was declared as primitive boolean in the back end, what would happen in this case?
Bear Bibeault wrote:But, and I'll just say this one more time then shut up, setting up the user to enter an invalid form by not supplying a default (setting one of the radio buttons as checked) is bad UX and whoever is doing your design needs to reconsider it.
Paul Clapham wrote:You may have seen those online questionnaires which start out by asking if you're male or female. They are all implemented by a pair of radio buttons and not by a checkbox which says "Check here if you are female".
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Paul Clapham wrote:
Bear Bibeault wrote:But, and I'll just say this one more time then shut up, setting up the user to enter an invalid form by not supplying a default (setting one of the radio buttons as checked) is bad UX and whoever is doing your design needs to reconsider it.
From one point of view that's true. But in the example I just mentioned, the questionnaire with "Male/Female" radio buttons, there isn't a reasonable default. It would absolutely be wrong for the designers to choose (say) Female for the default. In this case you want the user to positively choose one of the options and not just accept a default.
Prasanna Raman wrote:Paul, I was actually going to ask that question. Because in my case, the question is if the user is a citizen and they need to select yes or no. I don't know if choosing one or the other by default for them would work here.
Bear Bibeault wrote:I do not know; you'd need to consult the documentation or try it yourself for what happens when the parameter is not sent as part of the request. But in the HTTP request it will be sent as either text, or not sent at all. What the framework does with it is up to the framework
Prasanna Raman wrote:
Bear Bibeault wrote:I do not know; you'd need to consult the documentation or try it yourself for what happens when the parameter is not sent as part of the request. But in the HTTP request it will be sent as either text, or not sent at all. What the framework does with it is up to the framework
Thank you, Bear. OK, coming back to an old question, supposing Spring Web flow doesn't do anything and so the boolean variable never gets set. Doesn't it show a value of false by default when you try and access that field when there was no value set?
What exact validation would you do in this case? Would you make it Boolean and check for null