Solved

Setting Values for a Javabean from JSP

Posted on 2008-10-27
2
286 Views
Last Modified: 2013-11-24
Experts,
  I have a table display that when the user clicked on a row a jsp function is called with the selected table row id.  I would like to pass the selected rowid to my java class (bean) so that it can do some processing with the selected row (i.e. delete the row from the database).  I am having trouble setting the values in my java bean from the jsp page; though, I have no trouble getting values from the bean to my jsp.  Please help!

---
...
<jsp:useBean id="mybean" scope="request"
             class="test" />
..
..
function rowSelected(num)
{
alert("selected row:"+num); //popup window shows the correct selected row number
  <%
  mybean.setRowSelected(999); //these two lines produced the expected results
  System.err.println("Row ID:"+mybean.getRowSelected());
 
  mybean.setRowSelected(num); //but with this...jboss throws exception about not knowing what num is?
%>
}
...
...
0
Comment
Question by:johnchan2000
2 Comments
 
LVL 27

Accepted Solution

by:
rrz earned 500 total points
ID: 22815854
First of all, you should put your bean in a package.  After doing that use it in your bean tag.
<jsp:useBean id="mybean" scope="request" class="your.package.test" />  

>mybean.setRowSelected(num); //but with this...jboss throws exception about not knowing what num is?
num , I think is a javascript variable and is in the browser at the client.  After the user selects a row, to get num to the server you must either make a request with a url with num as a parameter, or submit a form, or make a AJAX call.  
0
 
LVL 1

Author Closing Comment

by:johnchan2000
ID: 31510433
You're confirming that what I was trying to do is not feasible.  I am now using  hidden fields to pass along the values - and it works just fine.  Thanks for the help.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

In my daily work (mainly using ASP.net), I need to write a lot of JavaScript code. One of the most repetitive tasks I do are the jQuery Ajax calls. You know: (CODE) I don't know if for you it's the same, but for me is soooo tedious to write the …
Article by: DanRollins
This article describes a JavaScript program that creates a maze made of hexagonal cells.  In Part 2 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7850-Hex-Maze-Part-2.html), we'll extend the program by adding a depth-…
The viewer will learn how to implement Singleton Design Pattern in Java.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

803 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