Javascript and JavaBeans

How to call a bean from with javascript.

Page 1 of 1

2 Replies - 3711 Views - Last Post: 17 September 2009 - 07:19 AM

#1 trixt.er  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 46
  • View blog
  • Posts: 419
  • Joined: 28-September 08

Javascript and JavaBeans

Post icon  Posted 16 September 2009 - 02:18 PM

So I am working on a dynamic web page with an oracle database to store all the data.
I have created the table to display the data with a trash icon at each row. When an icon is
clicked the entire rows data is deleted from the Oracle SQL database. I can easily retrieve the
primary key and want to pass it to a java bean so I can use the following.
entityManager.remove(obj.atId(id));


So in this scenario I need to pass the retrieved id from the javascript to a java bean.
The javascript looks like this...
	  function deleteInput(row, id) 
		 {
			 alert("Deleting row #" + row);
		 //  Delete by calling a javabean and passing it the id here.		
		 } 


So as you can see I know what needs to happen, I just don't know how to make it happen!
Any advice?

Is This A Good Question/Topic? 0
  • +

Replies To: Javascript and JavaBeans

#2 arthurakay  Icon User is offline

  • D.I.C Head

Reputation: 22
  • View blog
  • Posts: 226
  • Joined: 17-February 09

Re: Javascript and JavaBeans

Posted 17 September 2009 - 06:19 AM

I don't know anything about Java beans, but this sounds like a standard AJAX question.

When your "delete" icon is clicked, you need to fire an AJAX connection to your server with whatever value you need (e.g. the ID of the row).

Your server-side code (doesn't matter what language, though it sounds like you're using Java) takes that GET/POST value and does what it needs to. If you need it to pass data to/from the server or create Java beans then do it within your server-side code.

Finally, your server-side page passes any data back to the webpage in the AJAX response. At this point, you might remove the row from the screen or create a message saying the "delete" action succeeded or failed.

In other words... Javascript will have no idea what you're doing on the back-end. It won't know if you're using Java beans or anything else. In fact, Javascript doesn't care. It's all handled on the server. Does that help?
Was This Post Helpful? 0
  • +
  • -

#3 trixt.er  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 46
  • View blog
  • Posts: 419
  • Joined: 28-September 08

Re: Javascript and JavaBeans

Posted 17 September 2009 - 07:19 AM

View Postarthurakay, on 17 Sep, 2009 - 05:19 AM, said:

Does that help?

Nope.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1