You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by ar...@apache.org on 2012/09/27 01:03:49 UTC
svn commit: r1390766 - in /myfaces/trinidad/branches/ar_1940_2:
trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/
trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/
trinidad-examples/trinidad-demo/src/m...
Author: arobinson74
Date: Wed Sep 26 23:03:48 2012
New Revision: 1390766
URL: http://svn.apache.org/viewvc?rev=1390766&view=rev
Log:
TRINIDAD-1940
Fix the logic for auto-generated IDs with the trinidad components so that they match between requests.
Added more examples.
Added:
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachComponentBindingBean.java (with props)
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/TestNamingContainerComponent.java (with props)
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/ppr.jspx (with props)
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/simple.jspx (with props)
Modified:
myfaces/trinidad/branches/ar_1940_2/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorder.jspx
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorderMap.jspx
myfaces/trinidad/branches/ar_1940_2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java
Modified: myfaces/trinidad/branches/ar_1940_2/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java?rev=1390766&r1=1390765&r2=1390766&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java (original)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java Wed Sep 26 23:03:48 2012
@@ -25,11 +25,13 @@ import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
+import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TimeZone;
+import java.util.concurrent.atomic.AtomicInteger;
import javax.el.MethodExpression;
import javax.el.ValueExpression;
@@ -540,34 +542,48 @@ abstract public class UIXComponentELTag
_origId = getId();
if (_origId == null)
{
- // If the original ID is null, then we cannot suffix the ID correctly. We also cannot
- // rely on the component ID generation of the UIComponentClassicTagBase is it prevents
- // anyone from assigning an ID with the autogenerated prefix. As a result, we have to
- // generate our own unique ID ourselves.
- // This will ensure that component state will stick with Trinidad components with
- // generated IDs if components are reordered.
- Map<String, Object> viewAttrs = FacesContext.getCurrentInstance().getViewRoot()
- .getAttributes();
- Integer lastUniqueId = (Integer)viewAttrs.get(_UNIQUE_ID_KEY);
- if (lastUniqueId == null)
+ // If the original ID is null, that means that the trinidad tag does not have an ID
+ // attribute. In this case, we should generate an ID based on the page context and the
+ // current suffix.
+
+ Map<String, AtomicInteger> idMap = (Map<String, AtomicInteger>)
+ pageContext.getAttribute(_UNIQUE_ID_KEY);
+ AtomicInteger counter;
+
+ if (idMap == null)
{
- lastUniqueId = 0;
+ idMap = new HashMap<String, AtomicInteger>();
+ pageContext.setAttribute(_UNIQUE_ID_KEY, idMap);
+ counter = null;
}
else
{
- ++lastUniqueId;
+ counter = idMap.get(currentSuffix);
}
- _origId = "tr_" + lastUniqueId;
- viewAttrs.put(_UNIQUE_ID_KEY, lastUniqueId);
+ if (counter == null)
+ {
+ counter = new AtomicInteger();
+ idMap.put(currentSuffix, counter);
+ }
- _origIdGenerated = true;
+ int i = counter.getAndIncrement();
+ setId("tr_" + i + currentSuffix);
+ }
+ else
+ {
+ setId(_origId + currentSuffix);
}
-
- setId(_origId + currentSuffix);
}
}
+ @Override
+ public void setJspId(String id)
+ {
+ _jspId = id;
+ super.setJspId(id);
+ }
+
private static final TrinidadLogger _LOG =
TrinidadLogger.createTrinidadLogger(UIXComponentELTag.class);
@@ -590,5 +606,5 @@ abstract public class UIXComponentELTag
private MethodExpression _attributeChangeListener;
private String _validationError;
private String _origId;
- private boolean _origIdGenerated = false;
+ private String _jspId;
}
Modified: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java?rev=1390766&r1=1390765&r2=1390766&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java (original)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java Wed Sep 26 23:03:48 2012
@@ -34,12 +34,11 @@ import javax.faces.component.visit.Visit
import javax.faces.component.visit.VisitResult;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
+import javax.faces.event.ValueChangeEvent;
import org.apache.commons.lang.StringUtils;
import org.apache.myfaces.trinidad.change.ChangeManager;
import org.apache.myfaces.trinidad.change.ReorderChildrenComponentChange;
-import org.apache.myfaces.trinidad.component.UIXCommand;
-import org.apache.myfaces.trinidad.component.visit.VisitTreeUtils;
import org.apache.myfaces.trinidad.context.RequestContext;
import org.apache.myfaces.trinidad.model.RowKeyPropertyModel;
import org.apache.myfaces.trinidad.model.SortCriterion;
@@ -91,6 +90,39 @@ public class ForEachBean
private static final long serialVersionUID = 1L;
}
+ public static class UpdatableItem
+ implements Serializable
+ {
+ public UpdatableItem(
+ String key,
+ String value)
+ {
+ _key = key;
+ _value = value;
+ }
+
+ public final String getKey()
+ {
+ return _key;
+ }
+
+ public final void setValue(String value)
+ {
+ _value = value;
+ }
+
+ public final String getValue()
+ {
+ return _value;
+ }
+
+ private final String _key;
+ private String _value;
+
+ @SuppressWarnings("compatibility:-1687851812834776335")
+ private static final long serialVersionUID = 1L;
+ }
+
public ForEachBean()
{
_list = new ArrayList<Person>(
@@ -101,9 +133,17 @@ public class ForEachBean
new Person("d", "Alice", "Jones")));
_model = new RowKeyPropertyModel(new ArrayList<Person>(_list), "key");
+ _simpleList = new ArrayList<Person>(_list);
_map = new LinkedHashMap<String, Person>();
-
_applySortToNonCollectionModelObjects();
+
+ _updatableItemMap = new LinkedHashMap<String, UpdatableItem>();
+ for (int i = 1; i <= 5; ++i)
+ {
+ String key = Integer.toString(i);
+ String value = String.format("Item %d", i);
+ _updatableItemMap.put(key, new UpdatableItem(key, value));
+ }
}
public final void setCurrentExample(String currentExample)
@@ -145,9 +185,13 @@ public class ForEachBean
return _list;
}
+ public List<Person> getSimpleList()
+ {
+ return _simpleList;
+ }
+
public void updateSortOrder(ActionEvent evt)
{
- UIXCommand sourceComponent = (UIXCommand)evt.getComponent();
RowKeyPropertyModel model = _getCollectionModel();
if (_sortProperty == null)
@@ -164,14 +208,16 @@ public class ForEachBean
final FacesContext facesContext = FacesContext.getCurrentInstance();
List<String> orderedKeys = _applySortToNonCollectionModelObjects();
- for (UIComponent targetComponent:
- RequestContext.getCurrentInstance().getPartialTargets(sourceComponent))
- {
- String clientId = targetComponent.getClientId();
- //System.out.println("CLIENT ID: " + clientId);
- VisitTreeUtils.visitSingleComponent(facesContext, clientId,
- new ReorderChildrenVisitCallback(orderedKeys));
- }
+ VisitContext visitContext = VisitContext.createVisitContext(facesContext,
+ Arrays.asList("rm:personForEachParent", "rcm:personForEachParent"),
+ null);
+ facesContext.getViewRoot().visitTree(visitContext,
+ new ReorderChildrenVisitCallback(orderedKeys));
+ }
+
+ public Map<String, ForEachBean.UpdatableItem> getUpdatableItemMap()
+ {
+ return _updatableItemMap;
}
public Map<String, Person> getMap()
@@ -184,6 +230,24 @@ public class ForEachBean
return _getCollectionModel();
}
+ public void inputValueValueChange(ValueChangeEvent valueChangeEvent)
+ {
+ UIComponent target = valueChangeEvent.getComponent();
+ String id = target.getId();
+ String keySuffix = id.substring(id.lastIndexOf('_'));
+ UIComponent toUpdate = target.findComponent("outputText" + keySuffix);
+ RequestContext.getCurrentInstance().addPartialTarget(toUpdate);
+ }
+
+ public void inputValueWithNCValueChange(ValueChangeEvent valueChangeEvent)
+ {
+ UIComponent target = valueChangeEvent.getComponent();
+ String id = target.getId();
+ String keySuffix = id.substring(id.lastIndexOf('_'));
+ UIComponent toUpdate = target.findComponent("testNC" + keySuffix + ":outputTextNC");
+ RequestContext.getCurrentInstance().addPartialTarget(toUpdate);
+ }
+
/**
* Applies the sort to the person list and the person map based on the sort order of the
* collection model.
@@ -275,7 +339,7 @@ public class ForEachBean
apm.addComponentChange(facesContext, target,
new ReorderChildrenComponentChange(childrenIds));
- return VisitResult.COMPLETE;
+ return VisitResult.ACCEPT;
}
@Override
@@ -295,10 +359,12 @@ public class ForEachBean
private final List<String> _orderedKeys;
}
+ private final List<Person> _simpleList;
private final List<Person> _list;
private transient RowKeyPropertyModel _model;
private final Map<String, Person> _map;
- private String _currentExample = "home";
+ private final Map<String, UpdatableItem> _updatableItemMap;
+ private String _currentExample = "ppr";
private String _sortProperty;
private boolean _sortAscending;
Added: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachComponentBindingBean.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachComponentBindingBean.java?rev=1390766&view=auto
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachComponentBindingBean.java (added)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachComponentBindingBean.java Wed Sep 26 23:03:48 2012
@@ -0,0 +1,25 @@
+package org.apache.myfaces.trinidaddemo.tagDemos;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class ForEachComponentBindingBean
+{
+ public ForEachComponentBindingBean()
+ {
+ _componentMap = new HashMap<String, TestNamingContainerComponent>();
+ for (int i = 1; i <= 5; ++i)
+ {
+ String key = Integer.toString(i);
+ TestNamingContainerComponent comp = new TestNamingContainerComponent();
+ _componentMap.put(key, comp);
+ }
+ }
+
+ public Map<String, TestNamingContainerComponent> getComponentMap()
+ {
+ return _componentMap;
+ }
+
+ private final Map<String, TestNamingContainerComponent> _componentMap;
+}
Propchange: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachComponentBindingBean.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/TestNamingContainerComponent.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/TestNamingContainerComponent.java?rev=1390766&view=auto
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/TestNamingContainerComponent.java (added)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/TestNamingContainerComponent.java Wed Sep 26 23:03:48 2012
@@ -0,0 +1,20 @@
+package org.apache.myfaces.trinidaddemo.tagDemos;
+
+import javax.faces.component.NamingContainer;
+
+import org.apache.myfaces.trinidad.component.core.layout.CorePanelGroupLayout;
+
+public class TestNamingContainerComponent
+ extends CorePanelGroupLayout
+ implements NamingContainer
+{
+ public TestNamingContainerComponent(String string)
+ {
+ super(string);
+ }
+
+ public TestNamingContainerComponent()
+ {
+ super();
+ }
+}
Propchange: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/java/org/apache/myfaces/trinidaddemo/tagDemos/TestNamingContainerComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml?rev=1390766&r1=1390765&r2=1390766&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml (original)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/WEB-INF/faces-config.xml Wed Sep 26 23:03:48 2012
@@ -3144,4 +3144,10 @@
sync with the change state -->
<managed-bean-scope>session</managed-bean-scope>
</managed-bean>
+
+ <managed-bean>
+ <managed-bean-name>forEachComponentBindingBean</managed-bean-name>
+ <managed-bean-class>org.apache.myfaces.trinidaddemo.tagDemos.ForEachComponentBindingBean</managed-bean-class>
+ <managed-bean-scope>request</managed-bean-scope>
+ </managed-bean>
</faces-config>
Modified: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx?rev=1390766&r1=1390765&r2=1390766&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx (original)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach.jspx Wed Sep 26 23:03:48 2012
@@ -39,6 +39,13 @@
<f:facet name="separator">
<tr:spacer height="6px"/>
</f:facet>
+ <tr:panelHeader text="Demos:" />
+ <tr:commandLink text="Simple collection model"
+ shortDesc="Simple for each loop using a list for items"
+ partialSubmit="true" id="simpleLink">
+ <f:setPropertyActionListener target="#{forEachBean.currentExample}"
+ value="simple"/>
+ </tr:commandLink>
<tr:commandLink text="Re-order collection model"
shortDesc="Example of reordering support with a collection model backed for each loop"
partialSubmit="true" id="reorderCollectionModelLink">
@@ -51,14 +58,27 @@
<f:setPropertyActionListener target="#{forEachBean.currentExample}"
value="reorderMap"/>
</tr:commandLink>
+ <tr:commandLink text="PPR"
+ shortDesc="Example of using partial triggers with components in a forEach loop"
+ partialSubmit="true" id="pprLink">
+ <f:setPropertyActionListener target="#{forEachBean.currentExample}"
+ value="ppr"/>
+ </tr:commandLink>
</tr:panelGroupLayout>
</f:facet>
<tr:panelGroupLayout layout="scroll"
- partialTriggers="reorderMapLink reorderCollectionModelLink">
+ partialTriggers="reorderMapLink reorderCollectionModelLink simpleLink pprLink">
<tr:switcher defaultFacet="home" facetName="#{forEachBean.currentExample}">
<f:facet name="home">
<tr:outputText value="Choose an example from the side panel."/>
</f:facet>
+ <f:facet name="simple">
+ <tr:panelGroupLayout layout="vertical">
+ <f:subview id="s">
+ <jsp:include page="forEach/simple.jspx"/>
+ </f:subview>
+ </tr:panelGroupLayout>
+ </f:facet>
<f:facet name="reorderMap">
<tr:panelGroupLayout layout="vertical">
<f:subview id="rm">
@@ -73,6 +93,13 @@
</f:subview>
</tr:panelGroupLayout>
</f:facet>
+ <f:facet name="ppr">
+ <tr:panelGroupLayout layout="vertical">
+ <f:subview id="ppr">
+ <jsp:include page="forEach/ppr.jspx"/>
+ </f:subview>
+ </tr:panelGroupLayout>
+ </f:facet>
</tr:switcher>
</tr:panelGroupLayout>
</tr:panelBorderLayout>
Added: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/ppr.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/ppr.jspx?rev=1390766&view=auto
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/ppr.jspx (added)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/ppr.jspx Wed Sep 26 23:03:48 2012
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page"
+ xmlns:tr="http://myfaces.apache.org/trinidad" version="2.1">
+ <tr:panelHeader text="How to use partial triggers with the forEach loop">
+ <tr:outputText value="Using the c:forEach tag, component IDs are not generated in a way that can be used with Trinidad's partial triggers. By using tr:forEach and either a map or a collection model, the IDs are known and can be used with partial triggers." />
+ <tr:panelGroupLayout layout="vertical" inlineStyle="padding-left: 2em; padding-top: 1em">
+ <tr:forEach var="item" items="#{forEachBean.updatableItemMap}" varStatus="vs">
+ <tr:panelLabelAndMessage id="a" label="Enter value for item #{vs.key}:">
+ <tr:inputText id="inputValue" value="#{item.value}" autoSubmit="true"
+ valueChangeListener="#{forEachBean.inputValueValueChange}"/>
+ </tr:panelLabelAndMessage>
+ <tr:outputText id="outputText" value="Value on server: #{item.value}"
+ inlineStyle="padding-left: 12px; font-size: 0.8em;"/>
+ </tr:forEach>
+ </tr:panelGroupLayout>
+ </tr:panelHeader>
+
+ <tr:panelHeader text="Partial triggers with a naming container">
+ <tr:outputText value="When a trinidad naming container tag is reached, the key is no longer appended to the ID. To reference an item in a naming container, no suffix is needed inside the naming container. This only works if the namining container is a trinidad tag. If there are other naming container tags, like f:subview, then the prefix will descend into that naming container." />
+ <tr:panelGroupLayout layout="vertical" inlineStyle="padding-left: 2em; padding-top: 1em">
+ <tr:forEach var="item" items="#{forEachBean.updatableItemMap}" varStatus="vs">
+ <tr:panelLabelAndMessage label="Enter value for item #{vs.key}:">
+ <tr:inputText id="inputValueNC" value="#{item.value}" autoSubmit="true"
+ valueChangeListener="#{forEachBean.inputValueWithNCValueChange}"/>
+ </tr:panelLabelAndMessage>
+ <tr:panelGroupLayout id="testNC"
+ binding="#{forEachComponentBindingBean.componentMap[vs.key]}">
+ <tr:outputText id="outputTextNC" value="Value on server: #{item.value}"
+ inlineStyle="padding-left: 12px; font-size: 0.8em;"/>
+ </tr:panelGroupLayout>
+ </tr:forEach>
+ </tr:panelGroupLayout>
+ </tr:panelHeader>
+</jsp:root>
\ No newline at end of file
Propchange: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/ppr.jspx
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorder.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorder.jspx?rev=1390766&r1=1390765&r2=1390766&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorder.jspx (original)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorder.jspx Wed Sep 26 23:03:48 2012
@@ -44,20 +44,15 @@
</tr:panelGroupLayout>
<tr:panelGroupLayout layout="vertical" inlineStyle="padding-left: 2em; padding-top: 1em">
<tr:panelHeader text="Components built from the for each loop">
- <tr:panelGroupLayout layout="vertical" id="personForEachParent_re"
+ <tr:panelGroupLayout layout="vertical" id="personForEachParent"
partialTriggers="applySort"
inlineStyle="padding-bottom: 1em">
<tr:forEach var="person" items="#{forEachBean.model}" varStatus="vs">
- <tr:panelGroupLayout id="personPgl">
- <f:facet name="separator">
- <tr:spacer width="10"/>
- </f:facet>
+ <tr:panelGroupLayout id="personPgl" layout="vertical">
<tr:outputText id="firstName"
value="First name: #{person.firstName}"/>
<tr:outputText id="lastName"
value="Last name: #{person.lastName}"/>
- <tr:outputText id="clientId"
- value="(Panel group layout client ID: #{component.parent.clientId})"/>
</tr:panelGroupLayout>
<tr:showDetail id="showDisclosure" disclosed="false" disclosedText="Disclosed text"
undisclosedText="Undisclosed text">
Modified: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorderMap.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorderMap.jspx?rev=1390766&r1=1390765&r2=1390766&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorderMap.jspx (original)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/reorderMap.jspx Wed Sep 26 23:03:48 2012
@@ -59,8 +59,6 @@
value="First name: #{person.firstName}"/>
<tr:outputText id="lastName"
value="Last name: #{person.lastName}"/>
- <tr:outputText id="clientId"
- value="(Panel group layout client ID: #{component.parent.clientId}) Client ID: #{component.clientId} Vs: #{vs.index}"/>
</tr:panelGroupLayout>
<tr:showDetail id="showDisclosure" disclosed="false" disclosedText="Disclosed text"
undisclosedText="Undisclosed text">
Added: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/simple.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/simple.jspx?rev=1390766&view=auto
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/simple.jspx (added)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/simple.jspx Wed Sep 26 23:03:48 2012
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="iso-8859-1" standalone="yes" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+
+-->
+<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core"
+ xmlns:tr="http://myfaces.apache.org/trinidad" version="2.1">
+ <tr:panelHeader text="Simple forEach example">
+ <tr:panelHeader text="This example shows a for each loop backed by a list">
+ <tr:outputText value="Note that the IDs are changed by the JSF tags in a manner that cannot be used for partial triggers." />
+ <tr:panelGroupLayout layout="vertical" inlineStyle="padding-left: 2em; padding-top: 1em">
+ <tr:forEach var="person" items="#{forEachBean.simpleList}" varStatus="vs">
+ <tr:panelGroupLayout id="personPgl" layout="horizontal">
+ <tr:outputText id="personName" value="#{person.firstName} #{person.firstName}"
+ inlineStyle="padding-right: 1em;"/>
+ <tr:outputText id="clientId" value="(Client ID: #{component.clientId})"/>
+ </tr:panelGroupLayout>
+ <tr:spacer height="1em" />
+ </tr:forEach>
+ </tr:panelGroupLayout>
+ </tr:panelHeader>
+ <tr:panelHeader text="This example shows a for each loop backed by a collection model">
+ <tr:outputText value="By using a collection model or a map, the IDs are discoverable by the item's key. See the partial triggers demo for how this can be used." />
+ <tr:panelGroupLayout layout="vertical" inlineStyle="padding-left: 2em; padding-top: 1em">
+ <tr:forEach var="person" items="#{forEachBean.model}" varStatus="vs">
+ <tr:panelGroupLayout id="personPgl2" layout="horizontal">
+ <tr:outputText id="personName2" value="#{person.firstName} #{person.firstName}"
+ inlineStyle="padding-right: 1em;"/>
+ <tr:outputText id="clientId2" value="(Client ID: #{component.clientId})"/>
+ </tr:panelGroupLayout>
+ <tr:spacer height="1em" />
+ </tr:forEach>
+ </tr:panelGroupLayout>
+ </tr:panelHeader>
+ </tr:panelHeader>
+</jsp:root>
\ No newline at end of file
Propchange: myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/simple.jspx
------------------------------------------------------------------------------
svn:eol-style = native
Modified: myfaces/trinidad/branches/ar_1940_2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java?rev=1390766&r1=1390765&r2=1390766&view=diff
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java (original)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/ForEachTag.java Wed Sep 26 23:03:48 2012
@@ -294,7 +294,7 @@ public class ForEachTag
// are created during this tags for each execution
_previousIterationNonTrinidadChildren = _getNonTrinidadChildren();
- _updateVars(true);
+ _updateVars(vm, true);
return EVAL_BODY_INCLUDE;
}
@@ -312,11 +312,12 @@ public class ForEachTag
_isFirst = false;
_isLast = _currentIndex == _currentEnd;
+ VariableMapper vm = pageContext.getELContext().getVariableMapper();
+
// If we're at the end, bail
if (_currentEnd < _currentIndex)
{
// Restore EL state
- VariableMapper vm = pageContext.getELContext().getVariableMapper();
if (_var != null)
vm.setVariable(_var, _previousDeferredVar);
if (_varStatus != null)
@@ -333,7 +334,7 @@ public class ForEachTag
}
// Otherwise, update the variables and go again
- _updateVars(true);
+ _updateVars(vm, true);
return EVAL_BODY_AGAIN;
}
@@ -439,7 +440,8 @@ public class ForEachTag
// for each index.
if (_iterationIdRequiresIncrement)
{
- _updateVars(false);
+ VariableMapper vm = pageContext.getELContext().getVariableMapper();
+ _updateVars(vm, false);
_iterationIdRequiresIncrement = false;
}
}
@@ -564,10 +566,10 @@ public class ForEachTag
// Push new values into the VariableMapper and the pageContext
private void _updateVars(
- boolean createNewIterationData)
+ VariableMapper vm,
+ boolean createNewIterationData)
{
- VariableMapper vm = pageContext.getELContext().getVariableMapper();
- Serializable key = null;
+ Serializable key = null;
// Generate a new iteration ID
_updateIterationId();