Try to do an update and see HttpContext attribute, setAttribute, removeAttribute functions. These functions are not typesafe as the value is an Any so you'd need to cast it yourself. I don't like this but then again HTTP web containers are not really typesafe in many cases.
Br's, Marius On Aug 25, 9:44 pm, Naftoli Gugenheim <[email protected]> wrote: > On Tue, Aug 25, 2009 at 2:29 PM, marius d. <[email protected]> wrote: > > > So you need access attributes not to context params (which are only > > init params). Should be no problem abstracting over those. Give me a > > little time. > > > If you really need in certain cases the servlet-context here is how to > > get it > > > LiftRules.context match { > > case context: HTTPServletContext => context.ctx // this is a > > ServletContext reference > > } > > > ... although I wouldn't recommend adding such dependencies. > > In this case I'm not too worried, it's pretty small-scale. Anyway I guess > I'll do this for now and update my code when you tell me the new way to do > it. > Thanks! > > > Br's, > > Marius > > > On Aug 25, 8:41 pm, Naftoli Gugenheim <[email protected]> wrote: > > > That doesn't seem to help. Here's the code from DbStarter: > > > // This will get the setting from a context-param in > > > web.xml if defined: > > > ServletContext servletContext = > > > servletContextEvent.getServletContext(); > > > String url = getParameter(servletContext, "db.url", > > > "jdbc:h2:~/test"); > > > String user = getParameter(servletContext, "db.user", "sa"); > > > String password = getParameter(servletContext, "db.password", > > "sa"); > > > > conn = DriverManager.getConnection(url, user, password); > > > servletContext.setAttribute("connection", conn); > > > > 2009/8/20 marius d. <[email protected]> > > > > > Ok ... > > > > > HTTPContext now has: > > > > > def initParam(name: String): Box[String] > > > > > def initParams: List[(String, String)] > > > > > HTTPRequest has > > > > > def context: HTTPContext > > > > > LiftRules has (this was supported since a while. Sonow in boot you > > > > have access to HTTPContext and init parameters.) > > > > > def context: HTTPContext > > > > > Br's, > > > > Marius > > > > > On Aug 20, 8:53 am, Naftoli Gugenheim <[email protected]> wrote: > > > > > H2's DbStarter reads the url/username/password and stores a > > connection object back in the servlet context. > > > > > > ------------------------------------- > > > > > > marius d.<[email protected]> wrote: > > > > > > I think that regardless of Naftoli's particular case he brought up a > > > > > valid point such as if when initializing a servlet user has a > > > > > ServletConfig ... we could easily abstract things here as well to > > make > > > > > it available in Boot as well. I'll noodle on this and see what I can > > > > > do. > > > > > > Of course I would not recommend using web.xml init params (unless > > > > > there are really compelling reasons to do so) but rather a Lift > > config > > > > > or an application config ... but that's just me. > > > > > > Br's, > > > > > Marius > > > > > > On Aug 20, 1:15 am, David Pollak <[email protected]> > > > > > wrote: > > > > > > > On Wed, Aug 19, 2009 at 11:29 AM, Naftoli Gugenheim < > > [email protected]>wrote: > > > > > > > > How can I read a context param (e.g. H2 sets "connection" param)? > > > > > > > Why is the context necessary to figure out the DB connection > > parameter? > > > > > > > -- > > > > > > Lift, the simply functional web frameworkhttp://liftweb.net > > > > > > Beginning Scalahttp://www.apress.com/book/view/1430219890 > > > > > > Follow me:http://twitter.com/dpp > > > > > > Git some:http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
