aspose file tools*
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
JavaRanch » Java Forums » Java » JSP
Bookmark "Dynamically created Check Boxes in a JSP" Watch "Dynamically created Check Boxes in a JSP" New topic
Author

Dynamically created Check Boxes in a JSP

Chris Whited
Greenhorn

Joined: Oct 19, 2012
Posts: 24

Hey,

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.

Thanks,
Chris Whited
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61764
    
  67

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


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chris Whited
Greenhorn

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
Bartender

Joined: Oct 14, 2005
Posts: 18987
    
    8

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: http://aspose.com/file-tools
 
subject: Dynamically created Check Boxes in a JSP