?
Solved

Setting Values for a Javabean from JSP

Posted on 2008-10-27
2
Medium Priority
?
294 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 28

Accepted Solution

by:
rrz earned 1500 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

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!

Question has a verified solution.

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

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)
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…
Suggested Courses

801 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