From the course: Build Spring Boot Apps with the Kotlin Programming Language

Connecting views to controller functions

- [Narrator] Okay, so we've got a backing beam, what'd I like to do now, is, I think we'll remove the hollow world and the hollow world file. We don't really want that in our project either. But, let's now put in the homepage for our application, and what the homepage is going to do, is it's going to display our seat booking html file, passing through an instance of the check availability backing beam. So, we'll have a new method, which we'll call homepage. (typing) And this is going to return an instance of a model and view, and what we want to do in here is return a new model and view. The name of the file this time is seat booking, but we need to pass in a model. Now our seat booking is expecting a variable cord beam, so that's what the name of our backing beam should be. So that's the next value we provide. So in quotes the word beam and then we need a new instance of our check availability backing beam. I'm just going to copy and paste that. Put the opening brackets at the end, and that should be enough to display the homepage. Just again, so things are clear, this is effectively doing the same as we do in Java. I just really missed off the new keyword here. I think that's the only real difference. Oh, I suppose there there'd be a new keyword there as well. Actually, we can simplify this, we can make it a single line expression, so let's do that, and then we can give this a request mapper. Which will just be the empty string, cause it's the homepage for our application, and we should now be able to run this and see it working. So hopefully, now if we go to the root of our application, which will just be localhost kernel 8080. We should see the view and the seat numbers and seat rows should have been populated. So, let's go and try it and see. Okay, so this looks good. We've got a drop down here with the numbers one to 36, and the rows A to O. I won't click submit just yet, cause we've not written the code yet for that part. But, I hope you're following along with me and you've got that working.

Contents