Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to submit a form without refreshing it

843844Aug 31 2007 — edited Aug 31 2007
hi all,
i got a problem with submitting a form using a JSF button without refreshing whole page. here's a sample of my code:
// in the JAVA
Button button = new Button();
button.setText("Submit Form");
button.setEscape(false);
String target = "targetId";       // this is the <div> or <span> to be updated by Ajax call
// in here 'sentTheForm(); is a javascript function
button.setOnClick("sendTheForm('" + target + "'); return false;");

// in JSP
// javaScript uses Prototype.js for Ajax call
function sendTheForm(target) {
   new Ajax.Update(target, 'Server/ProcessForm', {method:'post'});
}

// on the server side a Servlet sitting there to handle the actions
......
java.util.Map map = request.getParameterMap();      // request is an HttpServletRequest
out.println("there are " + map.size() + " fields submitted");
......
i hope the code trunks show what i want to do. Basically, i m trying to submit a form using ajax, and refresh on field of the page only. The above code gives result as:
there are 0 fields submitted
which means the form is not actually submitted. i don't know where i got wrong in my code. somebody can help? THank you in advance!

best regards
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 28 2007
Added on Aug 31 2007
4 comments
331 views