Velocity with checkbox

Hi,
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:
        <tr>
        <td class="header">Hibernate&nbsp;databas&nbspupdate</td>
        <td>
        <input type="checkbox"  name="deployHibernate" value ="$deploy.hibernate"/>
        </td>
        </tr>
 
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. 
deployHibernate=$deploy.hibernate
 
I would likte the string to be something like checked or notchecked.

Open in new window

MickeysAsked:
Who is Participating?
 
gaston_acevedoConnect With a Mentor Commented:
well
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.
0
 
gaston_acevedoCommented:
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.
0
 
MickeysAuthor Commented:
could you please show an example in code?
0
 
gaston_acevedoCommented:
hi,
and example of what?
checkbox
or java code
0
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.