• Post Reply Bookmark Topic Watch Topic
  • New Topic

Testing presence of request parameter (different to the null test)  RSS feed

 
Edward Winchester
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,

My problem is fairly subtle so I hope I can describe it properly. I am using Spring MVC with JSP. I have a multi action controller which by default provides a generates a list of entities for the view. The user can then select checkboxes against the entries and then click a delete submit button.

The controller's delete method handles the deletion. Here's the pseucocode:



So in the scenario where there's at least on checkbox selected, the deleteStatuses != null. Otherwise it does equal null.

This is the pseudocode for the default action for the controller. In this case there is no "deleteStatuses" at all.


In my JSP code I'm encountering a problem correctly distinguishing these 3 scenarios:


Of course I could put additional flags in the model like "didDelete"="yes" but I'd prefer to avoid that if possible.

Thanks for reading,

Ed
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The empty keyword checks for both nullness and zero length; you'll need to set a flag. IMO that's cleaner anyway, and would be easier to expose via service or whatever if the need ever arose.
 
Edward Winchester
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:The empty keyword checks for both nullness and zero length; you'll need to set a flag. IMO that's cleaner anyway, and would be easier to expose via service or whatever if the need ever arose.

Thanks for the reply I'm aware of the empty keyword. Please explain how it helps me to distinguish between the 3 scenarios I mention.
 
Edward Winchester
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edward Winchester wrote:
David Newton wrote:The empty keyword checks for both nullness and zero length; you'll need to set a flag. IMO that's cleaner anyway, and would be easier to expose via service or whatever if the need ever arose.

Thanks for the reply I'm aware of the empty keyword. Please explain how it helps me to distinguish between the 3 scenarios I mention.

I'll do the flag. Thanks again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!