Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot access the parameter of a Menu.param from a Lift Snippet
    primarykey
    data
    text
    <p>I'm trying to extract the parameter from a Lift Menu.param within a snippet so that I can use it to create a named Comet. However, I get a NullPointerException when I try to pass the parameter to the snippet using SnippetDisptach in my Boot.scala, as suggested here: <a href="http://comments.gmane.org/gmane.comp.web.lift/44299" rel="nofollow">http://comments.gmane.org/gmane.comp.web.lift/44299</a> </p> <p>I've created the Menu item as follows:</p> <pre><code>object AnItemPage { // create a parameterized page def menu = Menu.param[Item]("Item", "Item", s =&gt; fetchItem(s), item =&gt; item._id.toString) / "item" private def fetchItem(s:String) : Box[Item] = synchronized { ItemDAO.findById(ObjectId.massageToObjectId(s)) } } </code></pre> <p>I've added the menu to SiteMap. I've also created a Snippet which I would like to pick up the Item parameter. (I'm using fmpwizard's InsertNamedComet library here):</p> <pre><code> class AddCometItemPage(boxedItem: Box[Item]) extends InsertNamedComet with DispatchSnippet{ val item : Item = boxedItem.openOr(null) override lazy val name= "comet_item_" + item._id.toString override lazy val cometClass= "UserItemCometActor" def dispatch = null } </code></pre> <p>My next step is to crate an instance of this class as demonstrated by David Pollak here: <a href="http://comments.gmane.org/gmane.comp.web.lift/44299" rel="nofollow">http://comments.gmane.org/gmane.comp.web.lift/44299</a></p> <p>This is what I have added to my Boot.scala:</p> <pre><code>LiftRules.snippetDispatch.append { case "item_page" =&gt; new AddCometItemPage(AnItemPage.menu.currentValue) } </code></pre> <p>My item.html references this snippet:</p> <pre><code> &lt;div class="lift:item_page"&gt; </code></pre> <p>I get the following null pointer exception when I compile and run this:</p> <pre><code>Exception occurred while processing /item/5114eb4044ae953cf863b786 Message: java.lang.NullPointerException net.liftweb.sitemap.Loc$class.siteMap(Loc.scala:147) net.liftweb.sitemap.Menu$ParamMenuable$$anon$9.siteMap(Menu.scala:170) net.liftweb.sitemap.Loc$class.allParams(Loc.scala:123) net.liftweb.sitemap.Menu$ParamMenuable$$anon$9.allParams(Menu.scala:170) net.liftweb.sitemap.Loc$class.net$liftweb$sitemap$Loc$$staticValue(Loc.scala:87) net.liftweb.sitemap.Menu$ParamMenuable$$anon$9.net$liftweb$sitemap$Loc$$staticValue(Menu.scala:170) net.liftweb.sitemap.Loc$$anonfun$paramValue$2.apply(Loc.scala:85) net.liftweb.sitemap.Loc$$anonfun$paramValue$2.apply(Loc.scala:85) net.liftweb.common.EmptyBox.or(Box.scala:646) net.liftweb.sitemap.Loc$class.paramValue(Loc.scala:85) net.liftweb.sitemap.Menu$ParamMenuable$$anon$9.paramValue(Menu.scala:170) net.liftweb.sitemap.Loc$$anonfun$currentValue$3.apply(Loc.scala:114) net.liftweb.sitemap.Loc$$anonfun$currentValue$3.apply(Loc.scala:114) net.liftweb.common.EmptyBox.or(Box.scala:646) net.liftweb.sitemap.Loc$class.currentValue(Loc.scala:114) net.liftweb.sitemap.Menu$ParamMenuable$$anon$9.currentValue(Menu.scala:170) bootstrap.liftweb.Boot$$anonfun$lift$8.apply(Boot.scala:107) bootstrap.liftweb.Boot$$anonfun$lift$8.apply(Boot.scala:106) net.liftweb.util.NamedPF$$anonfun$applyBox$1.apply(NamedPartialFunction.scala:97) net.liftweb.util.NamedPF$$anonfun$applyBox$1.apply(NamedPartialFunction.scala:97) net.liftweb.common.Full.map(Box.scala:553) net.liftweb.util.NamedPF$.applyBox(NamedPartialFunction.scala:97) net.liftweb.http.LiftRules.snippet(LiftRules.scala:711) net.liftweb.http.LiftSession$$anonfun$net$liftweb$http$LiftSession$$findSnippetInstance$1.apply(LiftSession.scala:1506) net.liftweb.http.LiftSession$$anonfun$net$liftweb$http$LiftSession$$findSnippetInstance$1.apply(LiftSession.scala:1506) net.liftweb.common.EmptyBox.or(Box.scala:646) net.liftweb.http.LiftSession.net$liftweb$http$LiftSession$$findSnippetInstance(LiftSession.scala:1505) net.liftweb.http.LiftSession$$anonfun$locateAndCacheSnippet$1$1$$anonfun$apply$88.apply(LiftSession.scala:1670) net.liftweb.http.LiftSession$$anonfun$locateAndCacheSnippet$1$1$$anonfun$apply$88.apply(LiftSession.scala:1669) </code></pre> <p>Has anybody any idea where I'm going wrong? I've not been able to find a lot of information on Menu.param.</p> <p>Thank you very much for your help.</p> <p>f</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload