Good day,
This is more web service design than programming question I think. I’ll try to explain what I want to achieve. In example I have a 3 combo boxes(e.g. size, color, texture) on the page which are dependent on each other. We can select them only in turns(eg. 1st->2nd->3rd). After selecting combo box value, next combo box gets populated+enabled and we are able to select from it too.
I came up with a few solutions which I can apply for this problem.
- Is when we come to the page and loaded JavaScript sends a post with a request for data to populate those combo boxes. The response returned is a batch data of all variants(JSON) is parsed and handled by JavaScript with every selection client does.
- Page is loaded with only first combo box and the remaining ones gets filled with the default values. Every time client selects a value, appropriate event(ajax which leads to post get) is fired to fill/handle next combo boxes dependent on selections.
Myself I see that first one is quite complicated and the batch value can be very big in terms if there are lots of selection variations for each of the value. And the second one seems does too many useless requests to the server which I think can lead to server overload. What do you think of these solutions? Does the concept is okey? And is it worth to implement first solution instead of second one even it is harder?
If something you do not understand in my explanation please ask I’ll try to explain in more detail.
I agree that pre-fetching everything is not a scalable solution, at some point there could be an unreasonable amount of data to fetch.
The second solution of incrementally fetching data seems most common in my experience. I suppose that by “useless requests” you mean you’re concerned with repeatedly fetching the same data if the user back-tracks and then reselects.
To address problem that I’ve used various caching techniques to optimise that behaviour.
I would say that a succession of drop down boxes may not be the best UI. Some frameworks (eg. dojo) have tree widgets, like those you would use to navigate a directory structure. I think you might find that approach would look better, and it’s nicely extensible to beyond three levels of hierarchy.