users@jersey.java.net

[Jersey] Call another Resource with some other values

From: Cemo Koc <cem.koc.fwd_at_gmail.com>
Date: Tue, 22 Dec 2009 11:43:44 -0800 (PST)

Hi all,

I am struggling with something made me crazy. I wanted to actually add this
behaviour:

1) User gets resource A ==> It renders page A
2) User posts values for resource postA ==> Validation problem occurs
3) I want to forward posted values and errors and render page A again with
problems.


@POST
@ValidationEnabled
public Response postA(...){

}

@GET
public Response getA(@PathParam("ad") int ad){
   //
   return Response...build();
}


------

My validation code is like this. I commented necessary place and note that
switch case...



   @Around("@annotation(valAnno)")
    public Response check(ProceedingJoinPoint jp,ValidationEnabled valAnno)
{


        // validation ---> JSR 303
        Map map = validate(jp,valAnno);

        //problem occurs
        if (!map.isEmpty()) {
                  
             switch(valAnno.redirectType()){
                
                case HOMEPAGE:{
                 URI uri = new URI(getHomePage());
                 return Response.status(302).location(uri).build();
                     }
                   
                     case VALIDATE:{
                       /// ?????????????????????????????
                       /// Call getA with errors and other posted values
                       /// But URL should be change... It should be like
redirection
                       ///?????????????????????????????
                    }
            }
        }
        try {
            return (Response) jp.proceed();
        } catch (Throwable throwable) {
            return
Response.serverError().entity(throwable.getMessage()).build();
        }

    }




1) I am not sure about the things I have done....After validation error,
what should I do?

2) I know that I am trying to make something redirect in server side like
servlets. What should I write in empty blocks after validation in my aspect.

I am not sure that I could successfully explain my aim but it is simply like
this :(

Thanks




-- 
View this message in context: http://n2.nabble.com/Call-another-Resource-with-some-other-values-tp4205347p4205347.html
Sent from the Jersey mailing list archive at Nabble.com.