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:

  1. on page 1, user selects item list , clicks go button.
  2. an ajax call page 1's view-scoped controller bean creates big expensive data object (bedo), sanity checks make sure it's valid.
  3. if bedo valid, page 1 forwards via javascript page 2.
  4. 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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -