Retrieve String value from init method

Hi guys,

I need some help here.

Is it possible for me to retrieve the value of the string “code” outside the init method and use it in a different method?

If yes, how?

Thanks for the help.

protected void init(VaadinRequest request) {
String code = request.getParameter("code");
if (code != null){
System.out.println("Code: " + code);

Yes, you can either pass it to the method as a parameter or store it as a member variable in the UI class or elsewhere. See a
Java tutorial
for further details.

I don’t think the initial request is stored anywhere. You can get the current request object from VaadinService instance, which is the initial request while it is being processed, but not after that.

Variable set outside init belong to the class. They’re shared by all instances.
See a [Java course]
( for more information.