File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

create one checkbox per row for the JSP table

 
albert kao
Ranch Hand
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
albert kao
Ranch Hand
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This has no error:

How to improve it?
Now I need some code to process the checkbox.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it produce the desired HTML results?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 252
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Sheriff
Pie
Posts: 20171
25
MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would also have tried this:
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64178
83
IntelliJ IDE Java jQuery Mac Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do a View Source on the page. if the form doesn't contain the right values in the first place...
 
Brian Sternari
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic