Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6862567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:40:37+00:00 2026-05-27T02:40:37+00:00

I’ve set up a CRUD web application with Spring Roo and Spring MVC. My

  • 0

I’ve set up a CRUD web application with Spring Roo and Spring MVC. My problem is: since I’m using a converter for localizing the displaying of boolean values the Spring JSP Tag checkbox is broken which means the checkboxes don’t take the real value from the backing beans. They are always false and unchecked.

I’ve done some research and probably found the error in the writeTagDetails method of org.springframework.web.servlet.tags.form.CheckboxTag. Here is the interesting part of this method:

// the concrete type may not be a Boolean - can be String
if (boundValue instanceof String) {
    boundValue = Boolean.valueOf((String) boundValue);
}
Boolean booleanValue = (boundValue != null ? (Boolean) boundValue : Boolean.FALSE);
renderFromBoolean(booleanValue, tagWriter);

Because I’m using a converter to display yes/no instead of true/false the boundValue is a String and the call of Boolean.valueOf always results in false because the valueOf method isn’t aware of the used Spring Converter and interprets yes/no as false.

How can I solve this issue with Spring? Has anybody a clue? My brain has reached a blind alley.

Just for completeness: The converter for the Boolean type is working as expected (code see below).

public class BooleanConverter implements Converter<Boolean,String>, Formatter<Boolean> {

@Autowired
private MessageSource messageSource;

@Override
public String print(Boolean object, Locale locale) {
    return (object)
            ? messageSource.getMessage("label_true", null, LocaleContextHolder.getLocale())
            : messageSource.getMessage("label_false", null, LocaleContextHolder.getLocale());
}

@Override
public String convert(Boolean source) {
    return this.print(source, null);
}
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:40:38+00:00Added an answer on May 27, 2026 at 2:40 am

    This seems possible to overcome. That is you want a human readable Formatter to display yes/no to the user for boolean values in the model. But you still want the checkbox HTML elements to work and it appears those HTML checkbox elements/widgets/JSP tags expects true/false string to be used (or a boolean Java type) it doesn’t appear to use the converter to get the arbitrary yes/no string back to a boolean type.

    This problem for me manifests itself as the initial state of the checkbox is never ticked when the model has a Boolean.TRUE value set. This means any read-modify-update of the record (without editing that field ends up transitioning from ‘true’ to ‘false’ when it was not changed by the user). This is due to the initial state in the UI being inconsistent with the model (it shows always unchecked i.e. false state) even when model is true state. The displayed value is of an unchecked checkbox in the HTML edit record screen, even when the model has Boolean.TRUE for that value. This is because “yes” does not get interpreted as “true” by the HTML checkbox elements and it defaults to false (as that is the default boolean value).

    So define your Formatter/Converter (as you are already doing). But in your @Controller add:

    @InitBinder
    public void initBinder(WebDataBinder binder) {
        binder.registerCustomEditor(Boolean.class, "friesWithThat", new CustomBooleanEditor(false));
    }
    

    This appears to make the string display value continue to be yes/no but the value used and passed to the checkbox HTML elements continues to be true/false.

    Now when editing/updating the record (in CRUD) the initial state of the checkbox is consistent with the model and saving the data (without editing any fields) does not transition the checkbox state (which is my understanding of the problem you have).

    So from this I think we can understand that Converters/Formatters are for general display of data and that PropertyEditors are for mapping model data so the data needed by the UI widget.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
We are using XSLT to translate a RIXML file to XML. Our RIXML contains
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.