You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by Apache Wiki <wi...@apache.org> on 2007/10/18 00:50:09 UTC

[Myfaces Wiki] Update of "from ADF to Trinidad" by MattCooper

Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Myfaces Wiki" for change notification.

The following page has been changed by MattCooper:
http://wiki.apache.org/myfaces/from_ADF_to_Trinidad

The comment on the change is:
Doced a way to get similar functionality of a 10.1.3 region using Trinidad & JSF

------------------------------------------------------------------------------
  ||   panelGroup  |||| panelGroupLayout|||| <none> |||| <none> |||| <none> |||| <none> ||
  ||   panelHorizontal |||| panelHorizontalLayout|||| <none> |||| <none> |||| <none>|||| <none>||
  ||   processTrain|||| train |||| <none> |||| <none> |||| <none>|||| <none>||
- ||   region|||| <not available> |||| N/A |||| N/A |||| N/A|||| N/A||
+ ||   region|||| <not available> [#region see Region Migration] |||| N/A |||| N/A |||| N/A|||| N/A||
- ||   regionDef|||| <not available> |||| N/A |||| N/A |||| N/A|||| N/A||
+ ||   regionDef|||| <not available> [#region see Region Migration] |||| N/A |||| N/A |||| N/A|||| N/A||
  ||   selectInputColor  |||| inputColor||||  [#messageDesc messageDescUrl] [[BR]] [#messageDesc messageTargetFrame][[BR]] [#tip tip] [[BR]] [#valign valign]|||| contentStyle |||| <none>|||| help||
  ||   selectInputDate  |||| inputDate||||   [#messageDesc messageDescUrl][[BR]] [#messageDesc messageTargetFrame][[BR]] [#tip tip][[BR]] [#valign valign]|||| contentStyle |||| <none>|||| help||
  ||   selectInputText|||| inputListOfValues ||||   [#messageDesc messageDescUrl][[BR]] [#messageDesc messageTargetFrame][[BR]] [#tip tip][[BR]] [#valign valign] |||| contentStyle |||| TBD |||| TBD ||
@@ -245, +245 @@

   #{requestContext.agent}
  }}}
  (The EL expression #{requestContext.agent} returns an object that describes the client agent that is making the request and is to display the rendered output.)
+ 
+ == Region Migration ==
+ 
+ The 10.1.3 [[Anchor(region)]] was composed of the following artifacts:
+ 
+  * Region definition page fragment:
+   * Content is wrapped in an af:regionDef and "var" attribute defines the name of an EL variable to retrieve region attributes from
+   * Content has an EL variable named "bindings" for accessing data control objects from (corresponds to the "value" attribute on the af:region tag
+  * Region usage:
+   * A region is consumed with the af:region tag
+   * The af:region has a "value" attribute which defines the "bindings" EL variable for use by the region definition
+   * The af:region has a "regionType" attribute which identifies which JSP fragment contains the region definition (associated in the region-metadata.xml file).
+   * The af:region has optional f:attribute children that let you map objects from the usage page into EL used in the region definition fragment
+ 
+ To achieve equivalent functionality, separation, and reusability, the following changes must be made:
+ 
+  1. For each af:region, add a unique request-scope managed bean with the following implementation:
+   {{{
+ public UIComponent getAttributesHolder()
+ {
+   return _attributesHolder;
+ }
+ 
+ public void setAttributesHolder(UIComponent component)
+ {
+   _attributesHolder = component;
+ }
+ 
+ public List getAttributes()
+ {
+   if (_attributesHolder == null)
+   {
+     throw new IllegalStateException(
+       "The managed bean's attributes holder binding was not established.");
+   }
+ 
+   ArrayList attrs = new ArrayList();
+   Map<String,Object> attributes = _attributesHolder.getAttributes();
+   attrs.add(attributes);
+   return attrs;
+ }
+ 
+ private UIComponent _attributesHolder = null;
+ }}}
+  2. For each af:region, swap it out with the following JSP content that creates a naming container and establishes an EL-accessible Map of attributes for consumption by the included JSP:
+   {{{
+ <tr:group binding="#{customBean.attributesHolder}">
+   <f:attribute name="title" value="Snow Fall Conditions"/>
+   <f:attribute name="bindings" value="#{bindings.region1}"/>
+ </tr:group>
+ <tr:iterator id="regionLikeContainer1" var="attrs" value="#{customBean.attributes}">
+   <jsp:include page="myRegionDefinitionFragment.jsp"/>
+ </tr:iterator>
+ }}}
+   * The "customBean" variable is the unique managed bean created during step 1.
+   * The value of the f:attribute whose name="bindings" is the "value" from af:region.
+   * The "var" on the iterator replaces the "var" in the old af:regionDef.  It must not collide with other "vars" inside or else you may encounter a stack overflow at runtime.  The iterator only has one stamp.
+   * The page identified in the JSP include is the JSP fragment that used to be defined in the region-metadata.xml file.
+  3. In the region definition JSP fragment file:
+   * Remove the af:regionDef tag
+   * Ensure that any EL referring to the "var" defined on the regionDef corresponds to the "var" declared in the usage page.
+   * If you have any EL that pulls objects off of a "bindings" object, be sure to qualify it with the "var" name, e.g. "#{attrs.bindings}".
  
  = 2.) XML configuration =