📺 Develpreneur YouTube Episode

Video + transcript

Spring Boot - Crafting links and using multiple controller files

2024-01-16 •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. This is one of those details episodes where we build out some links and flesh out some of the create or edit record features.

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 working on our sort of you
know plugging up uh con connecting out
out connecting out our application and
cleaning that up a little bit uh one
little thing I was just noticing here is
if we look we've got these things are
not in the same container so let's go
look at that real quick if we go here
there's a field
set there's a
row uh let's see there's a
row there's a field set so it's probably
that extra little div Wonder if we
delete that guy that's probably what we
want is the div around those two field
sets so let's go fix that real quick on
our form and then what we're going to do
uh first let's see see if I
go field set and I want the next one
down which is going to be this one I've
got this div somewhere ah uh oh as I've
got it's I've got a big if
there
and then it's going to go within that
diff so what we need to
do is oh I wonder why and we've got an
extra Row in there as well which we
probably don't
need so let's
first I get rid of that let's go back to
our field sets put a row between
them and then here let's just call this
a
span and see
if uh somewhere down here there we go
okay so it did update it we'll see that
looks uh because what we're going to do
now is actually we want to plug in this
so when we do an on click we're getting
a totally
broken um because it's supposed to go to
edit task which probably we don't have
that wired up yet I bet so if we
go uh edit
project there we go edit task and we
give it a number let's
see yeah yeah so we've got to hook a
couple of things up so first things uh
let's go look at that let's see if we
got our see if our display is
okay
and so if we just pick a project let's
get rid of that let's jump down here
let's log
in and let's just pick a project and
Okay so we've got those they've come up
but they're still Within
uh they're not set the same way we'll
we'll fix that display later so there's
a couple things we want to do we want to
do let's see is this going to give us
anything so new task it's not getting us
anything useful let's go look at that uh
if we look at wh let's go back here so
we've got a new task and an add overhead
item so let's go look for new task
first it is probably yep so it does new
task
submit I'm not sure why we want to do a
new task
submit uh
um I guess cuz that's a get so let's
just do
um oh it does have a project
ID well let's go look let's figure out
what this is supposed to look like so
new task and new overhead do we have
those in our hello
controller I think we had
nope let's see do we have a task at all
we do have a
task uh let's see we have
projects
and here we go we do have edit no that's
edit
project we have dashboard greet test Ops
register delete op oh Ops we've already
done because we got
that and so we do not
have we have a new p password verify
edit user okay so the next thing we're
going to do is let's go to uh let's do
our tasks first so we're going to go
back and
steal from our prior
application I believe it's here nope uh
let's see there we go Source main Java
com get our way into our
controllers we may look out
uh we do not have a oh am I in this
one I am in this project okay so that's
why it all looks
familiar let's go down here to this
one where it is
different so come in here and we're
going to go into
our uh probably in proposal
controllers and we do have a task
controller so let's go look at our task
controller we may be nice enough that we
have if you look here we have a new task
we have new overhead we have delete task
delete overhead edit task edit overhead
calc hours uh not sure why we need that
but let's wow we have like a whole bunch
of nice little things
here so we could probably take this
whole thing and use
this as a secondary
controller uh let's go ahead and do that
let's see what we can do if we can just
take our test
controller and that's going to be up
here so that we don't keep piling on to
our hello controller which
[Music]
is uh where do we put it it is not in
our
model it is not in our row
mappers it
is here we
go yeah so so what we can
do I'm hoping yep there we go so we got
our task controller this should be now
he's going to be RBS ands
demo uh do
demo and then he's not in the controller
anymore and so he should be able to take
everything
here so we're just going to take all of
these and convert these
over I think they're all going to have
the same names just moved some packages
around so as you see like this is a nice
thing about an objectoriented
design is that you can use things over
and over again granted we technically we
should be we could just like have all of
this sitting in a library somewhere that
we linked to but for here we're going to
do it uh let's see did we need a I don't
think we need the serlet HTTP serlet
request let's go look
there uh let's
see I know we have a request somewhere
in here don't
we uh we have a request
mapping uh let's see do we have just a
request yeah there we
go let's see if
these uh if we go to our task
controller and we probably don't need
him
so we got
that let's
see how close this
gets so if we try to do this let's see
if these things like connect in on
us I'm guessing they won't but hey let's
see how close we got so we go back to
our home log
in let's pick a project um actually
let's go back to
projects let's get one that's got a task
let's try to edit it
first and then it looks like it's not
building that right so if we
do okay let's go look at that first
let's fix that because what we want it
to do is we do not want it to do
a oh here we go
okay so if we do select
task I don't think we want to
do that we just want to do a sledit task
and we don't want to do an overhead we
want to do a slash edit
overhead
and let's
see and we need to do those let's try
that first we'll get those two corrected
then we'll come back and figure out this
little form thingy that it's
doing because it's doing some gits and I
don't think it
should yeah see those should
be I think for new overhead let's go
look at those real uh let's go look at
our page real quick
okay so if we come in here
and we log in and we pick one and I
think we said edit as our first one so
edit's still not working but let's see
if it's getting as closer so yes so it
does edit task and it gives us a 13 and
a
15 and we can see here oh good now we're
starting to get some errors and it is uh
template minor oh because we don't have
our templates in that makes sense so if
we come back and these are going to be
uh there's probably a couple of
them so if we jump all the way down here
we're going to have to rename some stuff
I bet you uh let's see if we go to our
web app
resources nope sorry web
INF uh views we probably need our task
form and what was the other thing we're
doing it was a
overhead uh do we have anything else
that's a task or an overhead doesn't
look like it so let's
do those two and those are going to come
over here now we're going to just rename
them and see since they're they're not
going to work exactly but hey we're
going to get close uh let's see let's
shrink that down so if we go here to our
templates then we need to take
him see if we can rename him to
just
HTML and we're going to rename
him to HTML and these guys are going to
be broken of course because we're going
to have to convert our files over again
like we've done before so now if we run
them and so let's pick one Let's do an
edit and now we're able to edit let's
see what if we do a new we're not able
to do a new uh that's because it's still
doing some funkiness in the new so let's
go back to that and try to figure out
why it's doing that we do a new uh new
task new task submit it's going to do
get element by ID new task form.
submit and it's going to get
the uh new task
form and it's going to submit a get but
let's just not do that I don't think we
need that let's just change our window
location because I
think what we probably need is Ed task
and it probably just needs to
be uh we probably need the project
ID I bet we do I bet we need the project
ID so if we do a new task submit it's
going to be for that it's going to be uh
let's see we can do that plus project
ID and if we do
that let's go see if that works if we do
a new task
for the
project I think that's what we had right
uh I had edit oh let's we want it to be
that's going to
be new
task if we go here and we give it an ID
okay so it doesn't like that so let's go
look at our let's actually look at what
we're doing instead of guess our way
through it uh let's see this is the one
that we want this is the one that we
don't want okay so this is the one we
got now so if we
do so we have headit we know edit task
is working or at least we're getting to
our form so new task uh it does have a
git and he's looking for a project ID
parameter so if we go look at
that uh let's see
so if we do new task with the project
ID um
oh oh it's
because there we go okay so it's that
easy so it's Capital project uh Capital
ID in the project that makes a lot of
sense let's go to project form and this
is just going to be new
task project ID
equals and then let's see we probably
want that what was the other one so
that's new
task and the other one was uh overhead
so we don't need this new task form
thing I don't sure why we use that at
all new overhead probably going to be
the same
thing so let's just
[Music]
do
[Music]
here
and he's going to be new
overhead and I bet we will then be ready
to jump
into next episode we're going to start
putting a couple more pages together
here if that works so let's go here
let's go back to this
wh hello there we go so if we come in
here let's just do that so if we do a
new task we are broken if we do a new
overhead oh do like that at all okay uh
new
overhead oh wait
so what do we call it new oh add
overhead oh come on where did it
go if we go down here there we go add
over oh so it's new overhead
submit new overhead submit let's see
what it says in our
task there's new
overhead project
ID it's a get so it should be new
overhead let's see if we got that
right new overhead project ID equals oh
I need to send it a project I that's
where the problem is
so for both of those I now need to go to
the new task
and so new task submit needs to be have
that project
ID so now we have to do our little th on
click
equals that
and that and
that and I think that's going to get it
and then because I think that's what we
had when we did it before when we do a
th on let's see let's go find
that uh on click yep so now we just go
down
[Music]
here and this one's going to be a
th and that's going to be do we have it
yep and that's going to be the project
ID so let's go see if those work now and
then we will be ready to dive into
actually hooking these things up so
let's go here let's log
in let's pick one so if we do
new uh new is not hitting anything add
overhead is not doing anything uh if we
go to the edits I don't think we got
this edit fixed yet oh we did so we have
the edits we do not have the news done
so let's go look at that and see if it
got the ID if we go
to uh in here
new ah so it's not taking that properly
uh what did we miss so we
did oh this one we know it's supposed to
be like
that so if we look it should be oh we
didn't close
it and that means that's overhead submit
and we need
this one probably same thing didn't
close
it now one more time let's give it a
shot see how this
works and hopefully now we will see it
come in it's the fun of being a
developer when we have these kinds of
little things luckily it's pretty quick
to go through spin through these things
so oh we already checked the edits so
that's good check our task new task nice
ugly form new overhead there we go so so
now we got to we can plug these suckers
in and that's what we're going to do
next time is we'll go ahead and get
those things connected in and we're
getting pretty darn close to being able
to click on all our stuff uh this was
one there's this little thing that I'm
not sure this does anything useful uh
let's
see I think it doesn't yeah I think it
was supposed to add something
there oh it does okay so it is just
adding that stuff in so all right
cool uh there we go and that'll wrap
this one up sorry if we went a tad long
uh but next time around like I said
we're going to continue putting these
things together we are slowly building
out a you know moderately useful
application we'll do some more cleanup
some additional stuff next time and just
keep chugging along as always shoot us
an email at info@ develop order.com if
you have any questions otherwise go out
there and have yourself a great day a
great week and we will talk to you next
time
[Music]
time
Transcript Segments
1.35

[Music]

27.24

well hello and welcome back we are

29.519

continuing working on our sort of you

31.759

know plugging up uh con connecting out

34.28

out connecting out our application and

37.48

cleaning that up a little bit uh one

39.32

little thing I was just noticing here is

41.2

if we look we've got these things are

42.879

not in the same container so let's go

44.719

look at that real quick if we go here

46.52

there's a field

47.76

set there's a

50.559

row uh let's see there's a

55.16

row there's a field set so it's probably

57.68

that extra little div Wonder if we

60.28

delete that guy that's probably what we

62.68

want is the div around those two field

64.28

sets so let's go fix that real quick on

66.04

our form and then what we're going to do

68.799

uh first let's see see if I

72.28

go field set and I want the next one

76.159

down which is going to be this one I've

78.92

got this div somewhere ah uh oh as I've

84.72

got it's I've got a big if

88.84

there

91.159

and then it's going to go within that

93.159

diff so what we need to

95.92

do is oh I wonder why and we've got an

99

extra Row in there as well which we

101.119

probably don't

102.6

need so let's

105.92

first I get rid of that let's go back to

108.28

our field sets put a row between

111.88

them and then here let's just call this

115.52

a

116.52

span and see

118.84

if uh somewhere down here there we go

122.439

okay so it did update it we'll see that

124.439

looks uh because what we're going to do

125.92

now is actually we want to plug in this

128.84

so when we do an on click we're getting

131.599

a totally

133.36

broken um because it's supposed to go to

135.599

edit task which probably we don't have

138.239

that wired up yet I bet so if we

141.48

go uh edit

144.48

project there we go edit task and we

146.959

give it a number let's

148.599

see yeah yeah so we've got to hook a

151.519

couple of things up so first things uh

155.16

let's go look at that let's see if we

156.56

got our see if our display is

161.599

okay

164.48

and so if we just pick a project let's

167.72

get rid of that let's jump down here

170.56

let's log

173.56

in and let's just pick a project and

176.8

Okay so we've got those they've come up

178.4

but they're still Within

180.36

uh they're not set the same way we'll

182.12

we'll fix that display later so there's

184.08

a couple things we want to do we want to

185.64

do let's see is this going to give us

187.12

anything so new task it's not getting us

189.56

anything useful let's go look at that uh

191.56

if we look at wh let's go back here so

194.28

we've got a new task and an add overhead

196.08

item so let's go look for new task

198.72

first it is probably yep so it does new

202.2

task

204.879

submit I'm not sure why we want to do a

207.319

new task

208.56

submit uh

212.36

um I guess cuz that's a get so let's

215.28

just do

217.72

um oh it does have a project

222.319

ID well let's go look let's figure out

225.08

what this is supposed to look like so

226.599

new task and new overhead do we have

228.519

those in our hello

231.12

controller I think we had

236.68

nope let's see do we have a task at all

239.68

we do have a

241.959

task uh let's see we have

246.48

projects

249.519

and here we go we do have edit no that's

252.159

edit

253.519

project we have dashboard greet test Ops

257.799

register delete op oh Ops we've already

261.199

done because we got

264.08

that and so we do not

267.96

have we have a new p password verify

270.639

edit user okay so the next thing we're

273.52

going to do is let's go to uh let's do

277.039

our tasks first so we're going to go

279.96

back and

281.96

steal from our prior

285.32

application I believe it's here nope uh

289.199

let's see there we go Source main Java

293.88

com get our way into our

296.96

controllers we may look out

301.36

uh we do not have a oh am I in this

306.039

one I am in this project okay so that's

309.56

why it all looks

312.08

familiar let's go down here to this

315.32

one where it is

318.52

different so come in here and we're

320.919

going to go into

323.319

our uh probably in proposal

326.759

controllers and we do have a task

328.759

controller so let's go look at our task

331.319

controller we may be nice enough that we

333.72

have if you look here we have a new task

336.24

we have new overhead we have delete task

338.28

delete overhead edit task edit overhead

341.12

calc hours uh not sure why we need that

343.759

but let's wow we have like a whole bunch

345.88

of nice little things

349.319

here so we could probably take this

352.319

whole thing and use

355.4

this as a secondary

358.479

controller uh let's go ahead and do that

361.6

let's see what we can do if we can just

363.24

take our test

364.6

controller and that's going to be up

366.919

here so that we don't keep piling on to

369.479

our hello controller which

371.65

[Music]

372.72

is uh where do we put it it is not in

377.12

our

378.24

model it is not in our row

382.639

mappers it

384.96

is here we

387.919

go yeah so so what we can

391.44

do I'm hoping yep there we go so we got

394.319

our task controller this should be now

398.16

he's going to be RBS ands

402.319

demo uh do

405.919

demo and then he's not in the controller

410.44

anymore and so he should be able to take

414.24

everything

418.4

here so we're just going to take all of

421.12

these and convert these

425.72

over I think they're all going to have

427.879

the same names just moved some packages

430.16

around so as you see like this is a nice

432.12

thing about an objectoriented

434.199

design is that you can use things over

438.639

and over again granted we technically we

441.479

should be we could just like have all of

443.16

this sitting in a library somewhere that

444.479

we linked to but for here we're going to

446.319

do it uh let's see did we need a I don't

449.16

think we need the serlet HTTP serlet

452.08

request let's go look

454.759

there uh let's

457.24

see I know we have a request somewhere

459.479

in here don't

460.72

we uh we have a request

463.84

mapping uh let's see do we have just a

466.36

request yeah there we

468.919

go let's see if

471.639

these uh if we go to our task

474.879

controller and we probably don't need

478.319

him

480.28

so we got

485.479

that let's

487.28

see how close this

490.199

gets so if we try to do this let's see

493.96

if these things like connect in on

496.08

us I'm guessing they won't but hey let's

498.639

see how close we got so we go back to

500.72

our home log

503.96

in let's pick a project um actually

507.96

let's go back to

510.8

projects let's get one that's got a task

513.12

let's try to edit it

515.959

first and then it looks like it's not

518.64

building that right so if we

523.08

do okay let's go look at that first

525.48

let's fix that because what we want it

527.2

to do is we do not want it to do

536.399

a oh here we go

540.48

okay so if we do select

543.76

task I don't think we want to

549.519

do that we just want to do a sledit task

553.399

and we don't want to do an overhead we

554.88

want to do a slash edit

559.92

overhead

567.76

and let's

570.56

see and we need to do those let's try

572.959

that first we'll get those two corrected

574.68

then we'll come back and figure out this

575.959

little form thingy that it's

579.279

doing because it's doing some gits and I

581.92

don't think it

584.44

should yeah see those should

588.68

be I think for new overhead let's go

591

look at those real uh let's go look at

592.92

our page real quick

596

okay so if we come in here

599.959

and we log in and we pick one and I

602.399

think we said edit as our first one so

605.04

edit's still not working but let's see

606.56

if it's getting as closer so yes so it

608.079

does edit task and it gives us a 13 and

609.88

a

611.44

15 and we can see here oh good now we're

614.24

starting to get some errors and it is uh

617.6

template minor oh because we don't have

619.68

our templates in that makes sense so if

621.36

we come back and these are going to be

624.079

uh there's probably a couple of

625.64

them so if we jump all the way down here

629.8

we're going to have to rename some stuff

631.32

I bet you uh let's see if we go to our

634.44

web app

636.519

resources nope sorry web

639.32

INF uh views we probably need our task

643.959

form and what was the other thing we're

646.24

doing it was a

648.88

overhead uh do we have anything else

650.92

that's a task or an overhead doesn't

652.8

look like it so let's

655.24

do those two and those are going to come

657.639

over here now we're going to just rename

659.68

them and see since they're they're not

662.399

going to work exactly but hey we're

665.04

going to get close uh let's see let's

667.959

shrink that down so if we go here to our

671.12

templates then we need to take

674.24

him see if we can rename him to

677.8

just

680.48

HTML and we're going to rename

685.16

him to HTML and these guys are going to

687.8

be broken of course because we're going

690

to have to convert our files over again

692.44

like we've done before so now if we run

698.56

them and so let's pick one Let's do an

703.04

edit and now we're able to edit let's

706.079

see what if we do a new we're not able

708.16

to do a new uh that's because it's still

711.6

doing some funkiness in the new so let's

713.44

go back to that and try to figure out

716.399

why it's doing that we do a new uh new

721.639

task new task submit it's going to do

724.32

get element by ID new task form.

727.12

submit and it's going to get

730.76

the uh new task

733.48

form and it's going to submit a get but

736.279

let's just not do that I don't think we

738.04

need that let's just change our window

743.16

location because I

746.079

think what we probably need is Ed task

749.279

and it probably just needs to

752.279

be uh we probably need the project

758.079

ID I bet we do I bet we need the project

764.24

ID so if we do a new task submit it's

767.16

going to be for that it's going to be uh

770.199

let's see we can do that plus project

774.56

ID and if we do

777.399

that let's go see if that works if we do

780.44

a new task

782.76

for the

786.12

project I think that's what we had right

790.12

uh I had edit oh let's we want it to be

793.92

that's going to

795.12

be new

798.36

task if we go here and we give it an ID

802.959

okay so it doesn't like that so let's go

804.279

look at our let's actually look at what

806.44

we're doing instead of guess our way

807.959

through it uh let's see this is the one

812.24

that we want this is the one that we

814.8

don't want okay so this is the one we

816.8

got now so if we

818.68

do so we have headit we know edit task

821.48

is working or at least we're getting to

824.04

our form so new task uh it does have a

828.839

git and he's looking for a project ID

832.279

parameter so if we go look at

836.44

that uh let's see

840.32

so if we do new task with the project

846.639

ID um

852.759

oh oh it's

860.279

because there we go okay so it's that

863.199

easy so it's Capital project uh Capital

865.68

ID in the project that makes a lot of

868

sense let's go to project form and this

870.68

is just going to be new

872.72

task project ID

876.32

equals and then let's see we probably

879.44

want that what was the other one so

880.68

that's new

882.24

task and the other one was uh overhead

885.8

so we don't need this new task form

887.36

thing I don't sure why we use that at

888.44

all new overhead probably going to be

890.32

the same

891.72

thing so let's just

893.44

[Music]

894.56

do

895.69

[Music]

897.68

here

900.24

and he's going to be new

903.8

overhead and I bet we will then be ready

906.48

to jump

909.44

into next episode we're going to start

911.72

putting a couple more pages together

913.399

here if that works so let's go here

916.88

let's go back to this

921.16

wh hello there we go so if we come in

924.56

here let's just do that so if we do a

926.16

new task we are broken if we do a new

931.36

overhead oh do like that at all okay uh

935.519

new

938.8

overhead oh wait

945.959

so what do we call it new oh add

954.279

overhead oh come on where did it

957.6

go if we go down here there we go add

961.04

over oh so it's new overhead

965.12

submit new overhead submit let's see

967.68

what it says in our

969.959

task there's new

972.399

overhead project

975.959

ID it's a get so it should be new

978.319

overhead let's see if we got that

981.92

right new overhead project ID equals oh

985.44

I need to send it a project I that's

987.279

where the problem is

989.92

so for both of those I now need to go to

993.12

the new task

994.839

and so new task submit needs to be have

998.6

that project

1002.16

ID so now we have to do our little th on

1006.04

click

1007.72

equals that

1010.88

and that and

1015.8

that and I think that's going to get it

1019.519

and then because I think that's what we

1021.16

had when we did it before when we do a

1022.88

th on let's see let's go find

1028.16

that uh on click yep so now we just go

1032.48

down

1033.25

[Music]

1034.48

here and this one's going to be a

1039

th and that's going to be do we have it

1041.48

yep and that's going to be the project

1042.64

ID so let's go see if those work now and

1045.679

then we will be ready to dive into

1049.08

actually hooking these things up so

1050.84

let's go here let's log

1055.28

in let's pick one so if we do

1059.48

new uh new is not hitting anything add

1062.52

overhead is not doing anything uh if we

1065.44

go to the edits I don't think we got

1067.48

this edit fixed yet oh we did so we have

1069.679

the edits we do not have the news done

1072.28

so let's go look at that and see if it

1074.2

got the ID if we go

1077.4

to uh in here

1080.799

new ah so it's not taking that properly

1085.28

uh what did we miss so we

1088.64

did oh this one we know it's supposed to

1092.64

be like

1098.4

that so if we look it should be oh we

1102.08

didn't close

1104.6

it and that means that's overhead submit

1107.72

and we need

1109.12

this one probably same thing didn't

1110.76

close

1112.559

it now one more time let's give it a

1116.6

shot see how this

1118.44

works and hopefully now we will see it

1121.44

come in it's the fun of being a

1123.96

developer when we have these kinds of

1125.48

little things luckily it's pretty quick

1127.559

to go through spin through these things

1129.76

so oh we already checked the edits so

1132.2

that's good check our task new task nice

1135.28

ugly form new overhead there we go so so

1138.4

now we got to we can plug these suckers

1139.96

in and that's what we're going to do

1141.76

next time is we'll go ahead and get

1142.84

those things connected in and we're

1144.6

getting pretty darn close to being able

1147.919

to click on all our stuff uh this was

1149.679

one there's this little thing that I'm

1152.32

not sure this does anything useful uh

1155.08

let's

1157.159

see I think it doesn't yeah I think it

1159.72

was supposed to add something

1162.919

there oh it does okay so it is just

1166.32

adding that stuff in so all right

1168.84

cool uh there we go and that'll wrap

1173.559

this one up sorry if we went a tad long

1177.44

uh but next time around like I said

1179

we're going to continue putting these

1179.96

things together we are slowly building

1181.64

out a you know moderately useful

1183.799

application we'll do some more cleanup

1185.32

some additional stuff next time and just

1187.4

keep chugging along as always shoot us

1189.159

an email at info@ develop order.com if

1191.28

you have any questions otherwise go out

1193.72

there and have yourself a great day a

1195.159

great week and we will talk to you next

1198.039

time

1200.31

[Music]

1214.039

time