jsf - Sharing data between ViewScoped controllers -


i have controller user fills in information form. on saving form, jpa objects created , persisted database , user redirected controller view form. not interested in passing whole objects between controllers, strings represent objects. reload objects database, due slow load times, there way can pass data without accessing db?

edit: when 1 controller redirects another, interested in "sending" strings first controller redirected controller strings can displayed.

thank help!

edit 2:

here's code in first controller:

//called commandbutton public string saveform() {     //objects created , persisted db     //store objects' names strings. these values want access in second controller     return "view_form.jsf?formid=" + formid.tostring() + "&faces-redirect=true"; } 

in second controller called viewform, i'm loading formid viewparam:

<f:metadata>   <f:viewparam name="formid" value="#{secondcontroller.formid}" required="true"/>      <f:event type="prerenderview" listener="#{secondcontroller.loadform}"/> </f:metadata> 

in loadform access strings created in saveform. i'm looking @ link rodmar conde posted storing data in session map. correct way go this?

thank far!

the code looks fine. recommended approach case target page needs opened idempotent request. see further how navigate in jsf? how make url reflect current page (and not previous one) general hints.

your real problem apparently db performance (although single select on indexed table should relatively cheap, sure isn't connection cost (use connection pool) or network latency (host db server near web server)). introducing kind of 2nd level cache in persistence layer may lot. refer documentation of persistence layer in question using keywords "second level cache" or "l2 cache".

note beyond scope of jsf. abusing jsf session scope way, not right one. sharing data between 2 view scoped bean instances separated request not possible lifecycle ends , starts request. see jsf viewscoped variable not surviving redirect same page.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -