Velocity with checkbox

I need to create a checkbox that reads the value if it is checked or not and then I will do some stuff depending on that.

But I cant get the checked or not checked into the code. Why?
In my servlet I add:
actionMap.put("showServer", ShowServerAction.class);
it goes to ShowServerAction.class
in my showServer.vm I have writen this:
        <td class="header">Hibernate&nbsp;databas&nbspupdate</td>
        <input type="checkbox"  name="deployHibernate" value ="$deploy.hibernate"/>
and the box shows and I can check it. When I then press the button it will bring the checkbox value....I guess.
I try to get the value
String deployHibernate = request.getParameter("deployHibernate");
The value that gets into the string is. 
I would likte the string to be something like checked or notchecked.

Open in new window

Who is Participating?
gaston_acevedoConnect With a Mentor Commented:
supose you have a variable named "mustCheck"
in velocity template, the code is

<input id="$name.$value" type="checkbox" name="$name" value="$value"#if ($mustcheck) checked#end >

Of course you can use attributes from the object used for fill the template.
The checkbox html object not use the value attribute to inform his state. use instead the checked attribute.
If checkbox contains the checked attribute whit ANY value then his estate is checked.
You must control programatically if the templade adds or remove this attribute.
MickeysAuthor Commented:
could you please show an example in code?
and example of what?
or java code
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.