Author: nbelaevski
Date: 2008-04-23 20:10:21 -0400 (Wed, 23 Apr 2008)
New Revision: 8103
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatable/UpdateBean.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/capitals/CapitalsBean.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/common/Environment.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataProvider.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaData.java
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java
branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
Log:
richfaces-demo made compatible with JDK 1.4/JSF 1.1
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatable/UpdateBean.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatable/UpdateBean.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatable/UpdateBean.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -10,7 +10,7 @@
HtmlInputText priceRef;
private UIRepeat repeater=null;
- private Set<Integer> keys = null;
+ private Set keys = null;
/**
* @return the keys
@@ -44,8 +44,8 @@
public String change(){
- HashSet keys = new HashSet<Integer>();
- int rowKey = repeater.getRowIndex();
+ HashSet keys = new HashSet();
+ Integer rowKey = new Integer(repeater.getRowIndex());
keys.add(rowKey);
setKeys(keys);
priceRef.processValidators(FacesContext.getCurrentInstance());
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/datatablescroller/DataTableScrollerBean.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -21,16 +21,16 @@
*/
public class DataTableScrollerBean {
private SimpleSelection selection = new SimpleSelection();
- private ArrayList<DemoInventoryItem> selectedCars = new
ArrayList<DemoInventoryItem>();
+ private ArrayList selectedCars = new ArrayList();
private static int DECIMALS = 1;
private static int ROUNDING_MODE = BigDecimal.ROUND_HALF_UP;
- private static List <DemoInventoryItem> allCars = null;
+ private static List allCars = null;
- public List <DemoInventoryItem> getAllCars() {
+ public List getAllCars() {
synchronized (this) {
if (allCars == null) {
- allCars = new ArrayList<DemoInventoryItem>();
+ allCars = new ArrayList();
for (int k = 0; k <= 5; k++) {
try{
switch (k) {
@@ -77,8 +77,8 @@
return allCars;
}
- public List<DemoInventoryItem> getTenRandomCars() {
- List<DemoInventoryItem> result = new ArrayList<DemoInventoryItem>();
+ public List getTenRandomCars() {
+ List result = new ArrayList();
int size = getAllCars().size()-1;
for (int i = 0; i < 10; i++) {
result.add(getAllCars().get(rand(1, size)));
@@ -90,9 +90,9 @@
return rand(1,10000);
}
- public List <DemoInventoryItem> createCar(String make, String model, int count){
+ public List createCar(String make, String model, int count){
- ArrayList <DemoInventoryItem> iiList = null;
+ ArrayList iiList = null;
try{
int arrayCount = count;
@@ -121,7 +121,7 @@
}
- iiList = new
ArrayList<DemoInventoryItem>(Arrays.asList(demoInventoryItemArrays));
+ iiList = new ArrayList(Arrays.asList(demoInventoryItemArrays));
}catch(Exception e){
System.out.println("!!!!!!createCategory Error: " + e.getMessage());
@@ -163,19 +163,19 @@
public String takeSelection() {
getSelectedCars().clear();
- Iterator<SimpleRowKey> iterator = getSelection().getKeys();
+ Iterator iterator = getSelection().getKeys();
while (iterator.hasNext()){
- SimpleRowKey key = iterator.next();
+ SimpleRowKey key = (SimpleRowKey) iterator.next();
getSelectedCars().add(getAllCars().get(key.intValue()));
}
return null;
}
- public ArrayList<DemoInventoryItem> getSelectedCars() {
+ public ArrayList getSelectedCars() {
return selectedCars;
}
- public void setSelectedCars(ArrayList<DemoInventoryItem> selectedCars) {
+ public void setSelectedCars(ArrayList selectedCars) {
this.selectedCars = selectedCars;
}
}
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/capitals/CapitalsBean.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/capitals/CapitalsBean.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/capitals/CapitalsBean.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -13,14 +13,14 @@
import org.xml.sax.SAXException;
public class CapitalsBean {
- private ArrayList<Capital> capitals = new ArrayList<Capital>();
+ private ArrayList capitals = new ArrayList();
private String capital = "";
- public List<Capital> autocomplete(Object suggest) {
+ public List autocomplete(Object suggest) {
String pref = (String)suggest;
- ArrayList<Capital> result = new ArrayList<Capital>();
+ ArrayList result = new ArrayList();
- Iterator<Capital> iterator = getCapitals().iterator();
+ Iterator iterator = getCapitals().iterator();
while (iterator.hasNext()) {
Capital elem = ((Capital) iterator.next());
if ((elem.getName() != null &&
elem.getName().toLowerCase().indexOf(pref.toLowerCase()) == 0) ||
"".equals(pref))
@@ -50,7 +50,7 @@
return null;
}
- public ArrayList<Capital> getCapitals() {
+ public ArrayList getCapitals() {
return capitals;
}
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/common/Environment.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/common/Environment.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/common/Environment.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -3,12 +3,9 @@
import java.util.HashMap;
import java.util.Map;
-import javax.faces.application.Application;
-import javax.faces.context.FacesContext;
-
public class Environment {
private Map params = new HashMap();
- private String version;
+ private Object version;
public Map getParams() {
return params;
}
@@ -17,8 +14,12 @@
this.params = params;
}
- public String getVersion() {
- String shortVersion =
FacesContext.getCurrentInstance().getApplication().getExpressionFactory().createValueExpression(FacesContext.getCurrentInstance().getELContext(),
"#{a4j.version}",
String.class).getValue(FacesContext.getCurrentInstance().getELContext()).toString();
- return shortVersion.substring(0, shortVersion.indexOf("$Date"));
+ public void setVersion(Object version) {
+ this.version = version;
}
+
+ public Object getVersion() {
+ String sVersion = version.toString();
+ return sVersion.substring(0, sVersion.indexOf("$Date"));
+ }
}
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataModel.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -3,6 +3,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -27,8 +28,8 @@
private AuctionDataProvider dataProvider;
private Integer currentPk;
- private Map<Integer,AuctionItem> wrappedData = new
HashMap<Integer,AuctionItem>();
- private List<Integer> wrappedKeys = null;
+ private Map wrappedData = new HashMap();
+ private List wrappedKeys = null;
private boolean detached = false;
/**
@@ -41,14 +42,12 @@
* (non-Javadoc)
* @see org.ajax4jsf.model.ExtendedDataModel#getRowKey()
*/
- @Override
public Object getRowKey() {
return currentPk;
}
/**
* This method normally called by Visitor before request Data Row.
*/
- @Override
public void setRowKey(Object key) {
this.currentPk = (Integer) key;
@@ -56,7 +55,6 @@
/**
* This is main part of Visitor pattern. Method called by framework many times during
request processing.
*/
- @Override
public void walk(FacesContext context, DataVisitor visitor, Range range, Object
argument) throws IOException {
int firstRow = ((SequenceRange)range).getFirstRow();
int numberOfRows = ((SequenceRange)range).getRows();
@@ -65,13 +63,18 @@
// Such approach uses much more getByPk() operations, instead of just one request by
range.
// Concrete case may be different from that, so you can just load data from data provider
by range.
// We are using wrappedKeys list only to preserve actual order of items.
- for (Integer key:wrappedKeys) {
+ for (Iterator iterator = wrappedKeys.iterator(); iterator.hasNext();) {
+ Integer key = (Integer) iterator.next();
setRowKey(key);
visitor.process(context, key, argument);
}
} else { // if not serialized, than we request data from data provider
- wrappedKeys = new ArrayList<Integer>();
- for (AuctionItem item:dataProvider.getItemsByrange(new Integer(firstRow),
numberOfRows, null, true)) {
+ wrappedKeys = new ArrayList();
+ for (Iterator iterator = dataProvider.getItemsByrange(new Integer(firstRow),
numberOfRows, null, true).iterator();
+ iterator.hasNext();) {
+
+ AuctionItem item = (AuctionItem) iterator.next();
+
wrappedKeys.add(item.getPk());
wrappedData.put(item.getPk(), item);
visitor.process(context, item.getPk(), argument);
@@ -83,7 +86,7 @@
* to determine total number of data items.
*/
private Integer rowCount; // better to buffer row count locally
- @Override
+
public int getRowCount() {
if (rowCount==null) {
rowCount = new Integer(getDataProvider().getRowCount());
@@ -96,12 +99,11 @@
* This is main way to obtain data row. It is intensively used by framework.
* We strongly recommend use of local cache in that method.
*/
- @Override
public Object getRowData() {
if (currentPk==null) {
return null;
} else {
- AuctionItem ret = wrappedData.get(currentPk);
+ AuctionItem ret = (AuctionItem) wrappedData.get(currentPk);
if (ret==null) {
ret = getDataProvider().getAuctionItemByPk(currentPk);
wrappedData.put(currentPk, ret);
@@ -115,7 +117,6 @@
/**
* Unused rudiment from old JSF staff.
*/
- @Override
public int getRowIndex() {
throw new UnsupportedOperationException();
}
@@ -123,7 +124,6 @@
/**
* Unused rudiment from old JSF staff.
*/
- @Override
public Object getWrappedData() {
throw new UnsupportedOperationException();
}
@@ -131,7 +131,6 @@
/**
* Never called by framework.
*/
- @Override
public boolean isRowAvailable() {
if (currentPk==null) {
return false;
@@ -143,7 +142,6 @@
/**
* Unused rudiment from old JSF staff.
*/
- @Override
public void setRowIndex(int rowIndex) {
throw new UnsupportedOperationException();
}
@@ -151,7 +149,6 @@
/**
* Unused rudiment from old JSF staff.
*/
- @Override
public void setWrappedData(Object data) {
throw new UnsupportedOperationException();
}
@@ -175,7 +172,6 @@
* This is helper method that is called by framework after model update. In must
delegate actual database update to
* Data Provider.
*/
- @Override
public void update() {
getDataProvider().update();
}
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataProvider.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataProvider.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionDataProvider.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -1,6 +1,7 @@
package org.richfaces.demo.extendeddatamodel;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import org.richfaces.demo.common.RandomDataHelper;
@@ -39,11 +40,11 @@
"NEW 30pcs HEAT SINKS ,50pcs insulation bushing and film",
"0.2% Class A Platinum Resistance Thermometers PT100"
};
- private List<AuctionItem> allItems = null;
+ private List allItems = null;
private static final int VOLUME = 200;
private synchronized void initData() {
- List<AuctionItem> data = new ArrayList<AuctionItem>();
+ List data = new ArrayList();
for (int counter=0; counter<VOLUME; counter++) {
AuctionItem item = new AuctionItem(new Integer(counter));
item.setDescription((String)RandomDataHelper.random(allDescriptions));
@@ -55,7 +56,7 @@
allItems = data;
}
- public List<AuctionItem> getAllItems() {
+ public List getAllItems() {
if (allItems!=null && allItems.size()>0) {
return allItems;
} else {
@@ -65,7 +66,8 @@
}
public AuctionItem getAuctionItemByPk(Integer pk) {
- for (AuctionItem item:getAllItems()) {
+ for (Iterator iterator = getAllItems().iterator(); iterator.hasNext();) {
+ AuctionItem item = (AuctionItem) iterator.next();
if (item.getPk().equals(pk)) {
return item;
}
@@ -73,7 +75,8 @@
throw new RuntimeException("Auction Item pk="+pk.toString()+" not
found");
}
public boolean hasAuctionItemByPk(Integer pk) {
- for (AuctionItem item:getAllItems()) {
+ for (Iterator iterator = getAllItems().iterator(); iterator.hasNext();) {
+ AuctionItem item = (AuctionItem) iterator.next();
if (item.getPk().equals(pk)) {
return true;
}
@@ -82,8 +85,8 @@
}
- public List<AuctionItem> getItemsByrange(Integer startPk, int numberOfRows, String
sortField, boolean ascending) {
- List<AuctionItem> ret = new ArrayList<AuctionItem>();
+ public List getItemsByrange(Integer startPk, int numberOfRows, String sortField, boolean
ascending) {
+ List ret = new ArrayList();
for (int counter=0; counter<numberOfRows; counter++) {
ret.add(getAllItems().get(startPk.intValue()+counter));
}
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/extendeddatamodel/AuctionItem.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -18,7 +18,6 @@
private boolean loose = false;
private Double amount;
- @SuppressWarnings("unused")
private AuctionItem() {};
public AuctionItem(Integer pk) {
@@ -65,7 +64,7 @@
FacesContext ctx = FacesContext.getCurrentInstance();
if (bid!=null) {
System.out.println("place bid for pk="+getPk()+"
bid="+getBid()+" qty="+getQtyRequested());
- if (bid<=highestBid) {
+ if (bid.doubleValue()<=highestBid.doubleValue()) {
ctx.addMessage(event.getComponent().getClientId(ctx), new
FacesMessage(FacesMessage.SEVERITY_WARN,"Bid amount is lower that highest
bid","You need to bid amount higher that highest bid"));
won = false;
loose = true;
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/listShuttle/ToolBar.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -4,8 +4,8 @@
import java.util.List;
public class ToolBar {
- private List<ToolBarItem> items = new ArrayList<ToolBarItem>();
- private List<ToolBarItem> freeItems = new ArrayList<ToolBarItem>();
+ private List items = new ArrayList();
+ private List freeItems = new ArrayList();
public ToolBar() {
ToolBarItem item = new ToolBarItem();
item.setIcon("create_folder");
@@ -37,18 +37,18 @@
freeItems.add(item);
}
- public List<ToolBarItem> getItems() {
+ public List getItems() {
return items;
}
- public void setItems(List<ToolBarItem> items) {
+ public void setItems(List items) {
this.items = items;
}
- public List<ToolBarItem> getFreeItems() {
+ public List getFreeItems() {
return freeItems;
}
- public void setFreeItems(List<ToolBarItem> freeItems) {
+ public void setFreeItems(List freeItems) {
this.freeItems = freeItems;
}
}
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaBean.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -12,12 +12,14 @@
if (data instanceof MediaData) {
MediaData paintData = (MediaData) data;
- BufferedImage img = new
BufferedImage(paintData.getWidth(),paintData.getHeight(),BufferedImage.TYPE_INT_RGB);
+ int paintDataHeight = paintData.getHeight().intValue();
+ int paintDataWidth = paintData.getWidth().intValue();
+ BufferedImage img = new
BufferedImage(paintDataWidth,paintDataHeight,BufferedImage.TYPE_INT_RGB);
Graphics2D graphics2D = img.createGraphics();
graphics2D.setBackground(paintData.getBackground());
graphics2D.setColor(paintData.getDrawColor());
- graphics2D.clearRect(0,0,paintData.getWidth(),paintData.getHeight());
- graphics2D.drawLine(5,5,paintData.getWidth()-5,paintData.getHeight()-5);
+ graphics2D.clearRect(0,0,paintDataWidth,paintDataHeight);
+ graphics2D.drawLine(5,5,paintDataWidth-5,paintDataHeight-5);
graphics2D.drawChars(new String("RichFaces").toCharArray(),0,9,40,15);
graphics2D.drawChars(new String("mediaOutput").toCharArray(),0,11,5,45);
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaData.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaData.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/media/MediaData.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -6,8 +6,8 @@
public class MediaData implements Serializable{
private static final long serialVersionUID = 1L;
- Integer Width=110;
- Integer Height=50;
+ Integer Width=new Integer(110);
+ Integer Height=new Integer(50);
Color Background=new Color(0,0,0);
Color DrawColor=new Color(255,255,255);
public MediaData() {
Modified:
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/java/org/richfaces/demo/tree/Library.java 2008-04-24
00:10:21 UTC (rev 8103)
@@ -149,13 +149,13 @@
this.state2 = state2;
}
- public void walk(TreeNode node, List<TreeNode> appendTo, Class<? extends
TreeNode> type) {
+ public void walk(TreeNode node, List appendTo, Class type) {
if (type.isInstance(node)){
appendTo.add(node);
}
- Iterator<Map.Entry<Object, TreeNode>> iterator = node.getChildren();
+ Iterator iterator = node.getChildren();
while(iterator.hasNext()) {
- walk(iterator.next().getValue(), appendTo, type);
+ walk((TreeNode) ((Map.Entry) iterator.next()).getValue(), appendTo, type);
}
}
Modified: branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml
===================================================================
---
branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-04-23
19:53:19 UTC (rev 8102)
+++
branches/3.1.x/samples/richfaces-demo/src/main/webapp/WEB-INF/faces-config.xml 2008-04-24
00:10:21 UTC (rev 8103)
@@ -105,6 +105,10 @@
<managed-bean-class>org.richfaces.demo.common.Environment</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
+ <property-name>version</property-name>
+ <value>#{a4j.version}</value>
+ </managed-property>
+ <managed-property>
<property-name>params</property-name>
<property-class>java.util.Map</property-class>
<map-entries>