开发者

What does Scala Lift wiring give me?

I have been looking at the Scala web framework Lift. I recently saw something called Wiring and was wondering if some开发者_Go百科one could explain the benefits to me, as an application programmer.


Wiring gives you the ability to declare relationships among different elements on an HTML page and as predicate values change, the dependent values will automatically be updated on the page.

Think about the difference between a spreadsheet and a Java/Scala program. In a spreadsheet, you can declare complex inter-relationships among cells and when predicates change, the cells automatically update. Writing a program that reflects even a pretty simple spreadsheet will typically run into the hundreds or thousands of lines and be very difficult to maintain.

A concrete example is a shopping cart. Think of all the pieces of a web page that must be updated when you put something in a shopping cart. Writing the initial screen may not be hard, but then think about the maintenance complexity (okay, what do I have to update when something gets added to or removed from the cart, when the zip code changes, etc.)

What wiring gives you is the ability to declare relationships and no matter how the predicates change (e.g., tax rules change based on zip code, but anything that depends on taxable subtotal is updated when the tax rules change), the developer doesn't have to understand all the dependents that must also be updated.


Wiring (see demo) makes it possible to have several input fields (or cells) depend on each other and have results automatically passed to dependent cells. – And all of that without a line of JavaScript in a very declarative way.

As you can see in the demo, all you do is declaring how the cells depend on each other and then how they are being displayed. No need to write or call any helper functions in order to connect the cells.


Did you read the announcement on the Lift mailing list about wiring? https://groups.google.com/forum/#!searchin/liftweb/wiring/liftweb/WwLuiK3x0K4/e44Rm1325p4J

Also the two demos should help: http://demo.liftweb.net/simple_wiring and http://demo.liftweb.net/invoice_wiring

I understand the appeal of StackOverflow, but the mailing list is a goldmine of info about Lift.


You may also want to check out reactive-web (http://reactive-web.tk) as it adds the same features to Lift in a much more powerful way.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜