Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Resource files are loaded correctly for Ajax requests

  • Loading branch information...
commit 564c06ff5100d86b6a62dbd562de11f1163093dd 1 parent dfb39e0
@dpp dpp authored
View
2  web/webkit/src/main/scala/net/liftweb/http/DefaultRoutines.scala
@@ -98,7 +98,7 @@ object DefaultRoutines {
val loc = S.locale
val cb =
for {
- req <- S.request
+ req <- S.originalRequest
path = req.path.partPath.dropRight(1) :::
req.path.partPath.takeRight(1).map(s => "_resources_"+s)
bundle <- resBundleFor(loc, path)
View
15 web/webkit/src/main/scala/net/liftweb/http/Req.scala
@@ -857,6 +857,14 @@ class Req(val path: ParsePath,
}
/**
+ * A request that is neither Ajax or Comet
+ */
+ lazy val standardRequest_? : Boolean = path.partPath match {
+ case x :: _ if x == LiftRules.ajaxPath || x == LiftRules.cometPath => false
+ case _ => true
+ }
+
+ /**
* Make the servlet session go away
*/
def destroyServletSession() {
@@ -865,7 +873,12 @@ class Req(val path: ParsePath,
} httpReq.destroyServletSession()
}
- def snapshot = {
+ /**
+ * A snapshot of the request that can be passed off the current thread
+ *
+ * @return a copy of the Req
+ */
+ def snapshot: Req = {
val paramCalc = paramCalculator()
paramCalc.body.map(_.body) // make sure we grab the body
new Req(path,
View
15 web/webkit/src/main/scala/net/liftweb/http/S.scala
@@ -332,6 +332,7 @@ trait S extends HasParams with Loggable {
private val autoCleanUp = new ThreadGlobal[Boolean]
private val _oneShot = new ThreadGlobal[Boolean]
private val _disableTestFuncNames = new ThreadGlobal[Boolean]
+ private object _originalRequest extends RequestVar[Box[Req]](Empty)
private object _exceptionThrown extends TransientRequestVar(false)
@@ -379,6 +380,15 @@ trait S extends HasParams with Loggable {
*/
def request: Box[Req] = (Box !! _request.value) or CurrentReq.box
+
+ /**
+ * If this is an Ajax request, return the original request that created the page. The original
+ * request is useful because it has the original path which is helpful for localization purposes.
+ *
+ * @return the original request or if that's not available, the current request
+ */
+ def originalRequest: Box[Req] = _originalRequest.get or request
+
private[http] object CurrentLocation extends RequestVar[Box[sitemap.Loc[_]]](request.flatMap(_.location))
def location: Box[sitemap.Loc[_]] = CurrentLocation.is or {
@@ -1616,7 +1626,10 @@ for {
_attrs.doWith((Null,Nil)) {
_resBundle.doWith(Nil) {
inS.doWith(true) {
- withReq(doStatefulRewrite(request)) {
+ val statefulRequest = doStatefulRewrite(request)
+ withReq(statefulRequest) {
+ _originalRequest.set(Full(statefulRequest))
+
_nest2InnerInit(f)
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.