📺 Develpreneur YouTube Episode

Video + transcript

Spring Boot - ThymeLeaf Options

2024-01-23 •Youtube

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 revisit options in this episode as we look at some more complex ways to grab values. 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 looking at our application
conversion and we're going to jump back
into we're working on a couple different
field um form entries here and focus on
some drop downs again so let's just make
sure we're pretty solid on those give
you some more examples because this type
this difficulty and if we go over to uh
an opport Unity or an overhead I believe
yeah it's got a type and a difficulty as
well so these are going to be pretty
easy for us to uh you know basically
replicate and what we're going to do is
let's go back to our project form
because we've got a real nice copy and
paste we can do for our
select uh let's see if we go
here there we go so we've got a select
in our options and we're going to do
that for both of these so let's go look
at our task form first and we've got two
things working with we've got type and
difficulty so let's look at our type now
this one's note that we've got an
onchange here so we're actually calling
stuff based on this so we're going to
keep the onchange and that's a
straight you know normal on change
events we don't have to do anything
special with that uh we do want this to
be uh the field that it's going to be
coming from is going to be
type and that's what we're getting From
the Path and the items are in the type
list and we have an
ID is the
value and
name is essentially the the label that
we're going to see so if we take
that that should take care of our um
type I don't know if we have that in our
we probably don't in our overhead form
so if we look over here in our overhead
form which we still have a couple things
we got to clean out we've got a lot of
these form inputs uh type does have
calcal oh interesting enough so we
should be able to take the same thing
it's coming from type type list oh
excellent so it should be almost
identical did we get the form we did not
get the form yet so let's go ahead and
do that while we're at it let's get our
form straightened
out uh if we go in
here I need to make sure I get that
spelled right
and let's see so let's go over to
overhead form let's get our form fixed
and it's going to be save
overhead and it is going to come from
overhead and here we go overhead instead
of
task overhead if I can spell it
right and I don't need that piece so it
gives us something oh we don't need all
these form hiddden uh this is going to
be input type equals hidden so let's
just do
that and we know that our path is
actually uh what did we call that that
was going to be
the uh th
field I believe so we'll see that again
actually we probably see take that stuff
from the top of the task form it has an
ID a project ID so I think that's
exactly what we have user ID project ID
overhead same thing so hey so we can
just look at that we like rocking and
rolling okay so I got a little bit
sidetracked on that so let's go look at
our task form the other one we need to
do in our
selects is our so we got our type
done we take the same thing and now
we're going to do it for difficulty
difficulty oh look it has the Cal hours
as well so we don't have to change that
and it's basically the field is
difficulty instead of type list oh I'm
sorry uh oh yeah so that's type the
difficulty is our type difficulty list
is our
list well difficulty I guess is our our
value and then it is an ID and a name so
we should be good so we now should be
able
to take that and I bet we're pretty darn
close on our our task let's go ahead and
do that with our difficulty real quick
so I think it's going to be the exact
same and yep if you look at it it comes
for difficulty lit so it's exactly the
same here that makes stuff a little bit
easier so now let's run this and let's
see what we
got so when we run
it if we do a new task it's interesting
doesn't have that that was a bug from
last time so here we've got our types
we've got our difficulties uh doesn't
display super well we're going to have
to work on that a little bit uh I wonder
why let's go look at our layouts real
quick and oh we're using
a so he's a six a two a two and a
two that's cuz he just rolls over too
much so we can make him a five and a
three let's do that this is on task so
let's go to our task form and let's just
change that real quick so let's change
that shorten up the name and extend the
type and this could be partial because
of the wrong thing if I because I may
have my view yeah so if I shrink my view
down then depends on where you're at
sometimes it works sometimes it doesn't
but
anyways we now have all of our pieces
let's go look at this let's just do a
test uh this is a
test let's see if we try to do a SA or
update what does it
do
uh there we go
um we'll do this we'll just make one
instance just because hours worked we'll
make that uh
2.0 hours estimated oh because it
probably doesn't have a
cost
[Music]
um
trival trivial
there don't need that little thing
that's bothering me oh probably because
it's a it's probably looking some stuff
up based on that oh it is because it's
based on the the type let's see if we
try to save it's probably going to give
us an error because of the not a
number uh yeah not a number so what we
need to do is we need to figure out this
Cal hours because it has issues so if we
go to calc
hours uh let's see it's probably missing
a
value oh here it is it's because it's
doing this
get I wonder if it's that simple uh it
may be all we need to do for it uh while
we're here let's look at the
Save oh save is just the form so we
should be
good let's see what
happens so now
if we run it oh and that means we're
going to have to change that on overhead
so might as well get it on our overhead
form as well so this oh that one's
actually interestingly enough that one
probably is going to work uh task form
did we get that Cal hours okay let's go
check it out so if we come in here we'll
try to send I don't know if it's going
to care because it's going to make me
log
in come in here let's add a task this is
call it task one one
instance uh environment setup we'll call
it that difficult simple oh look see so
our hours estimate is coming
in oh I see so that's just so we haven't
worked any yet but let's just say uh
this is a
test save or
update now it did not come across error
because here it did not save so while it
came came in it didn't actually save the
data and we're probably going to see uh
index negative one out of bounds for
length 17 so we've got something here
let's see if it'll give us where that
actually
happened uh let see let's jump all the
way to top of our little stack trace and
by little I mean extremely huge uh typ
list task. tap type number one
template project form 170 okay so let's
go look at that oh
interesting
um type one so it's probably blowing up
here oh so maybe it did save
something there we go out of bounds
[Music]
precondition let's see so now we got to
dig up here this will be
fun uh there it is Project form there it
doesn't like it so there's a task. type
minus1 and well let's look at project
form 150 let's see if this helps us out
I'm sorry not 150
170 so if we go
here oh so this
is
I wonder
if it's going to give us
that
probably this may be something that
we're doing that's going to give us some
issues because it's trying to do
something out of our
list
so what we're going to try to do is
we're going to try to get this out of a
mapping so this will be sort of
interesting let's
see so it's blowing up on trying to list
the
task which is why we're seeing an error
but at least it's somewhat going so
let's go play with that so this may be
something we're going to have to tackle
as
well is so so I bet we're going to see
if we go here yep blew up yep give us an
issue cannot
render
because so what we need to do here is
what we want to do is
[Music]
probably
this
um we're going to see if that's going to
give it to us uh it's not going to be a
get so it probably be this let's see not
sure that's actually going to allow us
to get that but let's take a shot at it
real quick so if we do this um yeah
let's try
it I don't think it's going to work I
think we're have to come back because
it's a map and we're going to have to do
it based on
a so we come and do this and it still
give us the same thing so we need to to
do is we need to go figure out how do
I oh it's index minus one for like so
yeah so see it's trying to get in
here so it probably needs to be that git
of some
sort and it's probably
because I wonder if we can just do it as
simple as that it's probably going to
give us one off but let's
see
um except
it's
uh so that's for each
task and that we really want is
the yeah let's see what it does let's
see what it gives us I don't think it's
going to do it I think what we're going
to have to do is we're going to have to
go figure out how how to grab a map
value which would be a fun little thing
to add to this oh there we go okay so it
is coming across here uh Tas
name did I make it average I think I had
it simple yeah so it's off by
one
so
that's part of its problem is if I look
here
if I look at my options yeah so 1 two 3
four
five
but so he's simple but if I go back and
I look here he
is g to be average and so he's bringing
the wrong
piece interestingly enough
trivia
works I wonder if it gave us an error it
did not give us an
error huh
so that's interesting so if I come into
here so we did save a couple of these so
if I come in and make this uh
simple then he moves to average if I
move him
to complex does he die nope then he just
is he's not able to
be uh he's not able to display so he
just blows up on that one if I do hard
it's going to say it's complex there we
go so what I need to
do interesting thing that we got it this
way so let's go to this one and let's
see if we delete this task does that
give us something nope it doesn't so
delete yeah it does not so delete is
probably giving us an error we got a
couple of things here to fix in this
next round uh index five out of bounds
for only five oh so so we probably
probably got it off by one so first
thing we're going to do is we're going
to try to figure
out this little thing about displaying
our you our proper type and name because
I think in our
type yeah because these were actually
environment setup they were not database
tables so we've got to fix those too
both of those we've got things that were
um not working right so we're going to
see if we can get a little bit
of math going on in here and see what we
can do with that and then uh we'll just
sort of try to get this fixed and then
get our delete and keep on going so go
out there and have yourself a great day
a great week and we will talk to you
next
[Music]
time
Transcript Segments
0

[Music]

6.799

well hello and welcome back we are

9.44

continuing looking at our application

11.48

conversion and we're going to jump back

13.4

into we're working on a couple different

15.759

field um form entries here and focus on

19.359

some drop downs again so let's just make

21.359

sure we're pretty solid on those give

23.039

you some more examples because this type

25.199

this difficulty and if we go over to uh

29.519

an opport Unity or an overhead I believe

31.92

yeah it's got a type and a difficulty as

33.48

well so these are going to be pretty

34.64

easy for us to uh you know basically

37.76

replicate and what we're going to do is

40.48

let's go back to our project form

42.76

because we've got a real nice copy and

44.76

paste we can do for our

46.68

select uh let's see if we go

51.359

here there we go so we've got a select

53.48

in our options and we're going to do

55.76

that for both of these so let's go look

57.44

at our task form first and we've got two

60.359

things working with we've got type and

61.92

difficulty so let's look at our type now

65.799

this one's note that we've got an

67.68

onchange here so we're actually calling

69.439

stuff based on this so we're going to

71.64

keep the onchange and that's a

76.2

straight you know normal on change

78.84

events we don't have to do anything

80

special with that uh we do want this to

83.119

be uh the field that it's going to be

85

coming from is going to be

88.119

type and that's what we're getting From

90.04

the Path and the items are in the type

95.079

list and we have an

97.399

ID is the

100.6

value and

102.52

name is essentially the the label that

106.28

we're going to see so if we take

108.399

that that should take care of our um

112.84

type I don't know if we have that in our

115.68

we probably don't in our overhead form

117.719

so if we look over here in our overhead

120

form which we still have a couple things

121.399

we got to clean out we've got a lot of

123.479

these form inputs uh type does have

126.6

calcal oh interesting enough so we

129.72

should be able to take the same thing

131.72

it's coming from type type list oh

134.92

excellent so it should be almost

136.84

identical did we get the form we did not

138.84

get the form yet so let's go ahead and

140.28

do that while we're at it let's get our

141.84

form straightened

143.44

out uh if we go in

146.4

here I need to make sure I get that

148.56

spelled right

151.48

and let's see so let's go over to

153.16

overhead form let's get our form fixed

155.48

and it's going to be save

159.959

overhead and it is going to come from

162.84

overhead and here we go overhead instead

165.84

of

169.72

task overhead if I can spell it

173.8

right and I don't need that piece so it

176.879

gives us something oh we don't need all

178.159

these form hiddden uh this is going to

180

be input type equals hidden so let's

181.64

just do

188.12

that and we know that our path is

191

actually uh what did we call that that

193.56

was going to be

195.239

the uh th

199.12

field I believe so we'll see that again

202.799

actually we probably see take that stuff

204.44

from the top of the task form it has an

207.44

ID a project ID so I think that's

209.959

exactly what we have user ID project ID

212.72

overhead same thing so hey so we can

216.159

just look at that we like rocking and

219.36

rolling okay so I got a little bit

220.959

sidetracked on that so let's go look at

222.239

our task form the other one we need to

223.799

do in our

225.28

selects is our so we got our type

228.56

done we take the same thing and now

230.56

we're going to do it for difficulty

232.239

difficulty oh look it has the Cal hours

234.319

as well so we don't have to change that

237.56

and it's basically the field is

240.36

difficulty instead of type list oh I'm

244.68

sorry uh oh yeah so that's type the

249.48

difficulty is our type difficulty list

252.72

is our

256.079

list well difficulty I guess is our our

258.56

value and then it is an ID and a name so

261.68

we should be good so we now should be

263.84

able

264.84

to take that and I bet we're pretty darn

268.56

close on our our task let's go ahead and

271.88

do that with our difficulty real quick

273.68

so I think it's going to be the exact

275.36

same and yep if you look at it it comes

279.16

for difficulty lit so it's exactly the

280.88

same here that makes stuff a little bit

284.039

easier so now let's run this and let's

287.96

see what we

291.4

got so when we run

295.52

it if we do a new task it's interesting

299.56

doesn't have that that was a bug from

301.199

last time so here we've got our types

303.479

we've got our difficulties uh doesn't

305.56

display super well we're going to have

306.88

to work on that a little bit uh I wonder

309.44

why let's go look at our layouts real

312.96

quick and oh we're using

318.639

a so he's a six a two a two and a

323.88

two that's cuz he just rolls over too

326.36

much so we can make him a five and a

329.039

three let's do that this is on task so

332.68

let's go to our task form and let's just

335.52

change that real quick so let's change

336.88

that shorten up the name and extend the

341.36

type and this could be partial because

346.08

of the wrong thing if I because I may

348.639

have my view yeah so if I shrink my view

352.44

down then depends on where you're at

354.039

sometimes it works sometimes it doesn't

356.44

but

357.68

anyways we now have all of our pieces

360.24

let's go look at this let's just do a

362.4

test uh this is a

365.52

test let's see if we try to do a SA or

367.8

update what does it

369.12

do

370.68

uh there we go

373.52

um we'll do this we'll just make one

376

instance just because hours worked we'll

377.8

make that uh

380.199

2.0 hours estimated oh because it

382.639

probably doesn't have a

384.759

cost

385.85

[Music]

388.4

um

390.28

trival trivial

392.759

there don't need that little thing

394.68

that's bothering me oh probably because

396.24

it's a it's probably looking some stuff

397.8

up based on that oh it is because it's

399.4

based on the the type let's see if we

401.56

try to save it's probably going to give

403.88

us an error because of the not a

409.72

number uh yeah not a number so what we

412.639

need to do is we need to figure out this

413.8

Cal hours because it has issues so if we

416.759

go to calc

418.12

hours uh let's see it's probably missing

421.319

a

423.44

value oh here it is it's because it's

425.96

doing this

429.24

get I wonder if it's that simple uh it

433.68

may be all we need to do for it uh while

437.52

we're here let's look at the

439.24

Save oh save is just the form so we

441.919

should be

443.479

good let's see what

447.12

happens so now

449.919

if we run it oh and that means we're

451.44

going to have to change that on overhead

452.68

so might as well get it on our overhead

454

form as well so this oh that one's

457.56

actually interestingly enough that one

460.08

probably is going to work uh task form

463.479

did we get that Cal hours okay let's go

466.56

check it out so if we come in here we'll

469.319

try to send I don't know if it's going

470.479

to care because it's going to make me

472

log

473.84

in come in here let's add a task this is

479.36

call it task one one

482.159

instance uh environment setup we'll call

484.479

it that difficult simple oh look see so

487.639

our hours estimate is coming

492.319

in oh I see so that's just so we haven't

495

worked any yet but let's just say uh

498.36

this is a

501.52

test save or

503.8

update now it did not come across error

506.4

because here it did not save so while it

509

came came in it didn't actually save the

511.08

data and we're probably going to see uh

513.8

index negative one out of bounds for

515.88

length 17 so we've got something here

519

let's see if it'll give us where that

520.519

actually

523.039

happened uh let see let's jump all the

525.12

way to top of our little stack trace and

526.92

by little I mean extremely huge uh typ

529.88

list task. tap type number one

534.24

template project form 170 okay so let's

537.04

go look at that oh

539.72

interesting

543.88

um type one so it's probably blowing up

549.839

here oh so maybe it did save

552.68

something there we go out of bounds

555.91

[Music]

559.04

precondition let's see so now we got to

561.64

dig up here this will be

565.32

fun uh there it is Project form there it

569.2

doesn't like it so there's a task. type

574.839

minus1 and well let's look at project

577.64

form 150 let's see if this helps us out

581

I'm sorry not 150

583

170 so if we go

593.04

here oh so this

598.12

is

602.24

I wonder

603.44

if it's going to give us

611.44

that

618.44

probably this may be something that

620.32

we're doing that's going to give us some

622.12

issues because it's trying to do

624.12

something out of our

628.04

list

630.24

so what we're going to try to do is

631.32

we're going to try to get this out of a

632.48

mapping so this will be sort of

634.399

interesting let's

638.88

see so it's blowing up on trying to list

642.44

the

643.68

task which is why we're seeing an error

647.079

but at least it's somewhat going so

648.36

let's go play with that so this may be

649.76

something we're going to have to tackle

650.959

as

657.32

well is so so I bet we're going to see

659.8

if we go here yep blew up yep give us an

662.76

issue cannot

665.68

render

668.48

because so what we need to do here is

671.519

what we want to do is

674.54

[Music]

676.2

probably

681.959

this

684.079

um we're going to see if that's going to

686.44

give it to us uh it's not going to be a

688.72

get so it probably be this let's see not

693.24

sure that's actually going to allow us

694.44

to get that but let's take a shot at it

696.36

real quick so if we do this um yeah

700.079

let's try

703.48

it I don't think it's going to work I

705.32

think we're have to come back because

706.32

it's a map and we're going to have to do

708.72

it based on

713.639

a so we come and do this and it still

717.56

give us the same thing so we need to to

719.12

do is we need to go figure out how do

723.079

I oh it's index minus one for like so

726.839

yeah so see it's trying to get in

729.16

here so it probably needs to be that git

732.68

of some

737.48

sort and it's probably

741.279

because I wonder if we can just do it as

743.399

simple as that it's probably going to

746.24

give us one off but let's

747.88

see

754.199

um except

756.88

it's

762

uh so that's for each

767.519

task and that we really want is

771.959

the yeah let's see what it does let's

774.199

see what it gives us I don't think it's

776.48

going to do it I think what we're going

777.32

to have to do is we're going to have to

778.32

go figure out how how to grab a map

782.88

value which would be a fun little thing

784.32

to add to this oh there we go okay so it

786.48

is coming across here uh Tas

790.519

name did I make it average I think I had

793.88

it simple yeah so it's off by

796.639

one

798.199

so

801.6

that's part of its problem is if I look

807.76

here

814.76

if I look at my options yeah so 1 two 3

817.72

four

818.68

five

822.12

but so he's simple but if I go back and

825.36

I look here he

828.76

is g to be average and so he's bringing

833.16

the wrong

835.959

piece interestingly enough

839.56

trivia

842

works I wonder if it gave us an error it

844.24

did not give us an

846.519

error huh

849.839

so that's interesting so if I come into

852.48

here so we did save a couple of these so

855.04

if I come in and make this uh

858.36

simple then he moves to average if I

861.839

move him

862.959

to complex does he die nope then he just

867.56

is he's not able to

870.12

be uh he's not able to display so he

873.199

just blows up on that one if I do hard

874.959

it's going to say it's complex there we

877.32

go so what I need to

879.959

do interesting thing that we got it this

882.399

way so let's go to this one and let's

883.759

see if we delete this task does that

885.199

give us something nope it doesn't so

887.48

delete yeah it does not so delete is

889.959

probably giving us an error we got a

891.759

couple of things here to fix in this

894.8

next round uh index five out of bounds

897.88

for only five oh so so we probably

900.16

probably got it off by one so first

901.8

thing we're going to do is we're going

903.199

to try to figure

904.88

out this little thing about displaying

909.12

our you our proper type and name because

913.16

I think in our

914.48

type yeah because these were actually

916.68

environment setup they were not database

918.399

tables so we've got to fix those too

919.92

both of those we've got things that were

923.04

um not working right so we're going to

924.6

see if we can get a little bit

926.8

of math going on in here and see what we

931.72

can do with that and then uh we'll just

934.16

sort of try to get this fixed and then

935.88

get our delete and keep on going so go

938.399

out there and have yourself a great day

940.24

a great week and we will talk to you

943.72

next

946.52

[Music]

957.6

time