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 and this episode focuses on a little of the Thymeleaf logic and using values from the database to populate a select dropdown.
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 just chugging along putting together an application and spring boot uh using time leaf and bootstrap and uh this time around we're going to we're just going to continue in this uh form that we're working on we have uh got our projects listing going pretty straightforward not a whole lot there we got that all working out we got some filtering and now we're clicking on a project and going to look at some stuff like for example none of these things have value so let's go into our our project and we're going to see why that's not happening so if we look here we can see that we've got this form input path and we don't have any value because what it was doing before is it was trying to do a path equals name which is essentially a value so if we instead do let's try this if we do th value equals and then it's probably be dollar name we're just going to give that a shot and let's see what that looks like so if we save that we restart it and we spin around here to here oh it's going to make us log in again and we got nothing so it's not coming up here so if we look here so what we want is oh oh it's because this is doing so this is all using the form from uh an old style which I don't think I even have forms here yep I don't even have form set up in here anymore um this is and it's not form as in a form uh that you would normally see but it was actually if you see here it is a form input so it's actually trying to take a tag and doing something so let's leave the class uh form control and we're going to do input so actually what we're going to have it's it is a uh an input in time Leaf however like most things and it looks about the same the difference is going to be here it is going to be a th field and then that looks good so we're going to do that so it's going to be a th field instead and we can do that here let's do a couple of these uh our class form control has already been defined so that's not we're looking back path is actually th field and so now let's take oh I need to do this let's get that guy fixed and then let's take a look at this and see if these now start giving us some values and we do that again sort of going with this Tim Leaf stuff you can I mean you can Google it or you can also sort of guess your way into things because it it's fairly sort of standard in how it does stuff and so now it doesn't like that because probably have a typo or I skipped something oh here we go uh neither binding forward being name so let's go look at anything let's try this if we do that not super intuitive but let's just go do that and see what it says then log in Pick It N doesn't like that either so what we're running into here is that we have oh we might have been fine okay so let's try this first uh let's go back to we do our form uh oh I wonder if we set it up as let's go look at our hello controller if we come into uh let's see that is the filter load project [Music] form which is probably the one we've got let's see there we go edit project does project form form so then he brings in here so he's got his model is going to be there test BL blah where did it go so there is oh it's going to be project it's probably what we need so if we go back up to here so actually what we want to do is we come up here and let me fix this first uh because that was where I was throwing getting thrown off so here we had before it was model attribute was uh project which is our value that we're sending across this is actually going to be guess what a and it's going to be an object and then that should work and then if we take that now to show that we're going to deal with that object now we do our little asterisk and let's just do these two first and I bet we're going to see this because now that's been passed across it's going to say hey grab it off of the uh form project oops which excuse me that is not a form form that is just a form and we want it to be oh because it's a Tim Lea one though we need it to be th action and that should do it let's see oh no won't because that has to be dollar project sorry again so now if we run this and we log in and we select a project oh we still got a problem so what did we miss this time oh I don't want to Pop That that class file up I want to do I wonder if I got project right uh let's see oh could not parse as expression save project oh because I don't need that as a th action I just need that as an actual action otherwise I could do uh we haven't really let's see the other thing I could do is set it as let's do it like this first we'll come back to that at another point uh where did I go name there we go so uh restart it we'll do with the th action at another point so now if we come in don't need that do need that and there so now we see our values coming in so let's code to get the rest of these turned in and turned on and it's again it's pretty much everywhere I've got a form input before then all I need to do is that path is going to be th field and I need to do my asterisk and my bra squirly brackets and that should do it so if I look everywhere that I find see like this is going to be a form select he's instead going to be just a select that path is going to be th field that's going to be a star items we're sending the sight list in so let's see how oh that actually may already look um no it doesn't oh so right now we don't have that drop down so let's see so this is actually going to be I wonder if that's going to be th items is probably what we want so let's try that uh form input no he's just an input with a path that is th field we're going to asterisk K input select see we get a lot of stuff in here so that's class let's just do it like that that's the path close it and then here we had a select path and close it now here I believe we have a th if I have to go back and check this because I may have forgotten that and now these are not going to be an option so those are so this is all being based off of this value so we should be good did we have an F up here I think we did oh yeah we did so we had a thf right there so if we go back and look here um so thf equals uh let's see let's do let's just try this and that's going to be a div and that's going to be a th if equals this will be a neat little one to look up if it doesn't work this way and we don't need the end of a form select because it's a regular select uh let's go ahead and go here uh let's see we don't really need our format uh we'll come back to that come back to that because we're going to clean those up at some point uh let's do this and that is the uh what do we call th field yep and then we got that oh except for it's not a dollar it's a star asterisk and items let's try th items and let's see what that does let's just go with oh let's do this one here uh path equals that and that gets us let's see if we got description prior descriptions okay and we can go ahead and do that oh we have both there that's a problem uh there we go we don't want both all right let's try that for now that's a lot of changes it's probably not going to work and then we will run through it oh actually I want we've got a broken tag in there somewhere too probably yep like right there we've got that thing thing that's right after prior descriptions which is right here uh that's it I think we want just that there's descriptions there's a row there we go this THS should be a div yeah we got some stuff to fix in there okay so let's do a look at this so now we have site which has no values we have status which has no values stick fixed bid is coming through bid amount agent cost um earnings and agent C oh those are the ones that we did not put the values in so two things let's go look at this so first we have oh so we've got select and then we have this th items is equal to site list so that most likely is incorrect so what we want here is so that select is okay but what we want to do instead is we need to create within that uh options and with the option let's close uh let's see we going do it like this and what it does is we can do a th each and this is going to be this one gets a little bit different because the way we do this one is we're going to have AP uh what did we call call this uh site list and then that is the each so each P or we'll just say item we'll just do H we'll keep it now let's do item so for each item we're going to come in and the th value I get it right yep is equal to uh dollar I and then the th text is equal to we'll do dollar I but what we really want is within this I think the label is think that's going be i. name let's go look at that so if we go look at our site list here let me go back here so site list is site list and that site list comes from da project Doo get site list and we're going to pull him Dao project Dao let's go with that uh site list the right one uh get status L okay select star from look up job sites so we need to go look up job sites and see what that looks like and that's going to be uh we go that from our R mapper which is here uh that's going to be our site rer and so it's going to be so we've got a site ID I assume that's what we want is it'll probably a site ID and name so let's go back over here to our project form uh that's going to be probably do site ID and let's see what that gives us now that also means that we're going to have to come to what was the other one we had another one in here see that was uh status site oh status is the other one so let's go look at that where did we have status that is down here so let's just take basically the same structure and here he's going to be uh th field status the items is actually status list so we're going to take that that's going to be status list and if we look at status list real quick it's probably going to be oh we don't have it here so if we go look to project Dao does it have the status list it does so it's just going to be uh a letter and a value so let's see if we just do uh here that's status so let's do let's just do I and I and see how that works so if we run that and we load this up then we come here oh we got a problem because it probably doesn't like that uh let's see property cannot be found okay so it doesn't have a site ID well let's just try an i and see what it does uh cannot be found oh on compound object of site so oh so if we go look at our model for site oh it is I ID so it is just ID and I'm going to asse this lowercase and let's see what it does and now when we come across got that and now we do have there we have sites and see we have these so we can can see what our status is probably want to have uh because this is a combo name we would probably want to clean this up but we will tackle that at another point because we've gone a tad long on this one so we're just going to continue on next episode we're going to continue uh chugging our way through these things get a couple of them cleaned up notice that we're now getting like a lot of our values are coming in and it's going to be a matter of doing some things like make sure that this thing gets loaded and we're going to get down here and clean up some of these others so we're just going to continue chugging along this time we looked at like building a a couple of things we looked at building our options for our select and we've also got a couple values that we're showing uh for example this one that's uh based on some ifs so that being said well let's get back to it have a great day a great week we will talk to you next [Music] time
Transcript Segments
[Music]
well hello and welcome back we are
continuing just chugging along putting
together an application and spring boot
uh using time leaf and bootstrap and uh
this time around we're going to we're
just going to continue in this uh form
that we're working on we have uh got our
projects listing going pretty
straightforward not a whole lot there we
got that all working out we got some
filtering and now we're clicking on a
project and going to look at some stuff
like for example none of these things
have value so let's go into our our
project and we're going to see why
that's not happening so if we look here
we can see that we've got this form
input
path and we don't have any value because
what it was doing before is it was
trying to do a path equals name which is
essentially a value so if we instead do
let's try this if we do th value
equals and then it's probably be dollar
name we're just going to give that a
shot and let's see what that looks like
so if we save that we restart
it and we spin around here to here oh
it's going to make us log in
again and we got nothing so it's not
coming up here
so if we look here so what we want is oh
oh it's because this is doing so this is
all using the form from uh an old style
which I don't think I even have forms
here yep I don't even have form set up
in here anymore um this is and it's not
form as in a form uh that you would
normally see but it was actually if you
see here it is a form input so it's
actually trying to take a tag and doing
something so
let's leave the class uh form control
and we're going to do input so actually
what we're going to have it's it is a uh
an input in time Leaf however like most
things and it looks about the same the
difference is going to be here it is
going to be a th
field and then that looks good so we're
going to do that so it's going to be a
th field
instead and we can do that here let's do
a couple of
these
uh our class form control has already
been defined so that's not we're looking
back path is actually th
field and so now let's take oh I need to
do
this let's get that guy fixed and then
let's take a look at this and see if
these now start giving us some
values and we do that again sort of
going with this Tim Leaf stuff you can I
mean you can Google it or you can also
sort of guess your way into things
because it
it's fairly sort of standard in how it
does
stuff and so now it doesn't like that
because probably have a typo or I
skipped
something oh here we go uh neither
binding forward being name
so let's go
look at anything let's try
this if we do that
not super intuitive but let's just go do
that and see what it says
then log
in Pick It N doesn't like that either so
what we're running into here is that we
have
oh we might have been fine okay so let's
try this first uh let's go back to we do
our
form
uh
oh I wonder if we set it up as let's go
look at our hello
controller if we come
into uh let's see that is the filter
load project
[Music]
form which is probably the one we've got
let's
see there we go edit project does
project form
form so then he brings in here so he's
got his model is going to be
there test BL blah where did it go so
there
is oh it's going to be project it's
probably what we
need so if we go back up to
here so actually what we want to do is
we come up
here and let me fix this first uh
because that was where I was throwing
getting thrown off so here we had before
it was model attribute was uh project
which is our value that we're sending
across this is actually going to be
guess what
a and it's going to be an
object and then that should work and
then if we take that now to show that
we're going to deal with that object now
we do our little asterisk and let's just
do these two first and I bet we're going
to see this because now that's been
passed across it's going to say hey grab
it off of the uh form
project oops which excuse me that is not
a form form that is just a
form and we want it to be oh because
it's a Tim Lea one though we need it to
be th
action
and that should do it let's
see oh no won't because that has to be
dollar project sorry
again so now if we run
this and we log in and we select a
project oh we still got a problem so
what did we miss this time oh I don't
want to Pop That that class file up I
want to
do I wonder if I got project right uh
let's see oh could not parse as
expression save project oh because I
don't need that as a th
action I just need that as an actual
action otherwise I could do uh we
haven't really let's see the other thing
I could do is set it as let's do it like
this first we'll come back to that at
another
point
uh where did I go name there we go so uh
restart
it we'll do with the th action at
another
point so now if we come in don't need
that do need
that and there so now we see our values
coming in so let's code to get the rest
of these turned in and turned on and
it's again it's pretty much everywhere
I've got a form input before then all I
need to do is that path is going to be
th
field and I need to do my
asterisk and my bra squirly
brackets and that should do it so if I
look everywhere that I
find see like this is going to be a form
select he's instead going to be just a
select
that path is going to be th
field that's going to be a
star items we're sending the sight list
in so let's see how oh that actually may
already look um no it doesn't oh so
right now we don't have that drop down
so let's see so this is actually going
to be I wonder if that's going to be th
items is probably what we want so let's
try that
uh form input no he's just an input with
a
path that is th
field we're going to asterisk
K input select see we get a lot of stuff
in here so that's
class let's just do it like
that that's the path close it
and then here we had a
select path and close
it now here I believe we have a th
if I have to go back and check this
because I may have forgotten
that
and now these are not going to be an
option so those are so this is all being
based off of this value so we should be
good did we have an F up here I think we
did oh yeah we did so we had a thf right
there so if we go back and look here
um
so thf
equals uh let's see let's
do let's just try
this and that's going to be a div and
that's going to be a th if
equals this will be a neat little one to
look
up if it doesn't work this
way and we don't need the end of a form
select because it's a regular
select uh let's go ahead and go
here uh let's see we don't really need
our format uh we'll come back to that
come back to that because we're going to
clean those up at some
point uh let's do
this and that is
the uh what do we call th field
yep and then we got that oh except for
it's not a dollar it's a star
asterisk and items let's try th
items and let's see what that does let's
just go with oh let's do this one
here
uh path
equals
that and that gets us let's see if we
got
description prior descriptions okay
and we can go ahead and do
that oh we have both there that's a
problem
uh there we go we don't want
both all right let's try that for now
that's a lot of changes it's probably
not going to
work and then we will run through
it oh actually I want we've got a broken
tag in there somewhere too probably yep
like right there we've got that thing
thing that's right after prior
descriptions which is right
here
uh that's
it I think we want just
that there's descriptions there's a
row
there we go this THS should be a
div yeah we got some stuff to fix in
there okay so let's do a look at this so
now we have site which has no values we
have status which has no values stick
fixed bid is coming through bid amount
agent
cost um earnings and agent C oh those
are the ones that we did not put the
values
in so two things let's go look at this
so first we
have oh so we've got select and then we
have this th items is equal to site list
so that most likely is
incorrect so what we want here is so
that
select is
okay but what we want to do
instead is we need to create within that
uh options
and with the
option let's close uh let's see we going
do it like this and what it does is we
can do a th
each and this is going to
be this one gets a little bit different
because the way we do this one is we're
going to have
AP uh what did we call call this uh site
list and
then that is the
each so each P or we'll just say item
we'll just do H we'll keep it now let's
do item so for each
item we're going to come in and the th
value I get it right yep is equal to
uh dollar
I and then the th
text is equal to we'll do dollar
I but what we really want is within this
I think the label
is think that's going be i. name
let's go look at that so if we go look
at our site list here let me go back
here so site list is site list and that
site list comes from da project Doo get
site
list and we're going to pull
him
Dao project
Dao
let's go with that uh site
list the right one
uh get status L okay select star from
look up job sites so we need to go look
up job
sites and see what that looks like and
that's going to be uh we go that from
our R
mapper which is
here uh that's going to be our site
rer and so it's going to be so we've got
a site ID I assume that's what we want
is it'll probably a site ID and name so
let's go back over here to our project
form uh that's going to be probably do
site
ID and let's see what that gives us now
that also means that we're going to have
to come to what was the other one we had
another one in here see that was uh
status site oh status is the other one
so let's go look at
that where did we have status that is
down here so let's just take basically
the same
structure and here he's going to be uh
th field
status the items is actually status
list so we're going to take
that that's going to be status list
and if we look at status list real quick
it's probably going to be oh we don't
have it here so if we go look to project
Dao does it have the status list it does
so it's just going to be uh a letter and
a value so let's see if we just
do
uh here that's status so let's do let's
just do I
and I and see how that works so if we
run
that and we load this
up then we come here oh we got a problem
because it probably doesn't like
that uh let's see property cannot be
found okay so it doesn't have a site
ID
well let's just try an i and see what it
does uh cannot be found oh on compound
object
of
site so oh so if we go look at our
model for
site oh it is
I
ID so it is
just ID and I'm going to asse this
lowercase and let's see what it
does and now when we come
across got that and now we do have there
we have sites and see we have these so
we can can see what our status is
probably want to have uh because this is
a combo name we would probably want to
clean this up but we will tackle that at
another point because we've gone a tad
long on this one so we're just going to
continue on next episode we're going to
continue uh chugging our way through
these things get a couple of them
cleaned up notice that we're now getting
like a lot of our values are coming in
and it's going to be a matter of doing
some things like make sure that this
thing gets loaded and we're going to get
down here and clean up some of these
others so we're just going to continue
chugging along this time we looked at
like building a a couple of things we
looked at building our options for our
select and we've also got a couple
values that we're showing uh for example
this one that's uh based on some ifs so
that being said well let's get back to
it have a great day a great week we will
talk to you next
[Music]
time