Posted on January 29th, 2009%
Yesterday, I wrote about the coolness of The Spark view engine (and a brief history of web programming). As I explore more, I’ll share my experiences here in hope that it shortens other people’s learning curve.
Today’s topic is the basics: writing a simple layout.
Spark offers full support for layouts and views. As with any other view engine, the file extension (by default, .spark) of both your layout and view files must match.
A simple layout looks like this:
<html>
<head>
<title>A simple layout</title>
</head>
<body>
<h1>A simple layout</h1>
<use content="view" />
</body>
</html>
The only thing that isn’t HTML is the <use content=”view” /> tag. This tag denotes where in the layout (master template) to embed the content from your view. In NVelocity, we used ${ChildContent} declaration in NVelocity, or the ${ChildOutput} declaration in Brail. Yes, it’s that simple.
Often times, we want to inject some view data into our layout, such as the page title. Let’s say our controller was sending a PageTitle to the view:
public void . . .
→ Read More: Simple layouts and views with Spark and MonoRail
Posted on January 28th, 2009%
I should have gone to bed early last night (after all, I did wake up at 4:30AM yesterday morning). Unfortunately, a spark of inspiration quite literally kept me up later than normal sleep cycles dictate… but what a spark it was.
To understand the spark, you have to understand my history of server-side web programming.
In the beginning
My first experience with server-side web programming was with Allaire ColdFusion some ten years ago. What was great about ColdFusion is its use of a tag-based scripting language, CFML, as illustrated below.
<cfset value = “Hello” />
<cfoutput>
#value# Bob!
</cfoutput>
After ColdFusion, I came across what is now known as “Classic ASP” – and my web code looked less and less like HTML.
<% value = “Hello” %>
<%= value %> Bob!
Classic ASP felt more like programming, less like web programming. Quite accurately, it was web programming via scripting. I missed the tag-based syntax of ColdFusion.
Then there was ASP.Net, which at first glance . . .
→ Read More: The Spark View Engine (and a brief history of web programming)
Posted on January 16th, 2009%
Via Slashdot:
Amenacier writes:
“Recent studies by Finnish and Swedish researchers have shown that drinking moderate amounts of coffee can reduce the risk of Alzheimer’s disease in people. The reason for this is as yet unknown, although it has been hypothesized that the high levels of antioxidants found in coffee may play a role in preventing dementia and Alzheimer’s. Alternatively, some studies have shown that coffee can protect nerves, which may help prevent Alzheimer’s. Other studies have shown that coffee may also help to protect against diabetes, another disease which has been shown to have links to Alzheimer’s disease. However, researchers warn against drinking too much coffee, as 3 cups or more may cause hallucinations.”
Mixed blessing for me. I’m a more-than-three-cups-per-day coffee drinker (less on weekends), which means I’m getting all the Alzheimer’s and diabetes protection, with the occasional hallucination.
Oddly, I don’t recall ever hallucinating, unless… this entire experience… of reality… is not real……
. . .
→ Read More: I won’t get Alzheimer’s or diabetes (but I will have hallucinations)
Posted on January 15th, 2009%
I’ve used a Palm Treo 650 for about 2 1/2 years, and it’s served me well (especially when teamed up with ChatterEmail). That being said, my Verizon Wireless contract is up for renewal, which means I can get a severely discounted new phone… or I can switch to a new provider.
I was going to stick with the Treo until the announcement of the upcoming Palm Pre. I’m no iPhone junkie or gadget-hound, but I’m a fan of Palm, so this new device certainly caught my eye and created a small amount of drooling.
No surprise that the Pre will initially be available to a service provider other than Verizon Wireless – that service provider being Sprint. I’ve never used Sprint, but their rates seem much more competitive than Verizon, and they do have the phone I’m yearning for.
Does anyone have experience with Sprint, especially in . . .
→ Read More: Anyone using Sprint mobile phone service?
Posted on January 14th, 2009%
[Digression] This post has been sitting in a somewhat unfinished state for a long time. It feels good to finally post it!
In rewriting my baseball game, CSFBL, I made the decision to use Castle ActiveRecord (built on top of NHibernate) to handle the persistence of my domain model. As a result, I needed to find a simple but effective way to unit test this implementation.
The unit tests needed to accomplish the following:
- Test the initialization of ActiveRecord (which validates the database schema against the object mappings).
- Test object validation (since I am using Castle’s Validation component and the
ActiveRecordValidationBase<T> base class).
- Ensure that a domain object can be persisted to the database.
- Ensure that a domain object can be retrieved from the database.
- Ensure that multiple instances of an object with the same persisted primary key are equal.
How, then, do we do this? . . . → Read More: Unit testing an Activerecord domain model with NUnit