I believe I am doing #1 now with no luck. Let me know if this is correct:
class Cars { // ... object locationQuery extends RequestVar[Box[LocationQuery]](Empty) def search(xhtml: NodeSeq): NodeSeq = { def processSearch() = { // ... val lq = new LocationQuery(validPickupDate.open_!, validDropoffDate.open_!, city, city) S.redirectTo("/select", () => { locationQuery(Full(lq)); requestReference(Full(requestRef)) }) } // binds are here } def selectedLocation(xhtml: NodeSeq): NodeSeq = { if (locationQuery.isDefined) { val selectedCity = locationQuery.open_!.pickupLocation Text(selectedCity.name + ", " + selectedCity.region) } else { Text("") } } // ... } Thanks, Bryan On May 3, 11:46 am, "marius d." <marius.dan...@gmail.com> wrote: > Oh.. 1 & 2 are unrelated ... just slightly different approaches. > > On May 3, 6:45 pm, "marius d." <marius.dan...@gmail.com> wrote: > > > Well instead of open_1 use openOr so that you wont get exceptions when > > the Box is Empty. Also if you want when you to the redirect you could > > propagate those RequestsVars as well so that your browser re-send > > them. Now sure if this is what you'd want but should help avoiding > > Empty request vars. But what I'd do is: > > > 1. Since you are doing redirect with state in the function passed to > > S.redirectTo you can set relevant values to your RequestVar's .. hence > > when your page is rendered your request vars have the old values > > potentially. > > 2. Use a StatefulSnippet and call redirectTo from the StatefulSnippet > > not S. Hence you can save state inside your snippet and when redirect > > happens, the same snippet instance would be used. > > > Br's, > > Marius > > > On May 3, 6:08 pm, Bryan <germ...@gmail.com> wrote: > > > > I have a snippet that calls S.redirectTo with state. In this same > > > snippet class I have a few functions to show the values of the > > > processed RequestVar's. This works fine until I refresh the page, > > > because in these functions I call .open_! on some now Empty > > > RequestVar's. It is simple enough to show Text("") when the box is > > > not Full, but now I have a problem with the page not showing useful > > > data. > > > > What are some suggestions for handling this? Should I just add code > > > to each of my many snippet functions to redirect to "/" when the > > > RequestVar's are empty? > > > > Thanks, > > > Bryan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---