title: Vaadin: How can I get URL parameters?
body: <p>I've been trying to get the parameters from a url in my project using Vaadin but it doesn't seem to be functioning properly. I followed the instructions from the vaadin documentation but the parameter isn't being properly set. The routerlink properly navigates using the parameter (e.g.  localhost:8080/banner/g50) but in the new view it isn't properly setting the variable.</p>
  
  <pre><code>@Route(value = "banner", layout = MainLayout.class)
  @PageTitle("Banner")
  public class BannerView extends VerticalLayout implements HasUrlParameter&lt;String&gt; {
         private String ID;
         ...
  </code></pre>
  
  <pre><code>    @Override
      public void setParameter(BeforeEvent event,String parameter) {
          ID = parameter;
      }
  </code></pre>
  
  <pre><code>    //this is in my other view 
      String pathVariable = getID();
      RouterLink routerLink = new RouterLink("Link to data", BannerView.class, pathVariable);
  </code></pre>
  
  <p>edit:
  This is my constructor</p>
  
  <pre><code>public BannerView(BannerService bannerService, GameService gameService) {
          this.bannerService = bannerService;
          this.gameService = gameService;
          addClassName("banner-view");
          setDefaultHorizontalComponentAlignment(Alignment.CENTER);
          //span just added for testing purposes
          Span test = new Span("+" + ID + "+");
          add(getBannerCount(), getDataChart(), getAverageStats(), test);
      }
  </code></pre>
  
  <p>ID is used in the three methods that I use to add components (which return a span, a vertical layout and a chart). I tried putting my add components in a button with a click listener event so I could add the components by clicking the button after the constructor finished running as a comment suggested but that resulted in an exception:  java.io.InvalidClassException: local class incompatible:. The add was running correctly in the constructor with a hardcoded id for testing</p>