Stateless Components
Since commenting on Tapestry vs. JSF I've realizing that both aren't exactly ideal, IMHO. Since then, I've come to the conclusion that components should be stateless and work within a simpler momento system.
Components wear two hats-- displaying and updating. Most components, the 80% case, purely serve the view while only 20% actually have interactive data. The situation begs the question, why add so much overhead to the framework for managing state for 80% of the components that only exist to display data?
First think about a JSP page that executes twice-- one for displaying, then posts back to itself for updating. This comes with the caveats that every component used in displaying must have the opportunity to take part in updating on the post back. JSP creates problems since there's no garauntee that every component used in displaying could participate in updating. This is causing problems for JSF and while the EG has come up with a suitable solution, there's still the issue of the quantity of state that now must be maintained. Tapestry gets around this by pooling objects to save on memory use in managing state.
What I'm suggesting is that we guarantee a consistent component tree for all phases of the lifecycle. This removes the heavy overhead of having a component framework manage component trees for you (bandwidth issues with overall latency and memory issues). Instead, the 'static' component tree operates on a momento object, just like frameworks operate on the Request/Session/Application scope. This momento object is stored much like JSF's ViewState, but only needs to preserve tidbits of a component's state.
We first define a page as being a stateless component, which means the page operates much like a Servlet (something Java developers are very familiar with). Since components are stateless and the component tree is generated once and used by everyone, the attributes cannot be dynamic-- or can they? Instead of following JSP and evaluating EL for attributes on a tag, instead you allow a component (tag) take in a ValueExpression (new EL-API). Then, at each invocation, the ValueExpression can be evaluated to produce the same dynamic behavior that JSP offers within a stateless environment.
But there's a catch. Since components are stateless, each phase: rendering and updating, must execute and work with state in a single method invocation. So a component has a 'onRender' event where the page context is passed, the component captures dynamic state and then calls 'onRender' on its children, scoping state for a single invocation by a Thread-- same as a Servlet's 'service' method. Apologies if I sound confusing at this point.
Remember I said that every component used in rendering must have an opportunity to participate in the update phase? So if I have a document that uses <c:if> behavior in rendering, then how can I guarantee that the update phase will offer the same result? I hinted in the last paragraph that the page context is passed to onRender. This allows <c:if> to store its state in the page context that will be used in updating also, much like JSF's ViewState, but we are cutting all the fat out.
In the above example, for the lifecycle of a PageState (render, update, and possibly render again, repeat--), the single Boolean value can be captured and stored, guaranteeing a consistent execution on every request.
Really, the 'evaluateTest' method could be abstracted into a parent component such that all ValueExpressions can have their state maintained for you by delegating the logic to a single method.
I'm still working out all the details, but I even have most of a 'repeater' example running that works with <c:forEach> without the need for a special data model to back any child form components.
The 80/20 Case
Components wear two hats-- displaying and updating. Most components, the 80% case, purely serve the view while only 20% actually have interactive data. The situation begs the question, why add so much overhead to the framework for managing state for 80% of the components that only exist to display data?
How Components can Be Stateless
First think about a JSP page that executes twice-- one for displaying, then posts back to itself for updating. This comes with the caveats that every component used in displaying must have the opportunity to take part in updating on the post back. JSP creates problems since there's no garauntee that every component used in displaying could participate in updating. This is causing problems for JSF and while the EG has come up with a suitable solution, there's still the issue of the quantity of state that now must be maintained. Tapestry gets around this by pooling objects to save on memory use in managing state.
What I'm suggesting is that we guarantee a consistent component tree for all phases of the lifecycle. This removes the heavy overhead of having a component framework manage component trees for you (bandwidth issues with overall latency and memory issues). Instead, the 'static' component tree operates on a momento object, just like frameworks operate on the Request/Session/Application scope. This momento object is stored much like JSF's ViewState, but only needs to preserve tidbits of a component's state.
A new Page Technology
We first define a page as being a stateless component, which means the page operates much like a Servlet (something Java developers are very familiar with). Since components are stateless and the component tree is generated once and used by everyone, the attributes cannot be dynamic-- or can they? Instead of following JSP and evaluating EL for attributes on a tag, instead you allow a component (tag) take in a ValueExpression (new EL-API). Then, at each invocation, the ValueExpression can be evaluated to produce the same dynamic behavior that JSP offers within a stateless environment.
But there's a catch. Since components are stateless, each phase: rendering and updating, must execute and work with state in a single method invocation. So a component has a 'onRender' event where the page context is passed, the component captures dynamic state and then calls 'onRender' on its children, scoping state for a single invocation by a Thread-- same as a Servlet's 'service' method. Apologies if I sound confusing at this point.
Logical Components
Remember I said that every component used in rendering must have an opportunity to participate in the update phase? So if I have a document that uses <c:if> behavior in rendering, then how can I guarantee that the update phase will offer the same result? I hinted in the last paragraph that the page context is passed to onRender. This allows <c:if> to store its state in the page context that will be used in updating also, much like JSF's ViewState, but we are cutting all the fat out.
protected boolean evaluateTest(PageState state) {
// get an Id from the page, we do this to accomodate
// components being executed repeated times <c:forEach>
String clientId = state.getClientId(this.getId());
// this could be executed in a post back
Boolean b = (Boolean) state.getState(clientId);
if (b == null) {
// this is a new 'request' cycle, so generate b
Boolean b = (Boolean) this.test.getValue(Boolean.class,
state.getELContext());
// store it for the life of this user's request
state.setState(clientId, b);
}
return b.booleanValue();
}
public void onRender(PageState state) {
if (evaluateTest(state)) {
this.renderChildren(state);
}
}
public void onUpdate(PageState state) {
if (evaluateTest(state)) {
this.renderChildren(state);
}
}
In the above example, for the lifecycle of a PageState (render, update, and possibly render again, repeat--), the single Boolean value can be captured and stored, guaranteeing a consistent execution on every request.
Really, the 'evaluateTest' method could be abstracted into a parent component such that all ValueExpressions can have their state maintained for you by delegating the logic to a single method.
Conclusion
I'm still working out all the details, but I even have most of a 'repeater' example running that works with <c:forEach> without the need for a special data model to back any child form components.

5 Comments:
In wow gold players buy wow gold create cheap wow gold a character world of warcraft gold and fast wow gold adventure age of conan gold through aoc gold the ffxi gil, warhammer gold missions, runescape gold blowing tibia gold things swg credits up lotro gold and 2moons dil,maple story mesos bullets, to eve isk name lineage 2 adena but a eq2 plat few wow power leveling things. Generally wow power leveling, if you’ve power leveling seen world of warcraft power leveling it in wow leveling a matrix power leveling film wow gold chances buy wow gold are cheap wow gold you can world of warcraft gold do it wow power leveling in the power leveling game. This wow gold is cheap wow gold excellent news buy wow gold for the vast power leveling mob wow powerleveling of people wow power leveling who cheap power leveling have wow gold always buy wow gold wanted to cheap wow gold experience world of warcraft gold the power leveling matrix wow powerleveling and do wow power leveling their cheap power leveling part power leveling in helping wow powerleveling the wow power leveling people cheap power leveling of Zion. Or wow gold even buy wow gold for those cheap wow gold people world of warcraft gold who wow gold were secretly wow geld sympathetic wow gold kaufen to the billig wow gold Machines, or those wow gold who found cheap wow gold the Merovingian buy wow gold charming bolts nuts and were nut and bolt secretly rooting for his Exiles throughout the film.
wow gold
buy wow gold
cheap wow gold
By
wow gold, at 2:37 AM
Cheap wow gOld welcome to each customer.you can buy WOw gOld here,WOw Gold store on line,wow gold,cheap wOw gold,Buy wow golD,world of warcraft WOw GOld, Welcome to our WOW GOld store,Our store provides the cheapest wow GoLd,world of warcraft woW goLD,WoW gold Look here to Buy WoW goLD, Cheap wOw geld,
Safe wow goLd Instant Delivery.
By
live1, at 9:02 PM
FAQ
Aktuelle News
Support
World of Warcraft(USA)
World of Warcraft(EUR)
Game Card
Guild Wars
Age of Conan - US
Age of Conan - EU
Final Fantasy XI
Vanguard
The Lord of the Rings OL - USA
The Lord of the Rings OL - EUR
By
live1, at 9:03 PM
welcome to China Highlights
China Highlights
China Tours
China Hotels
China Attractions
Beijing China Travel
Shanghai China Tour
Shanghai China Travel
Xi'an China Travel
By
diandian, at 9:03 PM
Brilliant job ! Your web blog has supplied me most of the expertise I requested .
Pasadena TX Locksmith
Locksmith Nashville TN
Locksmith Union City
Newark locksmith
Locksmith Newark CA
Locksmith Newark CA
Locksmith Newark CA
miami beach locksmiths
miami fl locksmith
miami beach locksmiths
locksmith fort worth
locksmiths fort worth
miami fl locksmith
miami fl locksmith
miami beach locksmiths
locksmith fort worth
locksmith miami
locksmith miami
locksmith fort worth
miami locksmiths
miami beach locksmith
locksmith fort worth
locksmith miami
locksmith miami
miami locksmiths
locksmith aventura
locksmith aventura
aventura fl locksmith
Locksmith Memphis TN
<a href="http://www.javaworld.com/comm
By
krishna, at 1:46 AM
Post a Comment
<< Home