[long] Why building Spindle is hard Pt.2

Geoff Longman <[email protected]> Sat, 11 Feb 2006 14:38:57 -0500
Newsgroups gmane.comp.ide.eclipse.spindle.devel
Message-ID <[email protected]>
I wrapped up the last email with a link to a war file containing a
simple Tapestry application. The home page includes two links. The
first link works ok and the second link fails, displaying an Exception
page.

So, why did the example war fail? Did you try it using Tapestry 4? Did
it fail there too? Yes it did.

In short, it failed because WOW.html refers to a component called
Message. ok, so what?

There are two namespaces in the app. The application namespace
(broken.application) and the library namespace (helper.library).

In both xml files I explicitly included /WEB-INF/WOW.page. In both
Tapestry 3 & 4 it is not required that WOW be explicit included in the
xml. But, for the sake of clarity I did include them. (things still
break if you remove the <page> tags).

So, the page defined by WOW.page exists in two namespaces with the
same name, WOW.

Both namspaces also declare a component called Message. So there are
two components in the overall application called Message, but each has
a different implementation (.jwc file), and exist in a different
namespace.

The problem here is that there is only one implementation of page WOW,
but it depends on the component Message that is in the application
namespace (/WEB-INF/Message.jwc). It will break if for some reason the
other implementation of Message.

Why does it depend on the one implementation of Message?

In WOW.html we see this:

<p>The message is <div jwcid="@Message">foo</div></p>

Message is invoked with no parameter bindings.

If you open up /WEB-INF/Message.jwc and
/WEB-INF/components/Message.jwc you'll see that they both declare a
parameter called foo that takes a String.

There is a subtle difference between the two 'foo' parameters.
/WEB-INF/Message.jwc#foo is not required and
/WEB-INF/components/Message.jwc#foo *is required*.

So, if for some reason Tapestry renders page WOW and chooses
/WEB-INF/components/Message.jwc as the Message implementation then
Tapestry will be unable to complete the page render as WOW.html is not
binding any value to the required 'foo' parameter of
/WEB-INF/components/Message.jwc

Why would Tapestry choose the 'wrong' implementation of Message. Well,
Tapestry is not choosing the wrong implementation. It is choosing the
right implementation in the current context.

look at the links in Home.html

The first link:

<span jwcid="@PageLink" page="WOW">

causes Tapestry load WOW from the application namespace and as the
page is built it needs to find Message. Components are resolved in the
context of the namespace the page was loaded from, in this case the
application namespace. /WEB-INF/Message.jwc is in the application
namespace has no required parameters and therefore <div
jwcid="@Message"> is legal.

The second link in Home.html:

<span jwcid="@PageLink" page="lib:WOW">

causes Tapestry to load a page called lib:WOW defined in the
helper.library namespace. Recall that there is only one .page file
called WOW and it exists in both namespaces. Now when Tapestry needs
to resolve Message, does so in the context of the library namespace
and picks up /WEB-INF/components/Message.jwc.

In this case <div jwcid="@Message"> is not legal as
/WEB-INF/components/Message.jwc has a required parameter 'foo'.  An
Exception page is the result with message:

"Required parameter foo of component lib:WOW/$Message is not bound."

The saga continues in Pt.3.

Geoff


--
The Spindle guy.          http://spindle.sf.net
Get help with Spindle:   
http://lists.sourceforge.net/mailman/listinfo/spindle-user
Blog:                     http://jroller.com/page/glongman
Feature Updates:          http://spindle.sf.net/updates


-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid3432&bid#0486&dat1642