📺 Develpreneur YouTube Episode

Video + transcript

Spring Boot - Redirecting Flow

2024-01-11 •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 continue form entry and log at what to do once we save our data.

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 doing our application
conversion moving from an old Apache tom
cat into a spiffy new spring boot uh
bootstrap five time Leaf all that good
stuff last episode we're working our way
through a form getting that data across
entering it saving it doing updates all
that kind of good stuff well we ended up
hitting a little bit of a snag and it
really had to do with dealing with uh
generating some of the the calculations
on the Fly probably not something you do
too
often and it does turn out to be a bit
of a pain to make sure that you get all
of your uh types correct so we're going
to do instead of what we were you know
trying to do it all on the Fly we're
going to all pull this stuff out and
we're going to pull this into our U Back
out so it's just going to be sent as
values into our form
so here we have project cost is already
there but we're going to take this
thing
and that's basically going to become our
earnings and so if we go back here we're
going to have an earnings and we're
going to have an agent cost so if we go
back to our
controller uh we'll just put that there
for now and we're going to create a
couple of
objects and it's going to
be this is going to be our we'll call it
our agent
cost and our
earnings
and we don't have those already so we
can pull those what we're going to do is
simply enough is we're going to come in
here and this guy is going to
become
earnings and we can take a look back
here make sure that we get that that
generated properly so earnings is going
to be this now here we've got let's see
project cost do we already have project
cost here we have that somewhere oh here
we go project
cost so here we actually are going to
have to go ahead
and let's do it this way we're going to
do uh we'll create a we'll just create a
project
cost and I think that's going to be a
double and we'll start at equal
z0
and so here instead of doing this add
object in all these
places we don't need to worry about it
here because project cost is going to be
Zero by
default so we're going come back here we
do project cost whoops don't need that
else and it's going to be uh we get with
the capital
c wh I need to spell it
right
and let's do it this way make sure we
get it copied and pasted right whoa not
sure what I just
did uh let's do
this do that okay so then we're going to
need here this just means project cost
equals that and
here
new project cost
equals that whole thing oh and there's
where our problem is is at our cost we
were actually adding all of those things
together
so actually this alone might fix our
problems uh let's go check that real
quick uh let's see project. agent
percent I think we had project set up
here yep we have project so we could do
it like that
oh except for it's going to have to be
get agent
percent uh I believe it's like that
project get agent percent
yep so let's try that because now we've
got the earnings there but we have not
pulled across yet
our uh agent cost so let's see if we
still have this blow
up which goes back to this is this is
why we got to make sure we oh I have an
error somewhere so let's go back it's
probably in the hello oh did I yes I did
was going to say probably had something
I didn't get
things oh project cost already
exists where did it oh here it is
Calculate cost
okay
oh interesting so I already
did project cost equals Calculate cost
oh this may be something where we did
something stupid so let's
go uh back to what we
had so project
cost oh so it is two different okay so
we're going to change
that
and we're going to make this let's see
this is Calculate
cost this one's going to
be uh oh we need to make it so we'll
just do
it uh this will
be total
cost and we'll just make that total cost
everywhere else here
so he's going to be equal to that he's
going to be equal to
that and we're going to shove him
here and oh this is going to
be project
okay let's see how this runs
I think that was what ended up happening
is we had one of our values not work we
were creating a string when we shouldn't
have been so if we come in
here and we go look boom now we finally
got it coming across our earnings and
our agent cost are coming here uh bit
amount uh earnings is based off of what
that's probably based off
of oh because it's t based off of our
calc Calculate cost which is I bet based
off of tasks so if we
go oh we probably have a nice little
complicated thing here project Dao
Calculate
cost uh and so there's hours estimated
and hours adjusted so we would have to
actually get it and that's from tasks so
we would have to within here we have no
task so uh see looks like we've got most
of our stuff coming up our ear earnings
on our agent cost is a little bit wonky
so let's go look at that on our form
real quick do a quick fix
there uh let's see oh it's because he's
an
md2 let's see how do we want to change
that around
um let's go ahead
and not sure why we put those together
the way we
did
we could do one more was that 2 4 6 8 10
12 so we probably would need
to tweak that a little bit let's do
status and stack that up on site
instead and take the that
one is that going to work
uh yeah I think that whole thing and and
then that's going to go here and we're
going to take our
status we're going to push that up by
our
site let's just see how that looks we
may want to clean it up a little bit but
that probably gives us a good
start so now let's go look and let's
actually look at one that maybe has
something since we've got a value this
has a bid let's see yeah so this has
tasks and now we can see some earnings
and some agent cost got our statuses
stacked up and uh everything is coming
through so we have a form uh we're able
to save and we're able to make some
adjustments so let's change this to 0
and this will probably change our agent
cost so now we're having an issue with
the
save oh this is trying to go back to
home we ran into this before that was
where we were at so now let's take a
look at our uh redirect
cuz what we have been doing is let's see
so if we do a
redirect uh let's see where was
home if we go here here's our home oops
that's the wrong
one H this is the one we want so we want
to fix our redirect so that it when we
save a project it actually redirects
properly
what we end up here is that our save
project since it's doing a redirect we
don't actually want it to go and create
a model in
view this is actually going to be just
like we did with uh for example here
we're just going to return but this time
instead of returning oh and that's I can
return
that this tells us hey we're not going
to try to go to that page we're going to
try to redirect to a new page so if we
do this let's try to save save some data
again and get that cleaned
up and when we do
so we can go back to the bid that we had
we're going to see that we had a
slightly different cost because we saved
it let's go back to the 13.3 that we
had and we're still having an issue so
let's take a look at what we got here so
this
one uh let's see it's not telling me
anything terribly useful about
it oh we know this is not going to
work and so let's see then we want to do
our home uh let's see
oh that's going to be a
string but what we need to do here
actually is we're going to have to do an
H
TP
response
and let's
see so we're going to need to
do
a let's do it like
this come back
here this is going to be the
response then we need to
do here
response
do send
redirect and then we can do
this I need to spin that
right and let's see if that works for
Save
project so go build
that oh doesn't like
that oh because we haven't added that
yet oh
and I'm just going to do
this it really doesn't matter what I
send oh I need to do that oh let's do it
this
way so we're going to do a
try
catch
here and what we're going to do is we're
going
[Music]
to uh let's just do
return and actually we could probably
return either way here if there's an
exception there we're going to
return
to let's go to
the oh let's see what's the most simple
one we've got let's see if we've got one
that has nothing I think we've got a
home uh let's see yeah we can just do
return
home uh probably don't want that but
that's and that's what we'll go with for
right now because we'll just keep it
simple we should never see that but
we'll do that just in
case And now when we run
it let's see if we get where we're
supposed to go
to I forget what we're supposed to go to
probably back to projects so let's just
uh we'll just
add some more text here just to be safe
we'll save it and it did not go where we
wanted to so it said it's trying to go
home why doesn't it like
home oh so we don't want to go back to
home we want to go to
dashboard
dashboard
um uh let's see when we save that we
actually probably want to go to projects
okay so we want to go
to so this going to be which is
what
projects technically we should probably
figure out where we came from and go
back to where we came from but let's try
this see if this
works
uh pick
that log in h let's go back to this guy
will change his bid to like
250 and now we're back so now we're
getting where we're supposed to be so
this has been uh a little bit of a fun
little journey here uh but we did need
to you know make sure that we've got our
redirect going we can't just um you we
can't it's not like just returning a
like here where it's going to return
just a an address uh which is actually
what we probably wanted that to be
something else anyways
um so we have this we now are able to do
our redirects we actually probably can
do should do
this up
here so we do our
opportunities that we
will work okay this should be we're just
going to say home although that's not
going to work for
us uh and then we want to get our
response
put that up
[Music]
here there we go that gives us something
to work from and we're just going to
continue moving along because the next
thing we're going to do is we're going
to come in here we're going to look at a
bid and actually let's go look here
because I bet we don't have any of the
edits set up so if we go here and click
we get nothing even though if we look
here yep it's trying to do edit
project edit task so it's got funkiness
going on there so it looks like that's a
broken link this is probably a broken
link yep and we probably if we do new
task that's a broken link so we got a
couple things down here so we've got our
top okay um not sure what we're supposed
to do here we'll take a look what that
is but um we will just continue on next
episode if you have any questions you an
email out to info@ develop or.com other
than that go out there and have yourself
a great day a great week and we will
talk to you
next
[Music]
time
Transcript Segments
1.35

[Music]

27.199

well hello and welcome back we are

29.24

continuing just doing our application

31.24

conversion moving from an old Apache tom

34.239

cat into a spiffy new spring boot uh

38.36

bootstrap five time Leaf all that good

41.2

stuff last episode we're working our way

43.8

through a form getting that data across

46.48

entering it saving it doing updates all

48.84

that kind of good stuff well we ended up

51.12

hitting a little bit of a snag and it

52.92

really had to do with dealing with uh

55.28

generating some of the the calculations

58.16

on the Fly probably not something you do

60.559

too

61.399

often and it does turn out to be a bit

64.28

of a pain to make sure that you get all

66.84

of your uh types correct so we're going

69.92

to do instead of what we were you know

73.04

trying to do it all on the Fly we're

74.32

going to all pull this stuff out and

76.439

we're going to pull this into our U Back

79.32

out so it's just going to be sent as

80.6

values into our form

82.96

so here we have project cost is already

86.72

there but we're going to take this

88.84

thing

90.4

and that's basically going to become our

92.119

earnings and so if we go back here we're

94.479

going to have an earnings and we're

95.56

going to have an agent cost so if we go

98.159

back to our

100.759

controller uh we'll just put that there

103.079

for now and we're going to create a

104.96

couple of

106.079

objects and it's going to

109.92

be this is going to be our we'll call it

112.6

our agent

114.28

cost and our

118.84

earnings

121.039

and we don't have those already so we

122.6

can pull those what we're going to do is

125.52

simply enough is we're going to come in

126.96

here and this guy is going to

129.56

become

133.239

earnings and we can take a look back

135.36

here make sure that we get that that

138.04

generated properly so earnings is going

140.239

to be this now here we've got let's see

147.08

project cost do we already have project

148.8

cost here we have that somewhere oh here

151

we go project

153.319

cost so here we actually are going to

156.879

have to go ahead

158.28

and let's do it this way we're going to

163.12

do uh we'll create a we'll just create a

166.319

project

169.68

cost and I think that's going to be a

174.519

double and we'll start at equal

178.76

z0

180.599

and so here instead of doing this add

183.72

object in all these

185.28

places we don't need to worry about it

187.239

here because project cost is going to be

188.72

Zero by

189.68

default so we're going come back here we

191.959

do project cost whoops don't need that

194.84

else and it's going to be uh we get with

198.48

the capital

200.799

c wh I need to spell it

206.12

right

208.68

and let's do it this way make sure we

212.04

get it copied and pasted right whoa not

215.439

sure what I just

219.08

did uh let's do

223.64

this do that okay so then we're going to

228.08

need here this just means project cost

234.4

equals that and

238.68

here

240.72

new project cost

245.319

equals that whole thing oh and there's

247.28

where our problem is is at our cost we

249.519

were actually adding all of those things

252.439

together

253.72

so actually this alone might fix our

257.32

problems uh let's go check that real

260.079

quick uh let's see project. agent

262.919

percent I think we had project set up

265

here yep we have project so we could do

268.919

it like that

270.6

oh except for it's going to have to be

271.639

get agent

275.52

percent uh I believe it's like that

278.639

project get agent percent

284.72

yep so let's try that because now we've

287.639

got the earnings there but we have not

289.24

pulled across yet

292

our uh agent cost so let's see if we

295.4

still have this blow

297.479

up which goes back to this is this is

299.72

why we got to make sure we oh I have an

301.479

error somewhere so let's go back it's

304.12

probably in the hello oh did I yes I did

309.72

was going to say probably had something

311.08

I didn't get

317.759

things oh project cost already

323.12

exists where did it oh here it is

326.039

Calculate cost

328.479

okay

332.08

oh interesting so I already

335.44

did project cost equals Calculate cost

338.68

oh this may be something where we did

340.16

something stupid so let's

342.319

go uh back to what we

346.4

had so project

352.72

cost oh so it is two different okay so

356.12

we're going to change

358.479

that

360.68

and we're going to make this let's see

363.36

this is Calculate

366

cost this one's going to

371.16

be uh oh we need to make it so we'll

374.52

just do

377

it uh this will

379.52

be total

384.199

cost and we'll just make that total cost

387.039

everywhere else here

390.599

so he's going to be equal to that he's

394.039

going to be equal to

397.8

that and we're going to shove him

403.759

here and oh this is going to

413.56

be project

416.759

okay let's see how this runs

421.479

I think that was what ended up happening

423.039

is we had one of our values not work we

426.68

were creating a string when we shouldn't

428.08

have been so if we come in

430.96

here and we go look boom now we finally

434.56

got it coming across our earnings and

436.039

our agent cost are coming here uh bit

439.039

amount uh earnings is based off of what

442.4

that's probably based off

445.72

of oh because it's t based off of our

449.039

calc Calculate cost which is I bet based

451.879

off of tasks so if we

454.84

go oh we probably have a nice little

457.44

complicated thing here project Dao

460.479

Calculate

464.24

cost uh and so there's hours estimated

466.72

and hours adjusted so we would have to

468.52

actually get it and that's from tasks so

470.56

we would have to within here we have no

473.68

task so uh see looks like we've got most

477.84

of our stuff coming up our ear earnings

479.52

on our agent cost is a little bit wonky

481.759

so let's go look at that on our form

483.44

real quick do a quick fix

486

there uh let's see oh it's because he's

489

an

491.479

md2 let's see how do we want to change

494.08

that around

497.28

um let's go ahead

502.84

and not sure why we put those together

505.8

the way we

508.24

did

509.759

we could do one more was that 2 4 6 8 10

513.599

12 so we probably would need

515.719

to tweak that a little bit let's do

519.479

status and stack that up on site

526.56

instead and take the that

531.399

one is that going to work

535.16

uh yeah I think that whole thing and and

539.32

then that's going to go here and we're

541.92

going to take our

543.72

status we're going to push that up by

546.8

our

550.8

site let's just see how that looks we

553.16

may want to clean it up a little bit but

555.2

that probably gives us a good

558.279

start so now let's go look and let's

560.959

actually look at one that maybe has

562.399

something since we've got a value this

564.44

has a bid let's see yeah so this has

566.72

tasks and now we can see some earnings

568.44

and some agent cost got our statuses

570.959

stacked up and uh everything is coming

574.2

through so we have a form uh we're able

577.519

to save and we're able to make some

579.44

adjustments so let's change this to 0

582.76

and this will probably change our agent

585.64

cost so now we're having an issue with

587.64

the

588.48

save oh this is trying to go back to

592.12

home we ran into this before that was

594.32

where we were at so now let's take a

596.24

look at our uh redirect

601.8

cuz what we have been doing is let's see

604.76

so if we do a

609.36

redirect uh let's see where was

613.8

home if we go here here's our home oops

617.92

that's the wrong

620.519

one H this is the one we want so we want

622.839

to fix our redirect so that it when we

625.88

save a project it actually redirects

628.04

properly

629.64

what we end up here is that our save

631.68

project since it's doing a redirect we

634.56

don't actually want it to go and create

637.399

a model in

639

view this is actually going to be just

641.639

like we did with uh for example here

645.2

we're just going to return but this time

646.6

instead of returning oh and that's I can

648.44

return

650.8

that this tells us hey we're not going

653.36

to try to go to that page we're going to

654.68

try to redirect to a new page so if we

657.68

do this let's try to save save some data

660.639

again and get that cleaned

665.079

up and when we do

670.279

so we can go back to the bid that we had

672.959

we're going to see that we had a

673.88

slightly different cost because we saved

676

it let's go back to the 13.3 that we

679.04

had and we're still having an issue so

681.24

let's take a look at what we got here so

682.68

this

685.079

one uh let's see it's not telling me

688.16

anything terribly useful about

691.92

it oh we know this is not going to

698.959

work and so let's see then we want to do

701.68

our home uh let's see

704.2

oh that's going to be a

708.24

string but what we need to do here

711.2

actually is we're going to have to do an

714.56

H

716.2

TP

717.959

response

721.12

and let's

725.56

see so we're going to need to

728.279

do

732.24

a let's do it like

737.92

this come back

740.199

here this is going to be the

744

response then we need to

747.079

do here

754.72

response

756.6

do send

760.839

redirect and then we can do

765.399

this I need to spin that

773.6

right and let's see if that works for

776

Save

777.519

project so go build

780.959

that oh doesn't like

784.279

that oh because we haven't added that

792.88

yet oh

796.519

and I'm just going to do

800.519

this it really doesn't matter what I

806.36

send oh I need to do that oh let's do it

809.959

this

811.16

way so we're going to do a

814.399

try

818.24

catch

822.44

here and what we're going to do is we're

825.48

going

825.96

[Music]

828.12

to uh let's just do

832.92

return and actually we could probably

835.199

return either way here if there's an

838.36

exception there we're going to

840.639

return

842.6

to let's go to

847.199

the oh let's see what's the most simple

849.44

one we've got let's see if we've got one

850.959

that has nothing I think we've got a

853.68

home uh let's see yeah we can just do

857.639

return

859.92

home uh probably don't want that but

862.199

that's and that's what we'll go with for

863.68

right now because we'll just keep it

864.92

simple we should never see that but

873.12

we'll do that just in

877.32

case And now when we run

883.36

it let's see if we get where we're

886

supposed to go

887.16

to I forget what we're supposed to go to

889.48

probably back to projects so let's just

892

uh we'll just

893.16

add some more text here just to be safe

896.639

we'll save it and it did not go where we

898.68

wanted to so it said it's trying to go

904.56

home why doesn't it like

916.12

home oh so we don't want to go back to

918.36

home we want to go to

921.759

dashboard

923.519

dashboard

925.8

um uh let's see when we save that we

928.8

actually probably want to go to projects

930.639

okay so we want to go

933.319

to so this going to be which is

936.72

what

939.319

projects technically we should probably

941.24

figure out where we came from and go

942.639

back to where we came from but let's try

945.04

this see if this

950

works

951.68

uh pick

955.04

that log in h let's go back to this guy

959.079

will change his bid to like

963.959

250 and now we're back so now we're

966.399

getting where we're supposed to be so

968.88

this has been uh a little bit of a fun

970.88

little journey here uh but we did need

973.319

to you know make sure that we've got our

975.399

redirect going we can't just um you we

979.199

can't it's not like just returning a

981.48

like here where it's going to return

982.839

just a an address uh which is actually

985.48

what we probably wanted that to be

987.04

something else anyways

989.44

um so we have this we now are able to do

992.279

our redirects we actually probably can

993.959

do should do

995.519

this up

997.8

here so we do our

1003.24

opportunities that we

1005.639

will work okay this should be we're just

1010.12

going to say home although that's not

1012.199

going to work for

1014.04

us uh and then we want to get our

1017.72

response

1020.639

put that up

1021.69

[Music]

1025.48

here there we go that gives us something

1027.64

to work from and we're just going to

1029.36

continue moving along because the next

1030.4

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

1031.16

to come in here we're going to look at a

1032.24

bid and actually let's go look here

1034.36

because I bet we don't have any of the

1036.839

edits set up so if we go here and click

1039.76

we get nothing even though if we look

1042.28

here yep it's trying to do edit

1045.16

project edit task so it's got funkiness

1049.039

going on there so it looks like that's a

1050.28

broken link this is probably a broken

1052.679

link yep and we probably if we do new

1056.96

task that's a broken link so we got a

1059.24

couple things down here so we've got our

1060.52

top okay um not sure what we're supposed

1063.6

to do here we'll take a look what that

1065.52

is but um we will just continue on next

1069.679

episode if you have any questions you an

1071.32

email out to info@ develop or.com other

1074.36

than that go out there and have yourself

1075.48

a great day a great week and we will

1077.44

talk to you

1079

next

1081.56

[Music]

1095.32

time