Navigator and parameters

Hello,

I am quite new to Vaadin so forgive me for the dumb question :slight_smile:

We managed to get a list of users to render in a table using Vaadin. Now we would like to edit one of those users by opening an “edit” view containing the selected user’s data. We tried to do that by using the “Navigator” add-on, passing the view name and some ID. When the edit view opens it requests the user data again from the server by using the ID passed as parameter in the navigateTo method.

So far so good… except that the requirements changed and we now need to pass more than one parameter to retrieve the selected user, which obviously is not supported by the “navigator” add-on.

My questions are:

  • Is there a way to do this with “Navigator” or some other components in Vaadin?
  • Am I doing this the wrong way? Should I re-use the user data from the listing instead of requesting it again from the server?

Thank you for your help!

Hi,

im not sure if i got you right but i try to answer:

  1. i dont know why you use the navigator plugin for this… why dont you just use a popup-window?

But anyway, i assume all data you need to request the user data is stored in your table?!
If so, your view just needs access to your table. you can accomplish this in several ways.
i would pass the table instance to the constructor (i assume its an own class as you have to implement the Navigator.View interface) of your edit-view and hold it as field. then when you open the view you can get the currently selected row (item id) by calling getValue on the table…
Then get the item from the table by calling getItem and read out the properties you need to request the user data…
If the user-items stored in the table already contain all user data, i would just set the item retrieved from the table as datasource of your edit-form.

  1. if you already fetched all user data while filling the table, it is wrong to request the data again, its a waste of bandwith imo.

Hope this helps,

Felix

If I remember correctly, I have done this in some applications by adding a little helper method that parses the navigator parameter into a map, e.g. from something like “a=b,c=d”. Another helper can be used to encode the parameter string where necessary.

The advantage of using Navigator here is that you get pages to which you can go directly with the URL etc. You should not forget access control, though (if needed).