190 likes | 335 Views
New and Upcoming RSF Features – 0.7.2. Antranig Basman, CARET, University of Cambridge. Main Heads of 0.7.2 Results. Spring Web Flow integration As well as release SWF 1.x, trunk and milestone SWF 2.x up to 2.0M3 Improvements in Navigation idiom Resulting View Bindings
E N D
New and Upcoming RSF Features – 0.7.2 Antranig Basman, CARET, University of Cambridge
Main Heads of 0.7.2 Results • Spring Web Flow integration • As well as release SWF 1.x, trunk and milestone SWF 2.x up to 2.0M3 • Improvements in Navigation idiom • Resulting View Bindings • EntityBeanLocator for automated OTP • EntityBroker "Entity Worlds" support • Numerous minor updates and consistentization • Template-based I18N • Role of leaves and branches clarified with forms http://www2.caret.cam.ac.uk/rsfwiki/Wiki.jsp?page=Roadmap
The Final State of RSF Navigation - I • This refers to navigation following a POST (action cycle) • The Static World: • NavigationCaseReporter, provides a list of static rules which are checked after the action completes public List<NavigationCase>reportNavigationCases(){ // In case of no error, transfer to the SearchResults view return ListUtil.instance( new NavigationCase( new SearchCriteriaViewParams(SearchResultsProducer.VIEW_ID))); }
The Final State of RSF Navigation - II • The Dynamic World: • ActionResultInterceptor (ARI2) • result: outgoing ARIResult record determining navigation • incoming: ViewParameters of current view • actionReturn: any return value from method binding • Your job: munge the elements of result, which contains in particular ViewParameters resultingView • NavigationCases have *already* occurred, can perform fine-tuning of outgoing destination taking account of static rules • ARI2 can be declared both locally (on a ViewProducer) or globally (as a standalone bean) publicinterface ActionResultInterceptor { publicvoidinterceptActionResult(ARIResult result, ViewParameters incoming, Object actionReturn); }
The Final State of RSF Navigation III • The Dynamic World (Structured): Resulting View Bindings (new 0.7.2 feature) • A "deferred binding" – unlike normal EL binding expressions, takes effect *after* all action processing is complete • Same timing as ARI2, but much cleaner semantics • Effect: read any EL path from the final request context after the action, and write it to any EL path in the outgoing ViewParameters • Covers very broad class of "local" detailed navigation rules, including the classic case of navigating to a view depending on a freshly created entity ID publicstaticvoidaddResultingViewBinding( UIParameterHolder holder, String viewParamsPath, String requestPath){
Resulting View Binding Example: • Assign from bean id in model to outgoing ViewParams field (in an OTP model) • Assign directly from incoming to outgoing viewID (but take the other info from NavigationCases) UIForm myform = UIForm.make(tofill, "myForm"); RSFUtil.addResultingViewBinding(myForm, "entityId", "myEntity.new 1.id"); RSFUtil.addResultingViewBinding(myForm, "ManagerProvenanceViewId", "viewParameters.ManagerProvenanceViewId");
RSF Navigation Guidelines • Always use the least powerful system possible • Use NavigationCases where your rules are static • Use ResultingViewBindings for most fine-grained "tweaks" • Fall back to an ARI2 if you have to (typically only really needed now for global navigation interception)
EntityBroker "Worlds" • An "Application Fragment" focused on a particular Sakai entity • Served up at paths like http://server/direct/myentity/3/mystub by the "Direct Servlet" (part of the Entity Broker) • Completely clean URL system, hosted outside the portal • Only requires one Spring definition in a normal SakaiRSF tool UIInternalLink.make(tofill,"modify_title_desc_link", UIMessage.make("modifytemplate.modify.title.desc.link"), new TemplateViewParameters(ModifyTemplateProducer.VIEW_ID, templateId)); UIMessage.make(tofill,"level-header","modifytemplate.level.header", new String[]{currentLevel,new Integer(templateItemsList.size()).toString(),});
Hosting an EntityBroker "World" • Define an "EntityViewParamsInferrer" at application scope: • Registers Entity prefix, as well as determining the default view for an incoming Entity reference <bean class="org.sakaiproject.blogwow.tool.inferrer.BlogGroupRSSInferrer" /> publicclass BlogRSSInferrer implements EntityViewParamsInferrer { public String[]getHandledPrefixes(){ returnnew String[]{BlogRssEntityProvider.ENTITY_PREFIX}; } public ViewParameters inferDefaultViewParameters(String reference){ IdEntityReference ref =new IdEntityReference(reference); returnnew BlogRssViewParams(BlogRSSProducer.VIEW_ID, ref.id,null); } }
Notes on EB Worlds • Could not be more simple (in RSF) • Easy to support in other view technologies (done in Wicket) • Work underway for use as a new breed of Sakai "helpers" • Unlike old Entity "access", hosted from a normal webapp • Need to take responsibility not to "leak" out into non-entity application views yourself, as well as proper security checks (throw SecurityException)
Spring Web Flow • At 1.x, Spring Web Flow is a standard Spring technology for managing conversational, stateful interactions ("wizards" or flows) • Flow transitions are mapped out as a finite state machine, either as XML document or in Java • Powerful features for snapshotting and recovering previous flow states • At 2.x, SWF is evolving to have a greater scope to manage top-level lifecycle and non-stateful interactions
A sample Spring Web Flow • "Sell Item" standard sample, JSF version (binding-free) <?xml version="1.0" encoding="UTF-8"?> <flow xmlns="http://www.springframework.org/schema/webflow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/webflow http://www.springframework.org/schema/webflow/spring-webflow-1.0.xsd"> <var name="sale" class="org.springframework.webflow.samples.sellitem.Sale" scope="conversation"/> <start-state idref="enterPriceAndItemCount" /> <view-state id="enterPriceAndItemCount" view="/priceAndItemCountForm.jsp"> <transition on="submit" to="enterCategory"/> </view-state> <decision-state id="requiresShipping"> <if test="${conversationScope.sale.shipping}" then="enterShippingDetails" else="processSale" /> </decision-state> <action-state id="processSale"> <bean-action bean="saleProcessor" method="process"> <method-arguments> <argument expression="conversationScope.sale" /> </method-arguments> </bean-action> <transition on="success" to="showCostOverview" /> </action-state>
Using SWF in RSF • All flow-scoped beans are available for normal request-scope injection via RSAC • Launch flows with special ViewParams SWFLaunchViewParams and binding bean SWFLaunchBean • Fire flow events with special ViewParams SWFEventViewParams and binding bean SWFEventBean • Access "SpringMVC-style" binding using SWFBindingBean
Producer interacting with SWF for(Person colleague:person.getColleagues()){ UIInternalLink.make(tofill,"colleague:", colleague.getFirstName()+" "+ colleague.getLastName(), new SWFEventViewParams("select", new PersonViewParams(colleague.getId()))); } UIForm form = UIForm.make(tofill,"form"); UICommand.make(form,"back","SWFEventBean.back"); }
SWF Integration Status • Majority of SWF standard samples have been ported to RSF-SWF and some to plain RSF • Integration with stable release SWF 1.0.4, as well as milestone SWF 2.0M3 • Whilst SWF 1.x sits within RSF as a navigation engine, SWF 2.x can act as the overall controller (Servlet/Portlet) • Both "forwards" and "backwards" integration supported via the same library • RSF AJAX (including UVB) is transparently supported within all SWF versions (see date widget)
I18N updates for 0.7.2 • Template-driven message syntax • Still use UIMessage component for complex cases where formatting required • UIMessage has been updated to accept an array of message codes following Spring "MessageSourceResolvable" semantics • UIVerbatim now accepts a UIMessage to allow rich text messages in .properties files <span rsf:id="msg=my-message-key">I18N message here</span>
Other Minor Updates • UIForms can now become direct branches • Local branch IDs are now optional • Finegrained wildcards for request addressible beans • New "tag elision syntax" of rsf:id="~my-rsf-id" allows "elision" of tag containment level in output markup. • Only top-level branches in component templates are considered for resolution http://www2.caret.cam.ac.uk/rsfwiki/Wiki.jsp?page=Roadmap
The RSF Future • It is Orange • 0.7.3 (early 2008) • Largely bugfixes • New client-side validation using DHTML and AJAX • The final component: UIDimensionalLinkfor idiomatic "portalisation"/"helpers"
The Further Future – 0.8 • RSF 0.8 – Intended for before Paris (summer 2008) • Full use of Java 1.5 Generics to cut down on ViewProducer verbiage, better typesafety during binding phase • Proper alignment with official Spring scopes (request and session) • RSF API and feature set will then be stable for final 1.0 release