You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-user@tomcat.apache.org by Charles Nealey <cn...@us.ibm.com> on 2004/03/10 18:13:00 UTC

input taglib - defaulting checkboxes to checked when using ?var=value in URL





I am using the Jakarta input taglib, the version published on 3/9/04. Here
is an example from the included input-examples.war file (from the included
form.jsp example file):

<%
String[] defaults = new String[2];
defaults[0] = "2";
defaults[1] = "5";
%>

Numbers you don't mind: &nbsp;&nbsp;&nbsp
<input:checkbox name="checkbox" value="1" defaults="<%= defaults %>"/>1
<input:checkbox name="checkbox" value="2" defaults="<%= defaults %>"/>2
<input:checkbox name="checkbox" value="3" defaults="<%= defaults %>"/>3
<input:checkbox name="checkbox" value="4" defaults="<%= defaults %>"/>4
<input:checkbox name="checkbox" value="5" defaults="<%= defaults %>"/>5

When I run this with a http://.../form.jsp, everything is good. All of the
input fields have the default values including the checkboxes above.
However, when I add ?var=value to the end of the URL (such as
http://.../form.jsp?var=value), it breaks the default checkboxes!
Everything else is still defaulted as it should be (text, textarea, select
and radio buttons are all still defaulting correctly), but the checkboxes
no longer have 2 and 5 defaulted to checked.

Is this a known bug or is there just no way to get this to work due to the
way checkboxes are submitted (nothing sent if nothing is checked)? Is there
a way to get around this? Any ideas???

      Thanks!

      Charles Nealey
      cnealey@us.ibm.com