users@jersey.java.net

[Jersey] How can I specify a Default value dynamically?

From: Paul <nibin.cse_at_gmail.com>
Date: Wed, 28 Sep 2011 23:45:45 -0700 (PDT)

Hi,

I am using query param for method. I want to specify the Default value for
that query param. If I specify a constant string, then it is fine. But how
can I specify a runtime value as the default value?

import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;

@Path( "Hello" )
public class HelloWorld
{
    private String defaultValue = "Default";

    @GET
    @Produces( MediaType.APPLICATION_XML )
    public String greet( @QueryParam( "User" ) @DefaultValue( "defaultValue"
) String userName )
    {
        String returnValue = "Hello " + userName;
        System.out.println( returnValue );
        return returnValue;
    }
}

Instead of a constant how can I use a variable here? Is it possible at all?
Regards,
Paul

--
View this message in context: http://jersey.576304.n2.nabble.com/How-can-I-specify-a-Default-value-dynamically-tp6842903p6842903.html
Sent from the Jersey mailing list archive at Nabble.com.