java ee - What's a good low-impact way for me to preserve this expensive data structure? -
i'm working mature production code written using java ee. deal unusual data condition, i've inserted sanity check works, adding unnecessary cost. architecture works this:
- on page 1, user selects item list , clicks go button.
- an ajax call page 1's view-scoped controller bean creates big expensive data object (bedo), sanity checks make sure it's valid.
- if bedo valid, page 1 forwards via javascript page 2.
- page 2's view-scoped backing bean creates new copy of bedo, identical 1 used sanity check.
i'm creating same bedo twice, , throwing away first one. i'd figure out solution wastes fewer processing cycles.
so question is, what's best low-impact way of getting bedo page 1's controller bean page 2's backing bean? giving page 1's controller access backing bean doesn't work; because page 2's backing bean view-scoped, gets created anew when user gets sent page 2.
i change scope of page 2's backing bean, i'd rather not. because mature production code, i'm wary of introducing regression errors. that's mean "low-impact"; don't want fool around existing architecture more have to.
and winner ... flash scope.
with on 1 end:
facescontext.getcurrentinstance().getexternalcontext().getflash().put("bedo", bedo);
and on other:
object bedoobj = facescontext.getcurrentinstance().getexternalcontext().getflash().get("bedo"); if (bedoobj != null && bedoobj instanceof bigexpensivedataobject) { ...
... behavior i'm looking for.
Comments
Post a Comment