[Lift] Re: problem when use ajaxButton
fixed. because image name have '.' character, which is not allowed, so select by id cant get the element. On Aug 27, 5:41 am, Lance Zheng wrote: > hi, > please help me, I can't find the reason, the code on > gisthttp://gist.github.com/175858 > def remove(img:String)={ > HomePage.removeImg(img) > JsCmds.Run("$('#"+img+"').remove()") > } > var imglist=imgs.map(i =>{ > {SHtml.ajaxButton(S.?("delete"), () =>remove(i))} li>}) > bind("list",xhtml,"imgs" -> {imglist}) > I'm sure jquery is working on that page, but [ JsCmds.Run("$('#"+img > +"').remove()") ]do nothing. > the buttons are in those s, when click, remove the li wrap it,and > also remove the button itself. > the page sourse in browser: > > .. > id="jquery"> >
[Lift] problem when use ajaxButton
hi, please help me, I can't find the reason, the code on gist http://gist.github.com/175858 def remove(img:String)={ HomePage.removeImg(img) JsCmds.Run("$('#"+img+"').remove()") } var imglist=imgs.map(i =>{ {SHtml.ajaxButton(S.?("delete"), () =>remove(i))}}) bind("list",xhtml,"imgs" -> {imglist}) I'm sure jquery is working on that page, but [ JsCmds.Run("$('#"+img +"').remove()") ]do nothing. the buttons are in those s, when click, remove the li wrap it,and also remove the button itself. the page sourse in browser: .. .. delete .. something wrong I do? thanks Lance --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Cant generating liftweb document from source
I try to generate doc but got an error. http://wiki.liftweb.net/index.php/Generating_Lift_scaladocs_locally my OS is vista and maven's version is 2.2.0 D:\scalasrc\liftweb>mvn -v Apache Maven 2.2.0 (r788681; 2009-06-26 21:04:01+0800) Java version: 1.6.0_13 Java home: C:\Program Files\Java\jdk1.6.0_13\jre Default locale: zh_CN, platform encoding: GBK OS name: "windows vista" version: "6.0" arch: "x86" Family: "windows" D:\scalasrc\liftweb>mvn scala:doc .. [WARNING] [Fatal Error] :1:38: Open quote is expected for attribute "{1}" associated with an elemen t type "href". [WARNING] Exception in thread "main" org.xml.sax.SAXParseException: Open quote is expected for attri bute "{1}" associated with an element type "href". [WARNING] at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse (AbstractSAXPar ser.java:1231) [WARNING] at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl $JAXPSAXParser.parse(SAXPars erImpl.java:522) [WARNING] at javax.xml.parsers.SAXParser.parse(SAXParser.java: 395) [WARNING] at scala.xml.parsing.FactoryAdapter.loadXML (FactoryAdapter.scala:292) [WARNING] at scala.xml.parsing.NoBindingFactoryAdapter.loadXML (NoBindingFactoryAdapter.scala:6 0) [WARNING] at scala.xml.XML$.load(XML.scala:68) [WARNING] at org.scala_tools.vscaladoc.DocUtil$.load (DocUtil.scala:28) [WARNING] at org.scala_tools.vscaladoc.Services$cfg$.setFrom (Services.scala:38) [WARNING] at org.scala_tools.vscaladoc.Main$.process(Main.scala: 81) [WARNING] at org.scala_tools.vscaladoc.Main$.main(Main.scala: 107) [WARNING] at org.scala_tools.vscaladoc.Main.main(Main.scala) [INFO] [ERROR] BUILD ERROR [INFO] [INFO] wrap: org.apache.maven.reporting.MavenReportException: wrap: command line returned non-zero v alue:1 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Is it possible to dynamically add/remove a Menu?
My story here is a small online shopping site, with very a simple CMS, so can't help you more :) On Aug 4, 12:11 am, David Pollak wrote: > On Mon, Aug 3, 2009 at 8:31 AM, Lance Zheng wrote: > > > thank you David, I'll try it. > > So... you're building a CMS system? > > I just "volunteered" to create the CMS system for my kids' school, so I'll > be working CMS code over the next few weeks. If you've got requirements, > please let me know. > > > > > > > On Aug 3, 10:15 pm, David Pollak > > wrote: > > > On Mon, Aug 3, 2009 at 1:31 AM, Lance Zheng wrote: > > > > > Hi, > > > > I want to add/remove Menu at runtime, for dynamically managing menu > > > > list. > > > > so I need to persist the menu list(SiteMap?) to the database, > > > > and retrieve it from the database when users access the home page. > > > > > the menu items link to the same page, pass some different params so > > > > let that page show different data. > > > > so I want to dynamically build the menu of home page. > > > > > is it possible to do this by using SiteMap and Menu of liftweb? > > > > In a word, yes. > > > > In a bunch of example... well if you have a static menu that you want to > > > enable, disable based on some calculation, use If() and Unless() when > > you're > > > defining your Loc(). You can see an example in ProtoUser.scala. > > > > For a custom menu based on RDBMS content: > > > > class BaseContentLoc(val name: String, _aspect: String) extends > > > Loc[CustomContent] { > > > // the name of the page > > > // def name = "Content" > > > > val BaseAspect = _aspect > > > > def defaultParams = Full(ContentLocStuff.NullCustomContent) > > > > override def forceParam = defaultParams > > > > // the default parameters (used for generating the menu listing) > > > override def additionalKidParams = > > > CustomContent.findAll(By(CustomContent.aspect, BaseAspect), > > > > OrderBy(CustomContent.displayOrder, Ascending)) > > > > // no extra parameters > > > def params = List(Loc.PlaceHolder, Loc.Template(myTemplate)) > > > > def myTemplate() = > > > > > /> > > > > /** > > > * Generate a link based on the current page > > > */ > > > val link = > > > new Loc.Link[CustomContent](List(BaseAspect), false) { > > > override def createLink(in: CustomContent) = { > > > Full(Text("/"+urlEncode(BaseAspect)+"/"+urlEncode(in.page))) > > > } > > > } > > > > /** > > > * What's the text of the link? > > > */ > > > val text = new Loc.LinkText(calcLinkText _) > > > > def calcLinkText(in: CustomContent): NodeSeq = { > > > if (in.page.length > 0) Text(in.page) else Text(name) > > > } > > > > object Finder { > > > def unapply(page: String): Option[CustomContent] = > > > CustomContent.findContent(page, BaseAspect) > > > } > > > > /** > > > * Rewrite the request and emit the type-safe parameter > > > */ > > > override val rewrite: LocRewrite = > > > Full({ > > > case RewriteRequest(ParsePath(BaseAspect :: Finder(content) :: Nil, > > > _, _, _), _, _) => > > > (RewriteResponse(BaseAspect :: Nil), content) > > > }) > > > > /** > > > * Check for page-specific snippets and > > > * do appropriate dispatching > > > */ > > > override val snippets: SnippetTest = { > > > case ("display", Full(v)) => display(v) _ > > > } > > > > def display(v: CustomContent)(in: NodeSeq) = v.content openOr in > > > > } > > > > Thanks, > > > > David > > > > -- > > > 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 > > -- > 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 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 -~--~~~~--~~--~--~---
[Lift] Re: Is it possible to dynamically add/remove a Menu?
thank you David, I'll try it. On Aug 3, 10:15 pm, David Pollak wrote: > On Mon, Aug 3, 2009 at 1:31 AM, Lance Zheng wrote: > > > Hi, > > I want to add/remove Menu at runtime, for dynamically managing menu > > list. > > so I need to persist the menu list(SiteMap?) to the database, > > and retrieve it from the database when users access the home page. > > > the menu items link to the same page, pass some different params so > > let that page show different data. > > so I want to dynamically build the menu of home page. > > > is it possible to do this by using SiteMap and Menu of liftweb? > > In a word, yes. > > In a bunch of example... well if you have a static menu that you want to > enable, disable based on some calculation, use If() and Unless() when you're > defining your Loc(). You can see an example in ProtoUser.scala. > > For a custom menu based on RDBMS content: > > class BaseContentLoc(val name: String, _aspect: String) extends > Loc[CustomContent] { > // the name of the page > // def name = "Content" > > val BaseAspect = _aspect > > def defaultParams = Full(ContentLocStuff.NullCustomContent) > > override def forceParam = defaultParams > > // the default parameters (used for generating the menu listing) > override def additionalKidParams = > CustomContent.findAll(By(CustomContent.aspect, BaseAspect), > > OrderBy(CustomContent.displayOrder, Ascending)) > > // no extra parameters > def params = List(Loc.PlaceHolder, Loc.Template(myTemplate)) > > def myTemplate() = > /> > > /** > * Generate a link based on the current page > */ > val link = > new Loc.Link[CustomContent](List(BaseAspect), false) { > override def createLink(in: CustomContent) = { > Full(Text("/"+urlEncode(BaseAspect)+"/"+urlEncode(in.page))) > } > } > > /** > * What's the text of the link? > */ > val text = new Loc.LinkText(calcLinkText _) > > def calcLinkText(in: CustomContent): NodeSeq = { > if (in.page.length > 0) Text(in.page) else Text(name) > } > > object Finder { > def unapply(page: String): Option[CustomContent] = > CustomContent.findContent(page, BaseAspect) > } > > /** > * Rewrite the request and emit the type-safe parameter > */ > override val rewrite: LocRewrite = > Full({ > case RewriteRequest(ParsePath(BaseAspect :: Finder(content) :: Nil, > _, _, _), _, _) => > (RewriteResponse(BaseAspect :: Nil), content) > }) > > /** > * Check for page-specific snippets and > * do appropriate dispatching > */ > override val snippets: SnippetTest = { > case ("display", Full(v)) => display(v) _ > } > > def display(v: CustomContent)(in: NodeSeq) = v.content openOr in > > } > > Thanks, > > David > > > > -- > 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 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 -~--~~~~--~~--~--~---
[Lift] Re: Is it possible to dynamically add/remove a Menu?
Hi Tim, >For what reason do you want to persist the site map to the database? >Can the user customize the menu or something? yes, the "site manager" can customizing the global menu, and the menu is just a plain menu without access control or something special. without using SiteMap and Menu, to implement this story, I can creating a menuitem class holding "text" and "link", build the menu in snippet. but I want to know how to do this by using liftweb API > You can do pretty much anything you want my making your own Loc() thank you, I will dive more deep to find the way. On Aug 3, 9:34 pm, Timothy Perrett wrote: > Lance, > > For what reason do you want to persist the site map to the database? > Can the user customize the menu or something? > > You can do pretty much anything you want my making your own Loc() > > Cheers, tim > > On Aug 3, 9:31 am, Lance Zheng wrote: > > > Hi, > > I want to add/remove Menu at runtime, for dynamically managing menu > > list. > > so I need to persist the menu list(SiteMap?) to the database, > > and retrieve it from the database when users access the home page. > > > the menu items link to the same page, pass some different params so > > let that page show different data. > > so I want to dynamically build the menu of home page. > > > is it possible to do this by using SiteMap and Menu of liftweb? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Is it possible to dynamically add/remove a Menu?
Hi, I want to add/remove Menu at runtime, for dynamically managing menu list. so I need to persist the menu list(SiteMap?) to the database, and retrieve it from the database when users access the home page. the menu items link to the same page, pass some different params so let that page show different data. so I want to dynamically build the menu of home page. is it possible to do this by using SiteMap and Menu of liftweb? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: how "10 seconds" works?
for more implementation detail, checkout liftweb source, look at the trait "net.liftweb.util.TimeHelpers" On Jul 31, 8:10 pm, Caesar You wrote: > Hi everyone, i am a rookie of lift and scala. > > now i am cofused about sth in the lift. Line 226 in > LiftSession.scala > > "ActorPing schedule (this, CheckAndPurge, 10 seconds)" > > Does anybody tell me how "10 seconds" works? that is how does the > scala convert it to type TimeSpan? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: How to use "SHtml.ajaxCall"?
my code all here: (google group is not a good place to show code, no syntax highlight) -- import scala.xml.NodeSeq import net.liftweb.http.S._ import net.liftweb.http.SHtml import SHtml._ import net.liftweb.util.Helpers._ import net.liftweb.http.js.{JsCmd, JsCmds} import net.liftweb.http.js.JE.{JsRaw, Str} import net.liftweb.http.js.jquery._ import JqJE._ class HelloFormAjax { def whoNode(str:String) = {str} def updateWho(str:String):JsCmd = { println("updateWho on " + str) JsCmds.Run("$('#who').text('"+str+"')") } def show(xhtml:NodeSeq):NodeSeq = { bind("hello", xhtml, "whoField" -> text("world", null) % ("size" -> "10") % ("id" - > "whoField"), "submit" -> {?("send")}, "who" -> whoNode("world") ) } } --- I guess maybe a comma is missing in your code, and maybe you are not use a IDE. On Jul 23, 10:29 pm, Dorinel wrote: > marius d. wrote: > > Try: > > > > ('value')"), updateWho _)._2}>{?("send")} > > This still is not working for me, it's what I get: > > use java command with args in file forced : false > /home/dorin/work/scala/hello-lift/src/main/scala/net/liftweb/hello/ > snippet/HelloFormAjax.scala:22: error: ')' expected but string literal > found. > "who" -> whoNode("world") > > When I'm trying your import: > use java command with args in file forced : false > /home/dorin/work/scala/hello-lift/src/main/scala/net/liftweb/hello/ > snippet/HelloFormAjax.scala:8: error: value js is not a member of > package net.liftweb > import net.liftweb.js.jquery._ > ^ --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Bug in Darwin
haha, see my post here https://groups.google.com/group/liftweb/browse_thread/thread/3a84814431e7ff94 "submit" -> {?("send")} and "submit" -> > JqGetAttr("value"), updateWho _)._2}>{?("send")} can work in IE8. but in Firefox3.5, it can't get "whoField" value out. Maybe it's a JQuery problem(liftweb 1.0, jquery1.3.2 build in)? On Jul 23, 9:22 pm, Dorinel wrote: > But I've stubled upon another bug when tried to implement the form > with Ajax: > > import scala.xml.NodeSeq > import net.liftweb.http.S._ > import net.liftweb.http.SHtml._ > import net.liftweb.util.Helpers._ > import net.liftweb.http.js.{JsCmd, JsCmds} > > class HelloFormAjax { > def whoNode(str: String) = {str} > > def updateWho(str: String): JsCmd = { > println("updateWho on " + str) > JsCmds.Run("$('#who').text('"+str+"')") > } > > def show(xhtml: NodeSeq): NodeSeq = { > bind("hello", xhtml, > "whoField" -> text("world", null) % ("size" -> "10") % ("id" -> > "whoField"), > > "submit" -> {?("Send")} % > ("onclick" -> ajaxCall("$('#whoField').attr('value')", s => updateWho > (s))), > "who" -> whoNode("world") > ) > } > > } > > I'm getting this bug: > use java command with args in file forced : false > /home/dorin/work/scala/hello-lift/src/main/scala/net/liftweb/hello/ > snippet/HelloFormAjax.scala:20: error: wrong number of arguments for > method ajaxCall: (net.liftweb.http.js.JsExp,(String) => > net.liftweb.http.js.JsCmd)(String, net.liftweb.http.js.JsExp) > "submit" -> {?("Send")} % > ("onclick" -> ajaxCall(JsExp("$('#whoField').attr('value')", s => > updateWho(s, --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: How to use "SHtml.ajaxCall"?
thank u, that works for me. On Jul 23, 2:59 pm, "marius d." wrote: > Try: > > ('value')"), updateWho _)._2}>{?("send")} > > or > > import net.liftweb.js.jquery._ > import JqJE._ > > > JqGetAttr > ("value"), updateWho _)._2}>{?("send")} > > Br's, > Marius > > On Jul 23, 8:54 am, Lance Zheng wrote: > > > Hi, > > I try the example "Hello Darwin"(http://wiki.liftweb.net/index.php/ > > Hello_Darwin), but ajax form can't work correctly. > > > I try bind submit button: > > > "submit" -> > ('#whoField').attr('value')", updateWho _)._2}>{?("send")} > > > but IDE tell me the first param of ajaxCall() must be a JsExp. > > > Dose lift have any implicit method that convert a string to JsExp? > > I don't know how to construct JsExp from String, help please! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] How to use "SHtml.ajaxCall"?
Hi, I try the example "Hello Darwin"(http://wiki.liftweb.net/index.php/ Hello_Darwin), but ajax form can't work correctly. I try bind submit button: "submit" -> {?("send")} but IDE tell me the first param of ajaxCall() must be a JsExp. Dose lift have any implicit method that convert a string to JsExp? I don't know how to construct JsExp from String, help please! --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---