So now we want to make the world we built on this button, which goes to Bucaram and then pass some
parameters, it passes the RIM ID, the start date and the end date.
We need to set up a handler that takes that and then creates a special variable for a reservation stores
that in the session and then takes us to the reservation page.
And that's really easy.
Let's do it now.
So let's go over to our roots and create a room and we'll call this room.
It'll be a get request or I'll just duplicate the previous line.
It will be a get request to book Dasch room.
And it's going to take us to a handler called Book Room, which doesn't exist yet, but we can go create
that.
So here in my handlers, let's create a function which will take the repository as a receiver and we'll
call it book room.
And as is the case with every handler, it has to have a response writer, which is a response writer.
And a pointer to a request.
All right, so that should fix the error in our rights file, and it does and what are we going to get
here?
Well, we're going to have to grab the values from the euro.
And I know those are stored in parameters called ID s and E, so let's get the ID is equal to ideate
an error because I'm actually going to.
I have to pass it from a string to an end, and again, I'm just going to ignore the air for now is
equal to our URL query doGet and on the name of the parameter, which is Edet.
And of course, I want to convert that from a string to an end.
So Pesters Seo Astar Seo in the dot a twohy and we'll put the parameter, the parentheses where they
belong and now have the ID and will say the start date is equal to our new URL dot query douget which
allows me to get a parameter, a get parameter.
And this one is called S.
And ending.
This is a sign the value of our UFO query does not get E for end, and I'm pretty sure that's what I
called them.
Let's go make sure.
So it's in the general's page s e and ID.
Yes, that's exactly what I've called them.
Now, just to make sure this works, before we go any further, let's just log this log print line D,
which is uppercase ID, start date and end date.
Let's make sure that works.
So I'm going to start my application.
Run my application.
And I expect to see printed out right here in the terminal those three parameters once I click on this
link, which fortunately I left active, so I should be able to just click on it.
Page not found book dash room ID.
I got something wrong.
Let's go find out what's in the roots.
Sagbo might want to spell room.
Right.
So let's start that over.
And come back here and I should be able to just hit this hit, click in here and hit return, and I
got a blank screen that's promising.
Let's go back to our terminal and there is the ID, the start date and the end date.
Good.
So I know that you are out now.
Works.
Now, what am I going to do with this?
Well, think about what we do.
Let's see when we after we choose a room, when we post book, when we post make a reservation.
It's at this point just before we display the make reservation page, we need to have some information.
So let's go in there and see what we have.
We have to have a sessional variable that is a reservation.
OK, so I'm going to want to create a reservation and put it in the session.
And that has to have some information.
It has to have the start date, the end date, the room ID and the room name so we can do that.
That's not hard.
So let's go down here and get our room.
First of all, let's create a variable call.
A ver rez is of type models, dot reservation.
Now I have an empty reservation so I can assign some things there right away and I need to put in red
dot remedy.
I have that.
That's just the ID, which maybe I'll call remedy, just make it more readable.
Room ID is equal to remedy.
Then I need to put it in the start date in the end date.
But remember the start date in the end date are actually in the format of time dot time.
And we have lots of examples up here where we did precisely that.
So let's just copy these, copy these three lines and come down here and we'll do that right here.
So this expects the spring to the string to be called SD, so I'll just rename this to rename this to
Eddie.
And now I have them in the correct format, which means I can go resort.
Start date is equal to start date and end date is equal to ending.
So I have the remedy, the start date and the end date.
What else do I need?
The last piece of information I need is the room name, which we did up here.
So we can just find that where we did it and copy it, paste it and we'll be good to go.
So let's see where we did it up here.
Which is fine room name.
Right here, so we can copy these lines.
Try that again, kopi these lines and pasted them down here.
So rez remedies should just be remedy that gives me my room and then rez room, the room name equals
room room name.
So at this point I've built up my variable, my special variable, the variable that's going to be put
into the session.
So let's just stick it in session m dot app, dot session dot put and it needs the context arg context,
the name which needs to be reservation because that's what I'm expecting to pull out.
Is it by that key and then there is.
All right.
So now we've got this done.
What do we want to do next.
We want to take them to the make reservation page HGP redirect.
Try that again.
Redirect and that expects to have w r make Dasch reservation.
And the actual code, which will be HDB status, temporary redirect, no less of status will go with
that one.
OK, and that should be it.
That's should be all I have to do.
So I'll get rid of this comment because I'm not using it.
And I'll give this the comment it should have.
I probably have some other ones I have to comment to so I'm able to do that, takes your parameters,
builds a sessional variable and takes user to make res screen.
OK, so that one has its comment.
This one needs a comment.
What does Chew's room do.
Displays list of available rooms.
OK, reservation summary needs a comment because I'm getting sloppy in my old age.
Display's the reservation summary page summary has to Ms.
And reservation doesn't have an extra eye, and I think that should be it looks like the rest of them,
that one doesn't need a comment.
This one does the rest.
Good.
All right.
So let's stop our application.
Started go back to a Web browser and let's start over, so we'll start at localhost right from the beginning
and I'll hide the JavaScript console because I'm pretty sure there's no JavaScript errors.
Now, I want to go to the rooms page.
The only one that set up is generals quarters.
We'll have to do a major suite next and check availability and search for dates I know are available
sometime in February, the ninth to the 10th.
OK, room is available and hopefully this will take us to the reservation page and it does Generals'
quarters, the ninth, the 10th.
We're all set.
And at this point I know that everything is right because otherwise this page wouldn't be displaying
anything.
So we should be good to go.
So the last step at this point is to take the code that we've used for the generals quarters page and
duplicate that functionality on the major sweep page.
So really, that's just a copy and paste exercise.
The one thing you have to remember to change is the remedy.
And the remedy for major suite in my case is to.
So I'll leave that as an exercise for you and then I'll go through I'll do it myself off camera and
show you what I have in the next lecture.
And then we're ready to move on to the next section.