On Wed, Jul 1, 2009 at 3:34 PM, Peter Robinett <pe...@bubblefoundry.com>wrote:

>
> Thanks Naftoli and David, I'm starting to understand what I need to
> do. However, the solution has revealed a gap in my beginner's
> knowledge of Scala: why was my code printing out the Loc instead of
> "Couldn't open"?


Are you coming from Java/C# or Ruby/Python?


>
>
> Second, even with foundParam.is within the for comprehension, I still
> need to get the the value out of the comprehension – the rest of my
> snippet is based upon it. So, I still need to openOr the Box, no? If
> so, how? Is there a more functional and Scalarific way to do this?


I don't think you have to pull the value out of the for comprehension... do
all the work inside the for comprehension.

When you're doing your design, think about transformation.  You'll
transforming input to output.  In this particular instance, what kind of
transformation are you performing?


>
>
> Thanks for your help,
> Peter
>
> On Jul 1, 2:45 pm, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> > On Wed, Jul 1, 2009 at 2:02 PM, Peter Robinett <pe...@bubblefoundry.com
> >wrote:
> >
> >
> >
> > > Thanks, David. Unfortunately I'm having a hard time figuring out how
> > > to get the foundParam.
> >
> > > Using your code, I have:
> > > val loc = for {req <- S.request; loc <- req.location} yield loc
> > > val l = loc openOr "Couldn't open"
> >
> > When in doubt, specify a type explicitly:
> >
> > val l: Loc[_] = loc openOr "Couldn't open"
> >
> > This will fail because you've got a Box[Loc[_]] and you're doing an
> openOr
> > with a String... the only common class between the two is Object.
> >
> > As another post suggested, do the foundParam.is inside the yield
> >
> >
> >
> >
> >
> > > println(loc)
> > > println(l)
> >
> > > The first println give me:
> > > Full(Loc(View List(nodes), <function>, LinkText(<function>), List()))
> >
> > > While the second shows that I am opening the Box:
> > > Loc(View List(nodes), <function>, LinkText(<function>), List())
> >
> > > If I try to access my Loc object, I get compilation errors. For
> > > example, "val p = l.foundParam" leads to the error "value foundParam
> > > is not a member of java.lang.Object." The toString method works, while
> > > the title parameter gives me the same error. I believe I am using the
> > > latest Lift code (I ran "mvn -U jetty:run") and feel I must be missing
> > > something very simple here.
> >
> > > Any advice is much appreciated!
> >
> > > Peter
> >
> > > On Jun 29, 10:05 am, David Pollak <feeder.of.the.be...@gmail.com>
> > > wrote:
> > > > On Fri, Jun 26, 2009 at 6:39 PM, Peter Robinett <
> pe...@bubblefoundry.com
> > > >wrote:
> >
> > > > > Thanks, Derek and Jeppe, your responses were very helpful. I
> > > > > implemented Jeppe's solution and added my own snippet tag within
> > > > > _viewTemplate.  Unfortunately, I spent the whole day trying to
> figure
> > > > > out how pass the current CRUDified object to my snippet. Do I
> retrieve
> > > > > it in _viewTemplate from S.params and add an attribute to the
> snippet
> > > > > tag? Or just retrieve it from S in the snippet?
> >
> > > > I've just made Loc.foundParam public.  If you get the Loc from the
> Req
> > > from
> > > > S (for {req <- S.request; loc <- req.location}) you can access
> foundParam
> > > > which contains the current crudified object.
> >
> > > > Thanks,
> >
> > > > David
> >
> > > > > I think I'm missing
> > > > > something fundamental with the S object and snippets. As you can
> tell,
> > > > > I'm very new to Lift! Any advice is much appreciated.
> >
> > > > > Peter
> >
> > > > > On Jun 24, 11:01 am, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote:
> > > > > > On 24 Jun 2009, Peter Robinett wrote:
> >
> > > > > > > Hi all,
> >
> > > > > > > I'm using CRUDify on one of my models and I'd like to display
> some
> > > > > > > additional data on the view template. I believe that I need to
> > > > > > > override one of the model definitions with some sort of
> reference
> > > to
> > > > > > > my own XHTML file. Which one? _viewTemplate? Or perhaps the
> > > > > > > viewTemplate method?
> >
> > > > > > If you look at the source to CRUDify, you'll see
> >
> > > > > > def viewTemplate(): NodeSeq = pageWrapper(_viewTemplate)
> >
> > > > > > where
> >
> > > > > > def pageWrapper(body: NodeSeq): NodeSeq =
> > > > > >   <lift:surround with="default" at="content">
> > > > > >     {
> > > > > >       body
> > > > > >     }
> > > > > >   </lift:surround>
> >
> > > > > > def _viewTemplate =
> > > > > >   <lift:crud.view>
> > > > > >     <table id={viewId} class={viewClass}>
> > > > > >       <crud:row>
> > > > > >         <tr>
> > > > > >           <td><crud:name/></td>
> > > > > >           <td><crud:value/></td>
> > > > > >         </tr>
> > > > > >       </crud:row>
> > > > > >     </table>
> > > > > >   </lift:crud.view>
> >
> > > > > > So the simplest thing is to override _viewTemplate with something
> > > similar
> > > > > > to the above. This should be done on the companion objects where
> > > CRUDify
> > > > > > is mixed in....
> >
> > > > > > /Jeppe
> >
> > > > --
> > > > 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
> >
>


-- 
Lift, the simply functional web framework http://liftweb.net
Beginning Scala http://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
-~----------~----~----~----~------~----~------~--~---

Reply via email to