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/28 01:10:17 UTC
svn commit: r1391261 - in
/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main:
java/org/apache/myfaces/trinidaddemo/tagDemos/ForEachBean.java
webapp/demos/tags/forEach.jspx webapp/demos/tags/forEach/updates.jspx
Author: arobinson74
Date: Thu Sep 27 23:10:16 2012
New Revision: 1391261
URL: http://svn.apache.org/viewvc?rev=1391261&view=rev
Log:
TRINIDAD-1940
Commit work so far before removing the component ID suffixing support.
Added:
myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/updates.jspx (with props)
Modified:
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/demos/tags/forEach.jspx
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=1391261&r1=1391260&r2=1391261&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 Thu Sep 27 23:10:16 2012
@@ -136,6 +136,7 @@ public class ForEachBean
_simpleList = new ArrayList<Person>(_list);
_map = new LinkedHashMap<String, Person>();
_applySortToNonCollectionModelObjects();
+ _arrangeMap = new LinkedHashMap<String, Person>(_map);
_updatableItemMap = new LinkedHashMap<String, UpdatableItem>();
for (int i = 1; i <= 5; ++i)
@@ -225,6 +226,11 @@ public class ForEachBean
return _map;
}
+ public Map<String, Person> getArrangeMap()
+ {
+ return _arrangeMap;
+ }
+
public SortableModel getModel()
{
return _getCollectionModel();
@@ -248,6 +254,26 @@ public class ForEachBean
RequestContext.getCurrentInstance().addPartialTarget(toUpdate);
}
+ public void handleArrangeNewItem(ActionEvent evt)
+ {
+
+ }
+
+ public void handleArrangeRemoveItem(ActionEvent evt)
+ {
+
+ }
+
+ public void handleArrangeMoveItemUp(ActionEvent evt)
+ {
+
+ }
+
+ public void handleArrangeMoveItemDown(ActionEvent evt)
+ {
+
+ }
+
/**
* Applies the sort to the person list and the person map based on the sort order of the
* collection model.
@@ -364,7 +390,8 @@ public class ForEachBean
private transient RowKeyPropertyModel _model;
private final Map<String, Person> _map;
private final Map<String, UpdatableItem> _updatableItemMap;
- private String _currentExample = "ppr";
+ private final Map<String, Person> _arrangeMap;
+ private String _currentExample = "updates";
private String _sortProperty;
private boolean _sortAscending;
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=1391261&r1=1391260&r2=1391261&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 Thu Sep 27 23:10:16 2012
@@ -64,10 +64,16 @@
<f:setPropertyActionListener target="#{forEachBean.currentExample}"
value="ppr"/>
</tr:commandLink>
+ <tr:commandLink text="Updates"
+ shortDesc="Example of adding and removing items from a for each loop"
+ partialSubmit="true" id="updatesLink">
+ <f:setPropertyActionListener target="#{forEachBean.currentExample}"
+ value="updates"/>
+ </tr:commandLink>
</tr:panelGroupLayout>
</f:facet>
<tr:panelGroupLayout layout="scroll"
- partialTriggers="reorderMapLink reorderCollectionModelLink simpleLink pprLink">
+ partialTriggers="reorderMapLink reorderCollectionModelLink simpleLink pprLink updatesLink">
<tr:switcher defaultFacet="home" facetName="#{forEachBean.currentExample}">
<f:facet name="home">
<tr:outputText value="Choose an example from the side panel."/>
@@ -100,6 +106,13 @@
</f:subview>
</tr:panelGroupLayout>
</f:facet>
+ <f:facet name="updates">
+ <tr:panelGroupLayout layout="vertical">
+ <f:subview id="up">
+ <jsp:include page="forEach/updates.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/updates.jspx
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/updates.jspx?rev=1391261&view=auto
==============================================================================
--- myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/updates.jspx (added)
+++ myfaces/trinidad/branches/ar_1940_2/trinidad-examples/trinidad-demo/src/main/webapp/demos/tags/forEach/updates.jspx Thu Sep 27 23:10:16 2012
@@ -0,0 +1,47 @@
+<?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"
+ xmlns:f="http://java.sun.com/jsf/core">
+ <tr:panelHeader text="How to add and remove items from a forEach loop">
+ <tr:outputText value="It is not safe to add or remove items from a standard c:forEach tag due to the way IDs are handled and how component state functions. By using a tr:forEach tag that is key based (map or collection model), items may be added or removed from the collection." />
+ <tr:panelGroupLayout layout="vertical" inlineStyle="padding-left: 2em; padding-top: 1em">
+ <tr:forEach var="item" items="#{forEachBean.model}" varStatus="vs">
+ <tr:outputText id="ot" value="#{item.firstName}" />
+ <tr:panelGroupLayout id="actions" layout="horizontal">
+ <tr:commandButton text="Insert new item">
+ <f:attribute name="key" value="#{vs.key}" />
+ </tr:commandButton>
+ <tr:commandButton text="Remove item">
+ <f:attribute name="key" value="#{vs.key}" />
+ </tr:commandButton>
+ <tr:commandButton text="Move item up">
+ <f:attribute name="key" value="#{vs.key}" />
+ </tr:commandButton>
+ <tr:commandButton text="Move item down">
+ <f:attribute name="key" value="#{vs.key}" />
+ </tr:commandButton>
+ </tr:panelGroupLayout>
+ <tr:spacer height="1em"/>
+ </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/updates.jspx
------------------------------------------------------------------------------
svn:eol-style = native