• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic