Author: danielc.roth
Date: 2009-04-14 16:47:12 -0400 (Tue, 14 Apr 2009)
New Revision: 10414
Modified:
trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java
Log:
Fix for JBSEAM-4113
Modified: trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java
===================================================================
--- trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java 2009-04-14 20:45:29 UTC
(rev 10413)
+++ trunk/examples/ui/src/org/jboss/seam/example/ui/Resources.java 2009-04-14 20:47:12 UTC
(rev 10414)
@@ -1,8 +1,6 @@
package org.jboss.seam.example.ui;
import java.io.ByteArrayInputStream;
-import java.util.HashMap;
-import java.util.Map;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Create;
@@ -14,30 +12,30 @@
@Scope(ScopeType.EVENT)
public class Resources
{
-
- private static Map<String, ResourceItem> resources = new HashMap<String,
ResourceItem>();
-
- static
- {
- resources.put("1", new ResourceItem("text.txt", new byte[] {
'a', 'b', 'c' }, null, "text/plain"));
- ByteArrayInputStream str = new ByteArrayInputStream(new byte[] { '1',
'2', '3' });
- resources.put("2", new ResourceItem("numbers.txt", str, null,
"text/plain"));
- }
-
+
@RequestParameter
- private String id;
-
+ private int id;
+
private ResourceItem item;
-
+
@Create
public void create()
{
- item = resources.get(id);
+ switch (id)
+ {
+ case 1:
+ item = new ResourceItem("text.txt", new byte[] { 'a',
'b', 'c' }, null, "text/plain");
+ break;
+ case 2:
+ ByteArrayInputStream str = new ByteArrayInputStream(new byte[] { '1',
'2', '3' });
+ item = new ResourceItem("numbers.txt", str, null,
"text/plain");
+ break;
+ }
}
-
+
public static class ResourceItem
{
-
+
public ResourceItem(String fileName, Object data, String disposition, String
contentType)
{
this.fileName = fileName;
@@ -45,57 +43,52 @@
this.disposition = disposition;
this.contentType = contentType;
}
-
+
public String fileName;
public Object data;
public String disposition;
public String contentType;
-
+
public String getFileName()
{
return fileName;
}
-
+
public Object getData()
{
return data;
}
-
+
public String getDisposition()
{
return disposition;
}
-
+
public String getContentType()
{
return contentType;
}
-
+
}
-
- public String getId()
+
+ public int getId()
{
return id;
}
-
- public void setId(String id)
+
+ public void setId(int id)
{
this.id = id;
}
-
+
public ResourceItem getItem()
{
return item;
}
-
+
public void setItem(ResourceItem item)
{
this.item = item;
}
-
- public ResourceItem getTextItem()
- {
- return resources.get("1");
- }
-
+
}