Re: Component to display raw row results as table
Re: Component to display raw row results as table
- Subject: Re: Component to display raw row results as table
- From: Zak Burke <email@hidden>
- Date: Thu, 19 Oct 2006 13:17:26 -0400
John Huss wrote on 10/19/06 11:24 AM:
Is there a component in Product Wonder or anywhere that will more or
less just take an array of dictionaries (raw rows) and display it as a
table?
This isn't very WO-like, but it does the trick if you really just want
an HTML string in return:
StringBuffer sb = new StringBuffer();
sb.append("<table>");
NSDictionary d = null;
for (Enumeration e = list.objectEnumerator(); e.hasMoreElements();)
{
sb.append("<tr><td>");
sb.append(Util.join("", "</td><td>", (NSDictionary)
e.nextElement(), false));
sb.append("</td></tr>");
}
sb.append("</table>");
/**
* Join elements in a hash into into a string.
*
* @param joinKey string to insert between elements
* @param joinPair string to insert between key and value
* @param d hash of elements
* @param showKey whether to display "key: value" or just "value"
* @return string formatted as "key: value<j>key..."
*/
public static String join(String joinKey, String joinPair, NSDictionary
d, boolean showKey)
{
if (d == null)
return "";
if (joinKey == null)
joinKey = ": ";
if (joinPair == null)
joinPair = "\n";
StringBuffer b = new StringBuffer();
Object key = null;
Enumeration e = d.keyEnumerator();
key = e.nextElement();
b.append(d.objectForKey(key));
while(e.hasMoreElements())
{
key = e.nextElement();
b.append(joinKey)
if (showKey)
b.append(key + joinPair);
b.append(d.objectForKey(key));
}
return b.toString();
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden