Detailed Notes
We are continuing a series of tutorials focused on Spring Boot. The crux of the project is to convert/migrate an old JSP/Tomcat application to a modern Spring Boot application and Java 7/8 to a current version. We are working on a complex form for entering data. We dig into another setup of forms and migrating controller code. This is part 1 of a brief, 2-part series.
You can learn more through our online classes at https://school.develpreneur.com and register for free. Registration will add you to our email list, and you will periodically receive coupons for courses and notifications of the latest releases.
Transcript Text
[Music] well hello and welcome back we are continuing our Journey as it were from an old Apache Tomcat JSP application updating it to Spring Boot and walking through a few other things along the way just getting comfortable with spring boot getting comfortable with bootstrap five and also using time Leaf which is basically the you the core underlying uh sort of templating type thing that uh we use with instead of JSP that we use with the spring boot last time around we were playing around with this uh basically with trying to get a an index into a list that we sent in so when we save it that it would show properly here so that CU this one we're not actually we're just like jumping into a value we're going into that value and we're saying hey let's see what it resolves to uh because it's an ID versus a string and we're running into a few issues with it uh and it was basically because of doing this math that now what we've got is this list so if you go back to this page and look at this list where it's difficulty it's just saying Hey I want the text that is from the list the difficulty list and I want to get the one that is my value which is test. difficulty that's going to be my integer I'm just going to subtract one from it and then I'm going to get the name of that and we had a couple little issues with it I think it was because we were not doing this properly within the parenthesis but now so you can see just to see how it looks is I've got my list I'm just going to do a get out of it and I'm going to get it based on the uh index which here you can see bra bracketed by parentheses um I subtract one from it because it's a Zero versus a you know it's like a zero starting zero indexed array kind of thing and then I'm going to get the name and so now if we do it if I go to here like this one that was simple I'm going to set it to average save it and boom I've got my I shouldn't click on it because that's clickable but um so now it is displaying properly now just carrying forward we want to do sort of the same thing so we've got our task now we can create a new task we can cancel we can save don't know if we got our update I mean our delete so if we do delete uh it is not deleting so let's go look at our delete real quick and see why that's not working and it looks like uh project ID is not readable or has an invalid one so we probably don't have here oh here we go so select task Let's see we may not be building our link properly uh let's see I think well let's go look at our so if we come in here it's going to do select task o That's select uh if we do delete oh that's in here this is going to be from the task itself so we're going to go look to our task form so we're going to come over here and we're going to go to [Music] our go find our template for our task there's our task form and if we look up here uh let's see let's go look for delete so delete is just going to do delete task and it's going to give it an ID and I think what we're going to find here is if we go look at our delete for uh it's probably not in here it's probably in our other controller uh let's see we had hello controller and we had what was our other controller uh we called it task controller there we go and so if we go look for delete here I bet we had here oh it's an ID T.G project ID so what's it complaining about let's close that uh it says it's not readable okay so uh let's go look here at our task Dao so we get a a task we look at our regular task model let's make sure we've got that right and we don't have some sort of which we probably would get an issue so if we look here project ID yep project ID and it's complaining that what was it again uh it's not readable or it has an invalid getter does it turn the okay so let's go look at uh get project ID so that should be okay so if we do get project ID returns a project oh it's probably because it's not where did I put that it's probably the wrong one oh yeah for some reason get does not have a this dot uh wow we've got that in a couple of these so that's a nice little bug that we we found there is that for some reason we've got some of these that do not have I'm not sure why we suddenly got this but let's just do it like this um we have got a whole bunch of these that came across and did not use the this so they're actually just returning a local variable instead let's see this this there's description this name so that could cause us all sorts of little fun issues so let's make sure we properly adjust that out I think we're going to be okay in several of these because it's going to do it by default but just to be safe let's make sure there we do that now if we run it we should be able to uh we got to reset log in let's pick one that has a task here we go so let's take this task and let's try to delete it and it still didn't delete it so let's see what it says now oh so now it came through so let's go see why maybe it didn't uh this is going to be in our task [Music] controller uh it's going to go in and do a delete so let's go look at the Tas D Dao and see why it might not have deleted and where did we put our model blah blah mapper you it's up here somewhere right there it is I'm going to take a look at our Tas Dao if we look at delete so that's where task ID equals that uh let's just do we're just going to keep it simple here and we're going to do this so we're going to print the SQL and we're going to do the ID well except for we can't use a p print we're just going to a regular print wh and let's make sure uh what else did we want to look oh let's make sure we're sending the task IDE across for from the [Music] controller uh and we just come we do it yep and then we're going to go do that edit get project ID so let's see what that does for us so we're going to run this and we're going to jump over here we're going to reset and we're going to go up here we're going to try to delete and let's see what it does in the output oh it does nothing interesting so we may have delete task in Let's see we have that in two places so we have it there did we have it in the hello controller as well uh where did my hello controller we have delete opportunity so we have delete op interesting so let's go look at task well not task form and if we go look at uh Delete where's delete there it is delete task let's make sure we've got the right d ID for our delete task so if we inspect that element let's make sure we're getting our values across properly uh delete task 23 so now if we do that we delete task 23 it worked so we're not getting we weren't building it right somehow let's go look back at that let's go look at uh let's see that [Music] should interestingly enough it's not going there let's see let's go look at ours a little bit oh I wonder if it's a uh on click let's do uh we can't do that let's go look at that again and let's go fix our link and so we can run it let get uh well let's actually let's keep a look at what we were building here uh let's see oh we can just oh uh yeah pick one pick one so it's going to come in and he's going to do location.href we may have to okay so it's not s interestingly enough it [Music] is having an issue it's doing delete oh because it's a button because it's a button Ah that's problem is it's treating it as a submit one of those fun little things because we're in a form it's going to see that button and it's going to try to send it through submit instead so if we come through here and instead just change it to a div everything else is the same uh it's on yeah onclick yep that all works so now we should be able to come in here log in uh pick one wh pick one and delete that and now we're there so there we go that's one of those fun little things with a form is that if you've got a button an actual Button as opposed to something else it's going to try to send that through to the submit and so that's the process that we were we had broken so we have our tasks now working we can do everything with that let's take a look at our overhead now if we immediately go in we've got an issue here with the new overhead so let's go take a look at uh let's make sure first I look at that is that some weird uh no he's probably okay so let's go look at that page actually we probably have yep there we go and we've got uh project idea being class it's not readable oh so we may have this also that this issue that we had we have in the overhead so let's go look at our overhead real quick and yep there we go we got a bunch of these so let's just walk through this uh let's see return this return this return this could be one of those things that this is because we were working on an earlier version of java it was not so picky about the thises and figuring out scope so let's go look at this real quick and see if that fixed it to get us to creating a new opportunity or I'm sorry overhead okay we still get an error let's see if it's the same thing did we get it somewhere else uh now it is complain yeah project ID is not readable uh it's probably in Ely F thingss so let's see if it tells us where it did that so it's probably in the form itself overhead form 43 so let's go look at our overhead form that's going to be over here line 43 uh maybe we haven't converted everything yet uh could be 43 here field is that so project ID we don't have sitting there maybe so let's go look at our task controller for our new overhead and we have here project ID load over for head form project ID so if we go to load overhead form uh oh we don't have a project ID we have a user ID but we don't have just a straight project ID oh do we let's see let's let's go look at our overhead form uh do we instead want that to be I think we want that to be let's say if that's that let's see if we make it path I think that's what we really wanted that to be anyways let's try that before we change this all up cuz I think that's what we wanted is we wanted to bring it we didn't want to send it separate we wanted to bring it out of the controller itself so if we do path we're going to pull it off of that uh the object that we're working with if we do if we don't like we did before if we have a field then it's going to be looking for something that we have sent like a specific value we have sent in let's see if we got something different uh valid property project ID okay same thing so let's go look here if we go look not we w't look at oh because I didn't save that makes a difference uh let's see so there we go so we've got our type that should be our path and it is a I think what we want is do we want our let's go back look at our task real quick uh task form it's pathed we need [Music] our uh here we're using value but we can go here oh no we are still use I'm sorry path is the old one my mistake so we can do th field with a star so if we come to our overhead that's the problem when we mix a few things so if this is th field star that should work uh let's see that's going to be a value and a field all right so we should be good is that right that should be right and then we'll have to see just to make sure we've got case correct because if we do that uh overhead in the model if we look there uh let's see look at it so get uh may we may need the capital I think we probably need this to be a capital I let's try that real quick think that's it I think it's a case sensitivity issue there let's reset let's get going let's go here let's go here we got an error if it's not that then it is okay so type so now we've got to go in here we probably got type somewhere type uh th field so type is not readable or has an invalid getter so for overhead let's go look at type we have set type we have oh it's get type ID okay so we need to go back over here uh this is going to be type ID I wonder if difficulty is the same yep difficulty is the same and so now let's try it let's line up our values properly and now let's see if we can at least get our form up and there we go so now we're getting into it so it's probably a good place to pause for now we're going to come in next episode and we're going to go ahead and just follow through hooking up our our buttons again sort of reinforce some of these things I wonder if we're going to have the same issue with casting these values and uh we're just going to keep chugging along if you have any questions shoot us an email at info@ developer.com and go out there and have yourself a great day a great week and we will talk to you next time
Transcript Segments
[Music]
well hello and welcome back we are
continuing our
Journey as it were from an old Apache
Tomcat JSP application updating it to
Spring Boot and walking through a few
other things along the way just getting
comfortable with spring boot getting
comfortable with bootstrap five and also
using time Leaf which is basically the
you the core underlying uh sort of
templating type thing that uh we use
with instead of JSP that we use with the
spring boot last time around we were
playing around with this uh basically
with trying to get a an index into a
list that we sent in so when we save it
that it would show properly here so that
CU this one we're not actually we're
just like jumping into a value we're
going into that value and we're saying
hey let's see what it resolves to uh
because it's an ID versus a string and
we're running into a few issues with it
uh and it was basically because of doing
this math that now what we've
got is this list so if you go back to
this
page and look at this list where it's
difficulty it's just saying Hey I want
the text that is from the list the
difficulty list and I want to get the
one that is my value which is test.
difficulty that's going to be my integer
I'm just going to subtract one from it
and then I'm going to get the name of
that and we had a couple little issues
with it I think it was because we were
not doing this properly within the
parenthesis but now so you can see just
to see how it looks is I've got my list
I'm just going to do a get out of it and
I'm going to get it based on the uh
index which here you can see bra
bracketed by
parentheses um I subtract one from it
because it's a Zero versus a you know
it's like a zero starting zero indexed
array kind of thing and then I'm going
to get the name and so now if we do it
if I go to here like this one that was
simple I'm going to set it to average
save it and boom I've got
my I shouldn't click on it because
that's clickable but um so now it is
displaying properly now just carrying
forward we want to do sort of the same
thing so we've got our task now we can
create a new task we can cancel we can
save don't know if we got our update I
mean our delete so if we do delete uh it
is not deleting so let's go look at our
delete real quick and see why that's not
working
and it looks like uh project ID is not
readable or has an invalid one so we
probably don't have
here oh here we go so select
task Let's
see we may not be building
our link
properly uh let's see I think well let's
go look at our so if we come in here
it's going to do select
task o That's select uh if we do delete
oh that's in
here this is going to be from the task
itself so we're going to go look to our
task
form so we're going to come over here
and we're going to go to
[Music]
our go find our template for our task
there's our task form and if we look up
here uh let's see let's go look for
delete so delete is just going to do
delete task and it's going to give it an
ID and I think what we're going to find
here is if we go look at our delete for
uh it's probably not in here it's
probably in our other
controller uh let's see we had hello
controller and we had what was our other
controller uh we called it
task controller there we go and so if we
go look for delete here I bet we had
here oh it's an
ID T.G project ID so what's it
complaining about let's close that uh it
says it's not readable okay
so uh let's go look here at our
task
Dao so we get a a task we look at our
regular task model let's make sure we've
got that right and we don't have some
sort of which we probably would get an
issue so if we look
here project ID yep project
ID and it's complaining that what was it
again uh it's not readable or it has an
invalid
getter does it turn the okay so let's go
look at uh get project
ID
so that should be okay so if we do get
project
ID returns a project oh it's probably
because it's
not where did I put that it's probably
the wrong
one oh yeah for some reason get does not
have a this
dot uh wow we've got that in a couple of
these so that's a nice little bug that
we we found there is that for some
reason we've got some of these that do
not
have I'm not sure why we suddenly got
this but let's just do it like
this
um we have got a whole bunch of these
that came across and did not use the
this so they're actually just returning
a local variable
instead let's see this this there's
description this name so that could
cause us all sorts of little fun
issues so let's make sure we properly
adjust that out I think we're going to
be okay in several of these
because it's going to do it by default
but just to be safe let's make sure
there we do that now if we run
it we should be able
to
uh we got to reset log
in let's pick one that has a task here
we go so let's take this task and let's
try to delete it and it still didn't
delete it so let's see what it says
now oh so now it came through so let's
go see why maybe it didn't uh this is
going to be in our task
[Music]
controller uh it's going to go in and do
a delete so let's go look at the Tas D
Dao and see why it might not have
deleted and where did we put our model
blah blah mapper you it's up here
somewhere right there it
is I'm going to take a look at our Tas
Dao if we look at
delete so that's where task ID equals
that uh let's just
do we're just going to keep it simple
here and we're going to do this so we're
going to print the
SQL and we're going to do
the
ID well except for we can't use a p
print we're just going to a regular
wh and let's make
sure uh what else did we want to look oh
let's make sure we're sending the task
IDE across for from the
[Music]
controller uh and we just come we do it
yep and then we're going to go do that
edit get project ID so let's see what
that does for
us so we're going to run
this and we're going to jump over here
we're going to
reset and we're going to go up here
we're going to try to
delete and let's see what it does in the
output oh it does nothing interesting so
we may have delete task in Let's see we
have that in two
places so we have it there did we have
it in the hello controller as
well uh where did my hello
controller we have delete
opportunity so we have delete op
interesting so let's go look
at task well not task
form
and if we go look
at uh Delete where's
delete there it is delete
task let's make sure we've got the right
d ID for our delete
task so if we inspect that element let's
make sure we're getting our values
across
properly uh delete task 23
so now if we do
that we delete
task
23 it worked so we're not getting we
weren't building it right somehow let's
go look back at that let's go look
at uh let's see
that
[Music]
should
interestingly enough it's not going
there let's see let's go look at ours a
little
bit oh I wonder if it's a uh on
click
let's do uh we can't do
that let's go look at that
again and let's go fix our
link and so we can run
it let get uh well let's actually let's
keep a look at what we were building
here uh let's see oh we can just oh uh
yeah pick one pick
one so it's going to come in and he's
going to
do location.href we may have
to okay so it's not s interestingly
enough it
[Music]
is having an
issue it's doing delete oh because it's
a button because it's a button Ah that's
problem is it's treating it as a
submit one of those fun little things
because we're in a form it's going to
see that button and it's going to try to
send it through submit instead so if we
come through
here and instead just change it to a div
everything else is the same uh it's on
yeah onclick yep that all works so now
we should be able
to come in
here log in uh pick one wh pick
one and delete
that and now we're there so there we go
that's one of those fun little things
with a
form is that if you've got a button an
actual Button as opposed to something
else it's going to try to send that
through to the submit and so that's the
process that we were we had broken so we
have our tasks now working we can do
everything with that let's take a look
at our overhead now if we immediately go
in we've got an issue here with the new
overhead so let's go take a look at uh
let's make sure first I look at that is
that some
weird uh no he's probably okay so let's
go look at that page actually we
probably have yep there we
go and we've got
uh project idea being
class it's not readable oh so we may
have this also that this issue that we
had we have in the overhead so let's go
look at our overhead real
quick and yep there we go we got a bunch
of
these so let's just walk through
this uh let's see return this
return
this return this could be one of those
things that this is because we were
working on an earlier version of java it
was not so picky about the
thises and figuring out scope so let's
go look at this real quick and see if
that fixed it to get us to creating a
new
opportunity or I'm sorry overhead okay
we still get an error let's see if it's
the same thing did we get it somewhere
else uh now it is complain yeah project
ID is not
readable uh it's probably in Ely F
thingss so let's see if it tells us
where it did that so it's probably in
the form
itself overhead form 43 so let's go look
at our overhead form
that's going to be over here line
43 uh maybe we haven't converted
everything yet uh could be 43 here field
is
that so project ID we don't have sitting
there maybe so let's go look at our task
controller for our
new
overhead
and we have here project ID load over
for head form project ID so if we go
to
load overhead
form uh oh we don't have a project
ID we have a user ID but we don't have
just a straight project ID oh do we
let's see let's let's go look at our
overhead form uh do we instead want that
to
be I think we want that to be let's say
if that's that let's see if we make it
path I think that's what we really
wanted that to be
anyways let's try that before we change
this all up cuz I think that's what we
wanted is we wanted to bring it we
didn't want to send it separate we
wanted to bring it out of the controller
itself so if we do path we're going to
pull it off of that uh the object that
we're working with if we do if we don't
like we did before if we have a field
then it's going to be looking for
something that we have sent like a
specific value we have sent in let's see
if we got something
different uh valid property project ID
okay same thing so let's go look
here
if we go look not we w't look at oh
because I didn't
save that makes a difference uh let's
see so there we go so we've got our
type that should be our
path and it is
a I
think what we want is do we want our
let's go back look at our task real
quick uh task
form it's pathed we need
[Music]
our uh here we're using value but we can
go
here oh no we are still use I'm sorry
path is the old one my mistake so we can
do th field with a star so if we come to
our
overhead that's the problem when we mix
a few things so if this is th
field star that should
work uh let's see that's going to be a
value and a field all right so we should
be
good is that right that should be
right and then we'll have to see just to
make sure we've got case
correct because if we do
that uh overhead in the model if we look
there uh let's see look at it so
get uh may we may need the capital I
think we probably need this to
be a capital
I let's try that real
quick think that's it I think it's a
case sensitivity issue
there let's reset let's get
going let's go here let's go here we got
an
error if it's not that then it
is okay so type so now we've got to go
in here we probably got type somewhere
type uh th
field so type is not readable or has an
invalid
getter
so for overhead let's go look
at
type we have set type we have oh it's
get type ID okay so we need to go back
over
here
uh this is going to be
type ID I wonder if difficulty is the
same yep difficulty is the
same and so now let's try it let's line
up our values
properly and now let's see if we can at
least get our form
up and there we go so now we're getting
into it so it's probably a good place to
pause for now we're going to come in
next episode and we're going to go ahead
and just follow through hooking up our
our buttons again sort of reinforce some
of these things I wonder if we're going
to have the same issue with casting
these values and uh we're just going to
keep chugging along if you have any
questions shoot us an email at info@
developer.com and go out there and have
yourself a great day a great week and we
will talk to you next
time