Solved

Setting Values for a Javabean from JSP

Posted on 2008-10-27
2
287 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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

809 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