• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to pass string from (jquery in jsp) to java  RSS feed

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a jquery function writen in a jsp page(with myfaces1.2) that looks like the following code:
jQuery(function(){
$("#lastName").autocomplete("lastname.jsp").result(function(event, data, formatted) {
var selected = data;
alert(selected);
})});

And a java class with a method that looks like the following code:
public class DetailsFormBean
{
private String lastname;
public void setLastName(String lastName)
{
this.lastname = lastName;
}
public String getLastName()
{
return lastname;
}
}
When i run the project, the autocomplete part is working fine. But i dont know how to pass the selected variable from jquery function to java method(setLastName).
Please help me to resolve this.
 
Bartender
Posts: 3185
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create an action in your server which accepts the last name as request data. Then you can make a post ajax call to the action in server from your javascript function passing the last name.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!