Solved

Setting Values for a Javabean from JSP

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
This article discusses how to implement server side field validation and display customized error messages to the client.
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…

724 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