aspose file tools*
The moose likes JSP and the fly likes create one checkbox per row for the JSP table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "create one checkbox per row for the JSP table" Watch "create one checkbox per row for the JSP table" New topic
Author

create one checkbox per row for the JSP table

albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 247
How to create one checkbox per row for the JSP table?
What is the code to process it?
This is what my first attempt:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Are you mixing scriptlets with the EL?

Pick one or the other (preferably modern EL). Mixing them will just create a mess and no end of problems.

In any case, what specific problems are you having? Does the HTML end up looking like you want? If not, why not? And what can you do about it?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 247
Bear Bibeault wrote:Are you mixing scriptlets with the EL?

Pick one or the other (preferably modern EL). Mixing them will just create a mess and no end of problems.

In any case, what specific problems are you having? Does the HTML end up looking like you want? If not, why not? And what can you do about it?


I modified some code from a book.
I got this error:
org.apache.jasper.JasperException: /WEB-INF/jsp/data.jsp(69,0) Unterminated <c:set tag

Is there a fix?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

OK, why didn't you just post that error in the first place rather than posting a vague question? You'll find that when you ask well-defined and specific questions that you will get better answers.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

albert kao wrote:I got this error:
org.apache.jasper.JasperException: /WEB-INF/jsp/data.jsp(69,0) Unterminated <c:set tag

It's telling you that your <c:set> is unterminated. So what do you check?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

After fixing that, the next step is back off your modifications and be sure not to use any scriptlets. I'm willing to bet that the book didn't mix the EL with scriptlets. And if it did, it certainly didn't embed EL expressions within scriptlets -- which is completely invalid.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 247
This has no error:

How to improve it?
Now I need some code to process the checkbox.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Does it produce the desired HTML results?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

albert kao wrote:Now I need some code to process the checkbox.

Then write some. Let us know what problems you run into.
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 247
Bear Bibeault wrote:
albert kao wrote:Now I need some code to process the checkbox.

Then write some. Let us know what problems you run into.


How to pass the value from the client checkbox to the server?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

String[] choice = arg0.getParameterValues("choice");

Yes, that's the correct way to get the checked values. So what's the problem?

P.S. arg0? You couldn't come up with a better name for the request parameter than arg0?
albert kao
Ranch Hand

Joined: Feb 04, 2010
Posts: 247
Bear Bibeault wrote:
String[] choice = arg0.getParameterValues("choice");

Yes, that's the correct way to get the checked values. So what's the problem?

P.S. arg0? You couldn't come up with a better name for the request parameter than arg0?


The problem is none of these will pass an integer to the server.
The server receive "k" but not 1, 2, 3, ....
<td><input type="checkbox" name="choice" value="k">Acknowledge</td>
<td><input type="checkbox" name="choice" value="$k">Acknowledge</td>
<td><input type="checkbox" name="choice" value=k>Acknowledge</td>
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18656
    
    8

I would also have tried this:
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61420
    
  67

Do a View Source on the page. if the form doesn't contain the right values in the first place...
Brian Sternari
Greenhorn

Joined: Feb 11, 2010
Posts: 1
You can do this:



Where 'varStatus="row"', defines a variable that can be used in generated elements (like checboxes) inside the forEach statement.

For example:

You can make checkboxes wich calls a javascript function with the row index passed as parameter:



Hope this help somebody!

Cheers!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: create one checkbox per row for the JSP table