You have to define a package for Category.scala

On Fri, Oct 10, 2008 at 4:00 PM, Charles F. Munat <[EMAIL PROTECTED]> wrote:

>
> Thanks, Derek. Actually, I don't use .html or even "add" (all my html
> files are called index.html -- I use directories to sort them). This
> error came when I was experimenting to see if that made a difference.
>
> That said, I get the error all the time. I don't have val dispatch... in
> my snippets. But that's because I copied the JPADemo over, and your
> AuthorOps and BookOps don't have the val dispatch either. But the
> JPADemo doesn't get this error.
>
> Also, my edit functions don't work -- the forms are not populated
> properly. I thought I had it working a minute ago, and now it isn't again.
>
> I switched the snippets around a bit and dropped the bind (because I
> wanted to color code alternate rows and wasn't sure how to do it
> otherwise). Here is an example:
>
> snippet/Category.scala:
>
> import scala.xml.{NodeSeq,Text}
>
> import net.liftweb.http.{RequestVar,S,SHtml}
> import net.liftweb.util.Helpers
> import S._
> import Helpers._
>
> import Model._
>
> class CategoryOps {
>   val formatter = new java.text.SimpleDateFormat("dd MMM yyyy")
>
>   def getRowClass(r: Int) = {
>     if (r % 2 == 0) "even" else "odd"
>   }
>
>   def list: NodeSeq = {
>     <tr valign="top" align="left">
>       <th class="text">Name</th>
>       <th class="integer">Links</th>
>       <th class="blank"> </th>
>       <th class="blank"> </th>
>     </tr> ::
>
>
> Model.createNamedQuery[Category]("findAllCategories").getResultList().toList.zipWithIndex.flatMap(c
> => <tr valign="top" class={getRowClass(c._2)}>
>       <td class="text">{c._1.name}</td>
>       <td class="integer">{SHtml.link("/links/search/", {() =>
>              WeblinkOps.resultVar(Model.createNamedQuery[Weblink](
>   "findWeblinksByCategory", "id" -> category.id).getResultList().toList)
>         }, Text(category.weblinks.size().toString))}</td>
>       <td class="edit">{SHtml.link("editor", () =>
> categoryVar(category), Text("Edit"))}</td>
>       <td class="delete"> </td>
>     </tr>)
>   }
>
>   object categoryVar extends RequestVar(new Category())
>   def category = categoryVar.is
>
>   def editor (xhtml : NodeSeq) : NodeSeq = {
>     def addOrUpdate () = {
>       if (category.name.length == 0) {
>        error("emptyCategory", "The category's name cannot be blank")
>       } else {
>        Model.merge(category)
>        redirectTo("/admin/categories/")
>       }
>     }
>
>     val currentId = category.id
>
>     <form method="POST" action="">
>       <table class="editor" border="0" cellpadding="3" cellspacing="0">
>         <tr valign="top" align="left">
>           <th>Name</th>
>           <td>{SHtml.text(category.name, category.name = _)}</td>
>         </tr>
>         <tr valign="top" align="left">
>           <th>{SHtml.hidden({category.id = currentId})} </th>
>           <td>{SHtml.submit("Save", addOrUpdate)}</td>
>         </tr>
>       </table>
>     </form>
>   }
> }
>
> webapp/admin/categories/editor/index.html:
>
> <lift:surround with="default" at="content">
>   <h2>Categories</h2>
>   <table class="list">
>     <lift:CategoryOps.list/>
>   </table>
> </lift:surround>
>
> And in Boot.scala:
>
> Menu(Loc("categories", List("admin", "categories", "index"),
>     "Categories", LocGroup("admin")),
>   Menu(Loc("categories_add", List("admin", "categories", "editor",
>     "index"), "Add a New Category", Hidden))
> ),
>
> ANY suggestions for how to do any of this better greatly appreciated. Do
> I need to add the val dispatch... part? If so, why is this different
> from the JPADemo?
>
> Thanks!
> Chas.
>
>
> Derek Chen-Becker wrote:
> > It means that the dispatch function on whatever Stateful Snippet is
> > being called isn't matching what you're asking it to provide. For
> > instance, if your snippet tag looks like
> >
> > <lift:MySnippet.add>
> >
> > Then the dispatchPf in the MySnippet stateful snippet has to have a
> > dispatch function like:
> >
> > val dispatch: DispatchIt = {
> >     case "add" => <some function here> _
> >   }
> >
> > See
> >
> http://scala-tools.org/mvnsites-snapshots/liftweb/lift-webkit/scaladocs/index.html
> > for more details.
> >
> > I also know that David has recently /strongly/ recommended not putting
> > ".html" on the ends of things.
> >
> > Derek
> >
> > On Fri, Oct 10, 2008 at 3:15 PM, Charles F. Munat <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
> >
> >
> >     What exactly does this mean? I get a lot of these.
> >
> >     WARN - Snippet Failure: SnippetFailure(/admin/users/add.html ->
> >       ParsePath(List(admin, users, add),html,true,false),
> >       Full(Menu.link),
> >       Stateful Snippet: Dispatch Not Matched)
> >
> >     What is failing here and what are the probable causes?
> >
> >     Thanks.
> >
> >     Chas.
> >
> >
> >
> >
> > >
>
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Collaborative Task Management http://much4.us
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to