View with parameters

I have a CustomComponent class with some parameters (boolean and size) and i want now to implements a View with it.

But i don’t know how to initialize the parameters. I thought that i can do it with the enter method but i don’t know how.

public class LoginComponent extends CustomComponet {
protected boolean capital;
...
}
public class LoginView extends LoginComponent implements View{

}

When navigate to login i want to set a value to capital using parameter

Correct me if I’m wrong but you just want to set a variable in your LoginComponent in the enter method?

You could e.g. just define a variable

LoginComponent component;

in your LoginView and then just use

component = new LoginComponent();
component.captial = false;

or if you have a setter

component.setCaptial(false);

in your enter method.
You could of course also pass it in the Constructor if you want to.

Greetings,
Michael

You can pass the values through the URL in the form of
viewname

/parameters
. You can get the value of the “parameters” part by calling
event.getParameters()
in the enter method of the
View
interface. You can also use a
Map
instead and get the values by key. For example, if you invoke the following URL:


http://localhost:8080/view1/[b]
param1=111
[/b]&
param2=222

You can get the value of
param1
by calling:


event.getParameterMap().get("
param1
")

Notice there are no hashbangs in the URL, this is achieved with Vaadin Framework 8.2 by annotating the
UI
implementation with
@PushStateNavigation
. See
this video
for a working example.

No,
I want to navigate to the view with paramethers.

OK i knew about the URL but …
if i have navigate to…
UI.getCurrent().getNavigator().navigateTo(“login/capital=true”);
???

Thanks a lot to answer so quickly and for the references, they help so much!!!

Yes, you can navigate programmatically like that.

Hi
I am new on vaadin 8. I want to send by email the url of a page with parameters. If users click on this link and arrive on the application and only after authentication. they are directed to the page of the url.

Oumar DIONI:

Hi
I am new on vaadin 8. I want to send by email the url of a page with parameters. If users click on this link and arrive on the application and only after authentication. they are directed to the page of the url.

You can do that by checking if the user is authenticated before building the UI. If so, you show the view, if not, you redirect to a login page which, for example, could include a parameter to indicate that the login view should redirect to the original view after a successful authentication.