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 the email is invalid.

As shown before both view are mapped to different page. And in AJAX call upon success it is calling function to add row.

I think these are two conflicting or equivalent steps I am taking. So I am missing some point.

Can anyone tell me how can I solve this issue?

Anjib

On 12/2/2010 2:09 PM, Dave Newton wrote:
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<anji...@hotmail.com>  wrote:

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 page
            request.setAttribute("returnValue",  email);
            return mapping.findForward(SUCCESS); //View 1

        } catch (Exception e) {
           //If email is invalid it retun null with error message and map to
blank page.
            request.setAttribute("returnValue",  "-1");

            ActionErrors errors = new ActionErrors();
            errors.add("error", new ActionMessage(e.getMessage(), false));
            this.saveErrors(request, errors);
            return mapping.findForward(FAILURE); //View 2

        }
}
On 12/2/2010 1:42 PM, Dave Newton wrote:

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

"Tap it" in that function: isn't the returnValue either the email (if
successful) or nothing (if not)?

Although personally I'd still use JSON; easier.

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@struts.apache.org
For additional commands, e-mail: user-h...@struts.apache.org

Reply via email to