Re: Struts 1 and AJAX

2010-12-03 Thread Dave Newton
Have you actually checked the object you're getting back to see (a) what it is, and (b) how to access and/or manipulate it? These are all JavaScript questions, not Struts, at least as far as I can tell. Dave On Fri, Dec 3, 2010 at 12:05 PM, Anjib Mulepati wrote: > I make following change to tes

Re: Struts 1 and AJAX

2010-12-03 Thread Anjib Mulepati
I make following change to test but still same problem function fnClickAddEmail() { var email = $("input#email").val(); $.post( "validateEmail.do", {sendValue: email}, function(returnValue){ if(returnValue == "-1"){ //Changed here displa

RE: Struts 1 and AJAX

2010-12-03 Thread Biesbrock, Kevin
> From: Anjib Mulepati [mailto:anji...@hotmail.com] > It still add blank row in table when invalid. The 'returnValue' variable is actually a jQuery object. I think you might have to do like returnValue.data or something to get the actual response text out of it. Beez --

Re: Struts 1 and AJAX

2010-12-03 Thread Anjib Mulepati
It still add blank row in table when invalid. Anjib On 12/3/2010 11:36 AM, Biesbrock, Kevin wrote: Gosh, you're so close. If you change this method: function fnClickAddEmail() { var email = $("input#email").val(); $.post( "validateEmail.do", {sendValue: email},

RE: Struts 1 and AJAX

2010-12-03 Thread Biesbrock, Kevin
Gosh, you're so close. If you change this method: function fnClickAddEmail() { var email = $("input#email").val(); $.post( "validateEmail.do", {sendValue: email}, function(returnValue){ //Does this function called even my email is invalid? Am I getting email

RE: Struts 1 and AJAX

2010-12-02 Thread Biesbrock, Kevin
1+json&ie=utf-8&oe=utf-8&aq=t&rls=o rg.mozilla:en-US:official&client=firefox-a Beez r 5347 -Original Message- From: Anjib Mulepati [mailto:anji...@hotmail.com] Sent: Thursday, December 02, 2010 3:34 PM To: Struts Users Mailing List Subject: Re: Struts 1 and AJAX

Re: Struts 1 and AJAX

2010-12-02 Thread Anjib Mulepati
I am trying with simple things but result are not as I expected. After call to Struts action I get either SUCCESS or FAILURE view. And these same page are displayed in the row itself. I was planning to display email if it is valid(SUCCESS) or error message on page (in div area fro error) if th

Re: Struts 1 and AJAX

2010-12-02 Thread Dave Newton
You *could* do that, or do it in the view layer, or just serialize a rational JSON object to the response and skip all the other issues, and make things easier. Dave On Thu, Dec 2, 2010 at 2:06 PM, Anjib Mulepati wrote: > So do I need to map two different view in action class as follow > > > {

Re: Struts 1 and AJAX

2010-12-02 Thread Anjib Mulepati
So do I need to map two different view in action class as follow { String email = (String) request.getParameter("sendValue"); // perform validation of email address try { insp.validate(email); //iF EMAIL IS VALID it return email and map email.jsp pag

RE: Struts 1 and AJAX

2010-12-02 Thread Biesbrock, Kevin
> Although personally I'd still use JSON; easier. > Dave Yep. So a successful response could look like this: response = { validEmail:true, emailAddress:'user@struts.apache.org' } and a failed response could look like this: response = { validEmail:false, emailAdd

Re: Struts 1 and AJAX

2010-12-02 Thread Dave Newton
On Thu, Dec 2, 2010 at 1:25 PM, Anjib Mulepati wrote: > But problem I am having is I can't tap the condition where email is > invalid. > > $.post( >"validateEmail.do", >{sendValue: email}, >function(returnValue){ >addToTable(returnValue); //add email to table

Re: Struts 1 and AJAX

2010-12-02 Thread Anjib Mulepati
I am trying to validate email user have entered in textbox. I am using AJAX call for validation. So I am sending my email as post request and if validated it will add email in the table in the web page. This is what I want to happen. But problem I am having is I can't tap the condition where e

Re: Struts 1 and AJAX

2010-12-02 Thread Dave Newton
On Thu, Dec 2, 2010 at 12:43 PM, Anjib Mulepati wrote: > Ok second also doesn't work. > "It doesn't work" actually isn't descriptive enough to allow anybody to help effectively--you'd need to say what actually happens, what you *expect* to happen, what's in your JavaScript console, what the actio

Re: Struts 1 and AJAX

2010-12-02 Thread Anjib Mulepati
Ok second also doesn't work. 1. I have AJAX post as follow: $.post( "validateEmail.do", {sendValue: email}, function(returnValue){ addToTable(returnValue); }, "text" ); 2. I have action as: { String email = (String) request.getPara

Re: Struts 1 and AJAX

2010-12-02 Thread Dave Newton
On Thu, Dec 2, 2010 at 12:33 PM, Anjib Mulepati wrote: > 1. By refresh I mean when user press F5 all content lost. > That is the nature of Ajax-heavy applications. You need to store a means of retrieving the object/data you're currently working with. One place to store it is in the session. Dave

Re: Struts 1 and AJAX

2010-12-02 Thread Anjib Mulepati
1. By refresh I mean when user press F5 all content lost. 2. I will try second one. Anjib On 12/2/2010 11:58 AM, Dave Newton wrote: On Thu, Dec 2, 2010 at 11:44 AM, Anjib Mulepati wrote: 1. My record in the table disappear if page is refresh. Don't refresh? Otherwise you need a mechanism to

Re: Struts 1 and AJAX

2010-12-02 Thread Dave Newton
On Thu, Dec 2, 2010 at 11:44 AM, Anjib Mulepati wrote: > 1. My record in the table disappear if page is refresh. > Don't refresh? Otherwise you need a mechanism to "remember" what you're working with, like the session. > 2. And If some of my email is incorrect I don't want that to be get back t

Struts 1 and AJAX

2010-12-02 Thread Anjib Mulepati
Struts 1.3.8 I am writing and application where end user insert the email address and get inserted in table shown on web page after successfully validation. For that I am doing following: 1. Get email from user in text box. 2. When user press add button AJAX post is called, email get validat