• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

non-whitespace whitespace

 
Craig Ricciuto
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The title might be confusing but here's my situation.

I have an ArrayList of String values being set in my action class and then in my JSP I iterate over that list outputting a checkbox and a textfield. All the checkboxes share a name (so their values end up in a list) and all of the textfields also share a name (a different name than from the checkboxes though) whose values end up in a list too.

The list for the checkboxes ONLY includes the selected checkboxes. That's fine. That's what I expect.
My problem is that the list for text fields has an element for EVERY text field (blank fields and filled in fields). This is a problem because my two lists don't match up. One list (the textbox list) is always bigger than the other list (the checkbox list).

I tried looping over the textbox list and doing a check for a space via:
but that didn't work. I tried using the String's trim() method...that didn't get rid of the whitespace so I could just check for a blank String.

So I either need to know what character it is that the textbox returning so I can do a check for that character and just remove it from my list OR find a way to not have blank textboxes get submitted and stored in the list in the first place...or a third option I have not considered.

Thanks for any help.
 
Craig Ricciuto
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nevermind. I figured out a way I could fix my problem. With a little javascript I just made the textboxes get enabled when it's corresponding checkbox is clicked. Any disabled textbox isn't passed into the list. I set all textboxes to be disabled by default.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic