[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Question on how to capture a clicked item on a table and pass to a Servlet?

Posted on 2006-03-28
9
Medium Priority
?
201 Views
Last Modified: 2010-04-01
Hello,

How do I capure an item clicked on a table and send it to a Servelt? For example Say I have a table like this...

   item1      item2        item3
   item4      item5        item6
   ------       ------        ------

Say I click on item5. I need to pick this item and call a Servlet so that I pass the value 'item5' to the
servlet.

Thanks
prain
0
Comment
Question by:prain
  • 5
  • 3
9 Comments
 
LVL 11

Expert Comment

by:fargo
ID: 16310540
Hi,

There are two options

1) When you click on a particular item, have a onclick event , set the hidden parameter in the form with this particular value and then submit the complete form (This means refresh complete page) and the action of the form should be the servlet.

2) Use AJAX and have an action make a java call (with servlet)

fargo
0
 

Author Comment

by:prain
ID: 16310564
So do I have to attach an onClick event for each item in the table?
0
 
LVL 3

Expert Comment

by:el_dios
ID: 16311426
Yes, how are you getting the items in thetable? You could use a scriptlet for doing this.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:prain
ID: 16312537
Within my servlet that prepares the table, I am having a variable. So the items that you see in the table are NOT
hard coded they are genrated dynamically. This is the line that I create each cell . the

displayName

is a java String variable.


out.println("<td>" + displayName + "</td> ");

So what I need is to pickup the value presented by t he displayName (visible in the table) and then
pass that value to a Servlet.

Thx.
0
 

Author Comment

by:prain
ID: 16313267
Hello,
I am increasing the points to 125.

I am getting the whole table messed up when I attach onClick or any other in each cell.

Again, here is what I want.

My table is generated by a Servlet. The Servlet has a loop within which I have this code.

out.println("<td>" + displayName + "</td> ");

where displayName is a java String variable. So when the table is created, item visible on each cell is created dynamically.

So I will have a table like this....

  item1      item2        item3
  item4      item5        item6
  ------       ------        ------

This works nice and the table is generated nicely. Now I want add some spice to that. I want to make each item a selectable item and then when selected I want to call a Servelt and I want to pass that selected item to teh servlet. Any help?
0
 
LVL 11

Expert Comment

by:fargo
ID: 16313331
>> I want to make each item a selectable item
ok. What do u mean by selectable item?

Do you wish it to be a link?
Do you wish to add a checkbox to each item?

What exactly?

fargo
0
 

Author Comment

by:prain
ID: 16313361
Actually it sould go to a Servlet. We we can say it s a link.
0
 
LVL 11

Accepted Solution

by:
fargo earned 500 total points
ID: 16313402
well,

if it is a link, it makes the job quite easy.

<a href="/to/your/servlet?param1=itemValue">item1</a>

you click on this link in your table and you go to a servlet. Will this be of help?

fargo

0
 

Author Comment

by:prain
ID: 16313897
fargo,

Goodie!. I got it. Thanks for all hints. a+

prain
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month18 days, 11 hours left to enroll

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question