• Post Reply Bookmark Topic Watch Topic
  • New Topic

Booleans in beans  RSS feed

 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are there special rules about booleans in beans? I tried changing a variable from a string to a boolean and now when I try to set the property it can't find the function.

This is the code with the boolean:


If I set the properties of the bean using property="*" it the introspection doesn't find the ispopup and just skips it. If I try to set it directly I get:

 
Paul Clapham
Sheriff
Posts: 22379
42
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a special rule: you can declare your boolean property like this:But I thought it was optional and that you could use the regular getXyz and setXyz for booleans as well. Maybe the "is" part of your property name is confusing things? Just a wild guess.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your bean violates the JavaBean pattern. Is the property a string or a boolean? Your accessor claims it's a boolean, yet your mutator claims it's a string.

Can't be both.
 
Jacob Fenwick
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ah. I was wondering about that. I wanted the request to pass 0/1 or n/y and parse it into a boolean. I thought that by passing in a string and returning a boolean I could accomplish this but I guess it violates the rules.
Does this mean that you have to pass the word false/true through the request when you use a boolean variable in a bean?
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66158
146
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd have to check the property conversion rules. See the JSP spec.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!