Solved

Velocity with checkbox

Posted on 2009-04-15
4
2,688 Views
Last Modified: 2013-11-23
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
Comment
Question by:Mickeys
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 2

Expert Comment

by:gaston_acevedo
ID: 24149079
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
 

Author Comment

by:Mickeys
ID: 24154781
could you please show an example in code?
0
 
LVL 2

Expert Comment

by:gaston_acevedo
ID: 24157699
hi,
and example of what?
checkbox
or java code
0
 
LVL 2

Accepted Solution

by:
gaston_acevedo earned 500 total points
ID: 24157838
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

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question