Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2888
  • Last Modified:

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

0
Mickeys
Asked:
Mickeys
  • 3
1 Solution
 
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
 
gaston_acevedoCommented:
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now