📺 Develpreneur YouTube Episode

Video + transcript

Spring Boot - Forms/Submit Part 2

2024-02-01 •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 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 of converting our
application last time around we got our
overhead item page actually displaying
ran through a couple little uh variable
issues now let's see if we can actually
do anything with it let's see where
we're at because we probably have got a
couple buttons to connect up and um you
know some things of that nature so let's
just do um it's going to be test item
one and let's go take a look at it it's
going to be documentation it's going to
be average uh it's generating values for
that's pretty good and we're just going
to say uh wh doesn't look is it oh
description is not readable so there's
first thing we've got is that's not
let's try to do a save and update uh it
does
but uh oh type was right documentation
average did we get that right let's go
back see see if our cancel works it does
so we're in pretty good shape let's go
back and what we're going to want to do
is we need to figure out how we do our
oh two
things yeah CU it's not bringing across
our name it's not populating that uh it
is populating these this probably needs
to get
calculated uh so that it's actually
doing that we'll have to see let's see
is that based off of
yeah it's based off of a change or
something like that so okay so we got a
couple things to work on let's start
with uh let's look at our description
and notes field on our overhead
form so if we go down there description
notes uh oh it's doing its
path so that was still grabbing a
path and it's not going to be formed
text area it is going to
be uh input type
equals text
area no just text always forget which is
which with these so we're going to do
that uh it's a form control description
we've got
that let's look at our name uh name is
also see it's the same thing we've got
that so it should
be uh it should be a th field I believe
is what we want
actually so th
field I wonder if we have that here so
if we've got ours
estimated uh we don't really have to
worry about that I don't know if that's
coming in that's interesting so since
it's read only we may have to may not
have to worry about it we will find out
in a minute uh let's see th field th
field that's a
path and so that's that's good our
indexes were looking pretty good let's
go fix our delete real quick if we have
one because we had that before yeah
delete this item okay so first we got to
get fix our
path and we want this to be a div if you
remember if it's a button it's going to
process through the form submit we don't
really want to do it in this case we're
just going to we've just got this one
wired up to be an on click instead of
doing some sort of a
submit and
let's give this a shot and see what
happened wh did I just no save that and
let's see if we've got our page
working and as you see that's a nice
thing about I objectoriented and so many
other things is once you get going
there's a lot of similarities and we can
get going pretty quick oh I have an
issue here so something it's either type
name or something like that uh name is
not valid
okay so wh and it's going to tell me
it's in overhead form line 60 that was
very nice of it so we can go to line
60 and oh just because I did
not properly do
that let's see is there anywhere else
that I have th field th field I probably
did I do that down here yes I
did so let's make sure we're grabbing
this right that one would would have
been a problem let's see if we go look
here yep
uh oh this needs to be a th on click I
think to make sure that we get its value
right so let's go run that and see if
these look
right so
now jumping in
here here we go uh oops well we can just
just add one let's do this let's walk
through the whole thing so let's add is
going to be item one and let's make him
uh that's a build he's going to be
trivial and this is just going to be
test text one if we
save he's there and so we're going to
add another one and he's going to be uh
project
management
complex item to I wonder if these are
not calculating right that's interesting
maybe that we missed something there so
this is just be test text
two project management complex project
management
complex oh it's because we don't have
any uh that's what it is is we need
probably like an overall let's create a
task this is just going to be uh task
one uh let's do 10 in instances of
building a page we probably have
somewhere in here like
a uh here we go screen
page uh for
UI that's going to be
average uh so we estimate 20
hours we're just going to call this a
placeholder and now if we do it here and
now you can see it's actually cuz these
are based off of we didn't really go
into this but these calculations are
based off of Total
oh so let's go in here and let's change
the text and let's see if uh if we leave
it if this if it still does our
calculations it does it didn't change
that and so now let's uh delete item two
uh let's cancel yep that comes back and
let's try to delete it and it blew up
probably because let's look at what it
was trying to do it did delete overhead
and it didn't bring the value right
so let's go look at that form
uh I wonder if that was supposed oh uh
that maybe is supposed to be a star
let's go check because we've done it
before let's go look over at our uh our
other for task form where we did delete
Ah that's right because it's that's what
we want is we want to do it with the
brackets otherwise it doesn't like that
overhead form that's so let's keep him
clean we'll do with that semicolon just
cuz because sometimes JavaScript likes
that now that's our delete so now if we
run
it and
reset so we've got the oh let's go back
to that other one uh we don't have a
cancel here interesting okay uh but
we'll go take this one and we're going
to delete
that and it did delete so now we've got
this working uh if we go back to our
let's do save update if we come back now
save update is actually going to our
projects instead of the current project
so let's fix that when we do oh that was
here I'm sorry that's project
Administration so if we go to a
task we can cancel if we go here it just
goes back to our list of projects so
that's okay so we're getting pretty
close uh we've got like a we can go to a
project we can click on it we can create
a new task we can cancel we can add an
overhead we can cancel let's try delete
delete probably shouldn't work yep so
let's say
delete let's go ahead and fix that one
let's fix that little bug real quick so
we're going to conditionally
display that
delete and we're going to say
here uh let's do
uh no this is going to be uh it's going
to be
style I
believe uh actually I think we can just
do here we can just do hidden
uh what am I looking at this is the
overhead form so let's start with that
uh actually let's just do it here if I
take a task and I change this to Hidden
I'm pretty
sure one of those nice little things
um and then
hidden uh oh it
doesn't H it didn't accept it live so
okay so we're going to conditionally do
it so first to hide that button cuz we
don't want to you know which that's the
easiest way to do it so we're on
overhead form so let's go look at
that and if we come
here and log
in and let's just pick one overhead
should not have delete it does not so
that's what we want and what we want
here is this just going to be our little
if so we're going to do our little
thf and what we want is on
the
delete uh let's see we want to do
actually we can do it this way I
guess we can actually just wrap that
whole thing so we don't even have to
that doesn't need to
be
we could make it a hidden but I think we
can just as easily do it
here and this is going to be uh it's
going be project ID no uh
ID is greater than
zero then it will display otherwise it
will not let's see did we get that right
not quite so okay like that
so this is
on let's do that on both of these that's
overhead let's go ahead and get our task
form and just knock that out at the same
time like
that there we go let's just run those
two and see what
happens we could wrap stuff around that
hidden but it's like hey why not make it
a div and let's see what that does for
us uh let's do this
here let's do this
here and so now when we do a new there
we go and if we do an edit it is there
now the interesting thing is because we
did it within the div now we have that
in a different div um so we've got a
couple things we can do we
probably let's see if we can do we're
going to do one more thing and we're
going to do within this uh let's see I
think we
had let's see how do we want to do this
let's see if we can do
that uh I'm not sure if we can do that
within oh we did before because we do it
with the drop down so we do it with uh
if we go back to our project
form
is we can do this is I think we can
do let's do th hidden and let's see what
happens let's see if that's going to
give it so if we do that here and
instead we do
within this
one and let's do
th
hidden and it's going to be based B off
of ID greater than
zero and it's either going to be
nothing or it's going to be
hidden and let's see what that does oops
let's do this
here so we do need it because if we do a
div then it sort of throws off our
display we could do we can work with
that but let's do it this way so uh test
form and now let's run over here and by
run I mean we'll change gears to this
page Log In what did I say task form so
if we do task form in
general he is gone and if I do a new
task he is gone so in either
case it's probably because it's going to
be so this is the created a task if we
go down in here create a
task
form
uh wrong one oh I want it here this
row a
[Music]
container so see he is hidden equals
hidden hidden equals false I wonder if
we can do
that
nope so we're going to have to do
something a little bit fun key here
let's oh let's do it this way instead of
a
div uh let's go back and let's just make
it uh wait where was
it there let's make it a
span and then we don't have to worry
about it so we're going to cheat that
way but it was worth taking a look at it
uh if I go to overhead
form go over here because a div is going
to give me sometimes a different section
span's going to say hey I'm in line so
it shouldn't mess us
up and let's see if we can do that so we
got a couple little lessons we've
learned here theoretically okay there
delete that task if it's new we can't
delete the task so now we've gotten
pretty far into this we've got all our
buttons working we've taken a couple
exceptions let's see what project report
does it blows up and so that is where
we're going to start next episode we're
going to get that one going going
probably going to have some nice little
query things to work with and a couple
little uh you know styling kind of
things much as we've dealt with there so
we you we looked at the difference again
we've seen this before difference
between span and Dev we have connected
up some of our things make sure that
we're properly using our fields and
accessing them you know timely versus
just a maybe a regular value or
something like that making sure we get
our uh case sensitivity correct and uh
we'll just come back next time and keep
going so until then go out there and
have yourself a great day a great week
and we will talk to you next
[Music]
time
Transcript Segments
0.64

[Music]

6.52

well hello and welcome back we are

9.719

continuing our journey of converting our

11.88

application last time around we got our

14.559

overhead item page actually displaying

17.72

ran through a couple little uh variable

19.439

issues now let's see if we can actually

21.199

do anything with it let's see where

22.84

we're at because we probably have got a

24.68

couple buttons to connect up and um you

27.76

know some things of that nature so let's

29.16

just do um it's going to be test item

32.52

one and let's go take a look at it it's

34.76

going to be documentation it's going to

36.32

be average uh it's generating values for

39.399

that's pretty good and we're just going

40.52

to say uh wh doesn't look is it oh

46.079

description is not readable so there's

48.84

first thing we've got is that's not

50.559

let's try to do a save and update uh it

52.719

does

54.52

but uh oh type was right documentation

58.039

average did we get that right let's go

59.559

back see see if our cancel works it does

63.039

so we're in pretty good shape let's go

65.479

back and what we're going to want to do

66.84

is we need to figure out how we do our

70.119

oh two

72.4

things yeah CU it's not bringing across

74.72

our name it's not populating that uh it

77.759

is populating these this probably needs

80.119

to get

83.6

calculated uh so that it's actually

85.479

doing that we'll have to see let's see

88.04

is that based off of

94.28

yeah it's based off of a change or

95.68

something like that so okay so we got a

97.2

couple things to work on let's start

98.88

with uh let's look at our description

101.84

and notes field on our overhead

105.92

form so if we go down there description

109.88

notes uh oh it's doing its

113.56

path so that was still grabbing a

117.039

path and it's not going to be formed

119.32

text area it is going to

122.24

be uh input type

127.319

equals text

130.56

area no just text always forget which is

134

which with these so we're going to do

135.64

that uh it's a form control description

138.72

we've got

139.959

that let's look at our name uh name is

144.239

also see it's the same thing we've got

146

that so it should

147.64

be uh it should be a th field I believe

150.36

is what we want

151.72

actually so th

154.76

field I wonder if we have that here so

157.04

if we've got ours

160.519

estimated uh we don't really have to

162.64

worry about that I don't know if that's

165.36

coming in that's interesting so since

166.68

it's read only we may have to may not

168.239

have to worry about it we will find out

170.72

in a minute uh let's see th field th

174

field that's a

178.04

path and so that's that's good our

181.08

indexes were looking pretty good let's

182.56

go fix our delete real quick if we have

185.879

one because we had that before yeah

188.72

delete this item okay so first we got to

191.4

get fix our

193.36

path and we want this to be a div if you

197.08

remember if it's a button it's going to

198.84

process through the form submit we don't

200.64

really want to do it in this case we're

201.84

just going to we've just got this one

204.08

wired up to be an on click instead of

205.76

doing some sort of a

208.12

submit and

210.239

let's give this a shot and see what

212.68

happened wh did I just no save that and

216.72

let's see if we've got our page

222.48

working and as you see that's a nice

224.76

thing about I objectoriented and so many

228.4

other things is once you get going

230.28

there's a lot of similarities and we can

232.439

get going pretty quick oh I have an

233.959

issue here so something it's either type

236.36

name or something like that uh name is

239.159

not valid

241.319

okay so wh and it's going to tell me

244.439

it's in overhead form line 60 that was

246.439

very nice of it so we can go to line

250.36

60 and oh just because I did

255.959

not properly do

258.359

that let's see is there anywhere else

260.68

that I have th field th field I probably

265.08

did I do that down here yes I

267.759

did so let's make sure we're grabbing

271.52

this right that one would would have

273.759

been a problem let's see if we go look

275.68

here yep

278.96

uh oh this needs to be a th on click I

282.52

think to make sure that we get its value

285.44

right so let's go run that and see if

287.759

these look

290.72

right so

292.96

now jumping in

296.479

here here we go uh oops well we can just

299.6

just add one let's do this let's walk

300.759

through the whole thing so let's add is

302.44

going to be item one and let's make him

307.28

uh that's a build he's going to be

309.8

trivial and this is just going to be

312.32

test text one if we

316.039

save he's there and so we're going to

319.28

add another one and he's going to be uh

323.08

project

324.319

management

328

complex item to I wonder if these are

330.919

not calculating right that's interesting

333.8

maybe that we missed something there so

335.28

this is just be test text

338.4

two project management complex project

341.639

management

345.919

complex oh it's because we don't have

347.96

any uh that's what it is is we need

350.08

probably like an overall let's create a

352.8

task this is just going to be uh task

357.44

one uh let's do 10 in instances of

361.4

building a page we probably have

364.16

somewhere in here like

366.52

a uh here we go screen

370.199

page uh for

372.12

UI that's going to be

374.639

average uh so we estimate 20

377.44

hours we're just going to call this a

379.56

placeholder and now if we do it here and

383.08

now you can see it's actually cuz these

384.599

are based off of we didn't really go

386.68

into this but these calculations are

388.4

based off of Total

390.36

oh so let's go in here and let's change

391.68

the text and let's see if uh if we leave

394.68

it if this if it still does our

396.16

calculations it does it didn't change

398.84

that and so now let's uh delete item two

403.36

uh let's cancel yep that comes back and

405.52

let's try to delete it and it blew up

408.8

probably because let's look at what it

410.12

was trying to do it did delete overhead

412.08

and it didn't bring the value right

415.96

so let's go look at that form

420.879

uh I wonder if that was supposed oh uh

425.199

that maybe is supposed to be a star

426.599

let's go check because we've done it

428.12

before let's go look over at our uh our

431.319

other for task form where we did delete

434.879

Ah that's right because it's that's what

436.8

we want is we want to do it with the

439.08

brackets otherwise it doesn't like that

441.36

overhead form that's so let's keep him

444.879

clean we'll do with that semicolon just

448.319

cuz because sometimes JavaScript likes

451.879

that now that's our delete so now if we

453.84

run

460.24

it and

464.36

reset so we've got the oh let's go back

467.479

to that other one uh we don't have a

469.319

cancel here interesting okay uh but

471.919

we'll go take this one and we're going

474.12

to delete

475.319

that and it did delete so now we've got

479.879

this working uh if we go back to our

483.4

let's do save update if we come back now

486.479

save update is actually going to our

488

projects instead of the current project

489.84

so let's fix that when we do oh that was

493.44

here I'm sorry that's project

494.4

Administration so if we go to a

496.44

task we can cancel if we go here it just

500.56

goes back to our list of projects so

502.08

that's okay so we're getting pretty

504

close uh we've got like a we can go to a

506.8

project we can click on it we can create

509.479

a new task we can cancel we can add an

512.719

overhead we can cancel let's try delete

515.8

delete probably shouldn't work yep so

518.959

let's say

521.039

delete let's go ahead and fix that one

523.36

let's fix that little bug real quick so

526

we're going to conditionally

527.959

display that

530.08

delete and we're going to say

536.72

here uh let's do

542.44

uh no this is going to be uh it's going

544.2

to be

545.48

style I

564.079

believe uh actually I think we can just

566.32

do here we can just do hidden

570.279

uh what am I looking at this is the

571.279

overhead form so let's start with that

574.24

uh actually let's just do it here if I

577.12

take a task and I change this to Hidden

581.64

I'm pretty

582.6

sure one of those nice little things

588.24

um and then

594.32

hidden uh oh it

597.24

doesn't H it didn't accept it live so

602.6

okay so we're going to conditionally do

604.519

it so first to hide that button cuz we

606.24

don't want to you know which that's the

607.959

easiest way to do it so we're on

609.32

overhead form so let's go look at

614.279

that and if we come

616.72

here and log

619.8

in and let's just pick one overhead

623.079

should not have delete it does not so

625.68

that's what we want and what we want

627.6

here is this just going to be our little

629.839

if so we're going to do our little

635.36

thf and what we want is on

640.72

the

644.6

delete uh let's see we want to do

648.959

actually we can do it this way I

651.839

guess we can actually just wrap that

654.399

whole thing so we don't even have to

656.279

that doesn't need to

658.04

be

661.36

we could make it a hidden but I think we

663.12

can just as easily do it

666.12

here and this is going to be uh it's

669.32

going be project ID no uh

674.959

ID is greater than

679.68

zero then it will display otherwise it

683

will not let's see did we get that right

686.04

not quite so okay like that

689.56

so this is

691.12

on let's do that on both of these that's

693.48

overhead let's go ahead and get our task

694.88

form and just knock that out at the same

701.8

time like

705.12

that there we go let's just run those

707.6

two and see what

711.56

happens we could wrap stuff around that

713.88

hidden but it's like hey why not make it

715.88

a div and let's see what that does for

717.519

us uh let's do this

720

here let's do this

722.399

here and so now when we do a new there

725.76

we go and if we do an edit it is there

729.36

now the interesting thing is because we

730.6

did it within the div now we have that

733.16

in a different div um so we've got a

736.079

couple things we can do we

741.12

probably let's see if we can do we're

743.8

going to do one more thing and we're

746.04

going to do within this uh let's see I

748.44

think we

754.32

had let's see how do we want to do this

756.76

let's see if we can do

762.12

that uh I'm not sure if we can do that

765.199

within oh we did before because we do it

767.72

with the drop down so we do it with uh

770.8

if we go back to our project

777.839

form

779.399

is we can do this is I think we can

786.399

do let's do th hidden and let's see what

789.399

happens let's see if that's going to

791.24

give it so if we do that here and

794.32

instead we do

796.8

within this

800.6

one and let's do

803.36

th

806.639

hidden and it's going to be based B off

810.8

of ID greater than

813.399

zero and it's either going to be

817.12

nothing or it's going to be

822.88

hidden and let's see what that does oops

825.32

let's do this

827.88

here so we do need it because if we do a

830.24

div then it sort of throws off our

831.48

display we could do we can work with

833.199

that but let's do it this way so uh test

835.639

form and now let's run over here and by

839.44

run I mean we'll change gears to this

841.92

page Log In what did I say task form so

845.839

if we do task form in

849.12

general he is gone and if I do a new

852.12

task he is gone so in either

856.68

case it's probably because it's going to

859.88

be so this is the created a task if we

863.759

go down in here create a

865.759

task

867.68

form

872.639

uh wrong one oh I want it here this

877.44

row a

879.18

[Music]

886.279

container so see he is hidden equals

888.68

hidden hidden equals false I wonder if

891.72

we can do

893.399

that

895.279

nope so we're going to have to do

897.44

something a little bit fun key here

899.24

let's oh let's do it this way instead of

901.48

a

902.32

div uh let's go back and let's just make

907.04

it uh wait where was

910.6

it there let's make it a

914

span and then we don't have to worry

915.92

about it so we're going to cheat that

917.519

way but it was worth taking a look at it

920

uh if I go to overhead

921.759

form go over here because a div is going

924.16

to give me sometimes a different section

926

span's going to say hey I'm in line so

929.12

it shouldn't mess us

934.68

up and let's see if we can do that so we

938.44

got a couple little lessons we've

939.68

learned here theoretically okay there

942.12

delete that task if it's new we can't

945.56

delete the task so now we've gotten

948.399

pretty far into this we've got all our

949.519

buttons working we've taken a couple

951.279

exceptions let's see what project report

953.36

does it blows up and so that is where

956.48

we're going to start next episode we're

957.88

going to get that one going going

959.16

probably going to have some nice little

960.16

query things to work with and a couple

962.399

little uh you know styling kind of

964.079

things much as we've dealt with there so

966.04

we you we looked at the difference again

968.24

we've seen this before difference

969.399

between span and Dev we have connected

972.44

up some of our things make sure that

973.759

we're properly using our fields and

976.24

accessing them you know timely versus

978.68

just a maybe a regular value or

980.72

something like that making sure we get

982.56

our uh case sensitivity correct and uh

985.759

we'll just come back next time and keep

986.959

going so until then go out there and

988.36

have yourself a great day a great week

990.92

and we will talk to you next

995.5

[Music]

1009.24

time