More parameterized snippet

25 views
Skip to first unread message

Jeppe Nejsum Madsen

unread,
Mar 1, 2011, 9:27:16 AM3/1/11
to lif...@googlegroups.com
Hi,

Seems I'm pushing the boundaries of Menu/Snippets lately, but I think
it's worth it. I can remove a lot of our homegrown Locs and the
resulting code is much cleaner.

Current problem:

We have snippets like this

class Order(o: Order) {
def editForm = ...
}

So there has to be a Loc[Order].currentValue in place for this snippet
to be instantiated. We will reuse the editForm snippet when creating a
new Order.

But it seems like it's not easy to create a Menu for this purpose: The
only way to create a Loc[T] where T<>Unit is to use Menu.param, but
this requires parsing/encoding functions which are not needed when
creating a new Order and it generates the wrong link (an extra "/" at
the end). My current workaround is this:

def createOp:Menu = Menu.param[Order]("x", "x", _ => Empty, _ => "") /
prefix / "new" >> Loc.CalcValue(() => Full(Order.create)) >>
Loc.Template(() => {

which sort of works except for the parts noted above.

It seems like it could be useful to add a way to create a Loc[T] where
the value is supplied via Loc parameters?

/Jeppe

David Pollak

unread,
Mar 1, 2011, 10:24:35 AM3/1/11
to lif...@googlegroups.com

Can you put together a sample e

> --
> You received this message because you are subscribed to the Google Groups "Lift" group.
> To post to this group, send email to lif...@googlegroups.com.
> To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
>

Jeppe Nejsum Madsen

unread,
Mar 1, 2011, 10:44:28 AM3/1/11
to lif...@googlegroups.com
On Tue, Mar 1, 2011 at 4:24 PM, David Pollak
<feeder.of...@gmail.com> wrote:
> Can you put together a sample e

Yep had the same idea that it's probably a good idea to have a test
bed for this stuff :-)

I'll be back.

/Jeppe

Jeppe Nejsum Madsen

unread,
Mar 1, 2011, 5:26:14 PM3/1/11
to lif...@googlegroups.com
On Tue, Mar 1, 2011 at 4:24 PM, David Pollak
<feeder.of...@gmail.com> wrote:
> Can you put together a sample e

I've started creating the scenarios here:
https://github.com/jeppenejsum/lift-crud

Look at the Menutest page.

Not much is working atm (i've got it working better in another app,
but this may be due to not having all the menu items as in this
example)

I'm also getting into an endless loop with the URL parse function
(on urls of the form /orders/1). Not sure what causes this

One outstanding design problem is what the type signature of the Loc
for this url should be: /orders/1/lineitems/new

I've also added some comments in Order.scala. Let me know how I can
help move this awesome stuff forward ;-)

/Jeppe

Reply all
Reply to author
Forward
0 new messages