Struts html:checkbox always enabled.

I'm using the Struts html:checkbox .  I have a checkbox called showTimeline.  If checked, I show a timeline graph on my jsp page.  if not, I want to not show the graph.

The problem is that if I set the checkbox to false , the checkbox sets itself to true.  Almost like something always turns the checkbox on.

My form has these methods:
       boolean showTimeline;
       public boolean isShowTimeline() {
            return showTimeline;
      }
      public boolean getShowTimeline(){
            return showTimeline;
      }

My JSP has this code:
      <tr><td>Enable Timeline</td>
          <td><html:checkbox property="showTimeline"></html:checkbox>
          </td>
      </tr>


So far my Action class does nothing but print the parameter:
   System.out.println(form.isShowTimeline());  // always prints "true"


How do I make my html:checkbox behave properly?  Meaning I uncheck the box and resubmit the form, I want to form to contain "false" and the box to remain unchecked.
tmonteitAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

tmonteitAuthor Commented:
!!correction!! the form has these methods:

My form has these methods:
       boolean showTimeline;
       public boolean isShowTimeline() {
            return showTimeline;
      }
      public void setShowTimeline(boolean showTimeline){
           this.showTimeline = showTimeline;
     }
0
JaaxArchitectCommented:
In your reset method, explicitly set the ShowTimeline to false and then try.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
suprapto45Commented:
Try Jaax's suggestion.

If it still does not work, try to retrieve the values not as boolean but as a String and see what do you get.

David
0
Bootstrap 4: Exploring New Features

Learn how to use and navigate the new features included in Bootstrap 4, the most popular HTML, CSS, and JavaScript framework for developing responsive, mobile-first websites.

tmonteitAuthor Commented:
I would actually prefer to work this checkbox with a String rather than a boolean.  

The only example of html:checkbox used a boolean.

Do you have an example of how to build an html:checkbox using a STRING.  like "TRUE" if checked "FALSE" if not.
0
JaaxArchitectCommented:
Please read the info present here :http://struts.apache.org/1.x/struts-taglib/tlddoc/index.html
It states that.

It states 'The underlying property value associated with this field should be of type boolean'
and also cautions developers to set the checkbox values to false in the reset
0
tmonteitAuthor Commented:
So, I already am using boolean.  What's wrong with the code that makes it not work properly?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.