I have a step where the user has to select how to supply a trajectory line and whether the ground level is taken from a server or from an uploaded raster file. This leads to a various amount of combinations and in order to keep the code simple I have added a SetParamsButton which collects the user choices and stores using the VIKTOR Storage class. After doing this I use step validation to see if the stored data matches the current user input.
However, in order to process the user choices and store them in the Storage I need some sort of trigger. In this case a view is not sensible to use so therefore I have used a SetParamsButton. Processing the user choices does not change anything in the parametrization so therefore the method connected to the button just returns an empty SetParamsResult. I was wondering if there is a more elegant way of solving this.
I don’t fully understand why you would want to store the user choices in
Storage, as these choices are already stored in the params. Is it not possible to process the choices on the fly when the user clicks the ‘next step’ button?
Regardless of the above, an
ActionButton can be used to perform an action without returning anything.
@bvanderhulst Maybe my explanation wasn’t too clear. The user makes choices for the trajectory line and how to determine the ground level. For these choices the user has to upload an input file using a FileField. These files need to be processed to a Polyline object with x, y and z coordinates.
In a previous version of the code we used the params whenever we wanted to access the Polyline but we found ourselves having to check whether the input files had been processed yet or not in many occasions. Therefore we decided to force the user to process the uploaded files in one location and then from that moment on use the Storage whenever we want to access the Polyline.
I think an ActionButton is a good solution and I will definitely look into it!