File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Dynamically created Check Boxes in a JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Dynamically created Check Boxes in a JSP" Watch "Dynamically created Check Boxes in a JSP" New topic

Dynamically created Check Boxes in a JSP

Chris Whited

Joined: Oct 19, 2012
Posts: 24


I have a JSP where it displays a table from a database query and in that table I have checkboxes that are created for every row. I want to make those checkboxes dynamic (as in I want the value attribute of each checkbox to be dynamically created). In my table I have included the primary key field and its values, since they are unique I figure that is the value I should use to feed to my checkbox value attribute to make it unique for each row of data.

My question is, is there an EL expression to obtain this value from each row? And if so, what would it be?

My JSP is fed a reult object from the servlet which it then uses to make a table using JSTL.
Here is my JSP code:

I am trying to figure out what to put in for the value attribute (where all the question marks are about 3/4ths of the way down).

Any help would be greatly appreciated.

Chris Whited
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63873

Well, it what you want is a property of column, then it's just ${column.whatever}.

[Asking smart questions] [About Bear] [Books by Bear]
Chris Whited

Joined: Oct 19, 2012
Posts: 24

So in my case, my field name of my primary key is Ref_Num so would it be ${column.Ref_Num} or would it be the full database name, so ${column.Objectives.Ref_Num} where Objectives is the table name that has the Ref_Num primary key field?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

I don't know what database and table names have to do with it.

If your "column" attribute refers to an object with a getObjectives() method, then {column.objectives} is the way to get the result of calling that method. EL doesn't know anything about databases and tables, all it knows about is JavaBeans. It's up to you to design your attributes so that they are JavaBeans.
I agree. Here's the link:
subject: Dynamically created Check Boxes in a JSP
It's not a secret anymore!