rawRowsForSQL and WORepetition
rawRowsForSQL and WORepetition
- Subject: rawRowsForSQL and WORepetition
- From: Michael Engelhart <email@hidden>
- Date: Thu, 22 Apr 2004 13:42:38 -0500
Hi -
I'm converting some JDBC/Servlet code over to WO for testing purposes
and have a question.
I need to use rawRowsForSQL (at least I think I do) for a query that
looks like this when viewed as a PreparedStatement in regular JDBC
code:
"SELECT code, name FROM countries WHERE code IN (SELECT DISTINCT
country FROM hotels) AND name LIKE ? ORDER BY name"
When if I do this using rawRowsForSQL, the query works fine but what I
want to do is display this in a simple 2 column table that will show
the code attribute in the first column and the name attribute in the
second column. What I have is a DirectAction like this:
public WOActionResults countryListAction() {
String sql = "SELECT code, name FROM countries WHERE code IN (SELECT
DISTINCT country FROM hotels) AND name LIKE '" + (String)
request().formValueForKey("first_letter") + "%' ORDER BY name";
NSArray result =
EOUtilities.rawRowsForSQL(session().defaultEditingContext(),
"TestModel", sql);
CountryList countryListPage = (CountryList)
pageWithName("CountryList");
countryListPage.setCountryListResult(result);
return countryListPage;
}
which BTW I'm not sure is the correct way to handle this but seems to
do what I'm looking for as far as passing the information to the next
page. I have a binding called "first_letter" that gets passed in from
a WOHyperLink.
I know that rawRowsForSQL returns an NSArray of NSDictionary. What I
can't figure out is how to display this simple 2 column table. I've
created a binding called countryDictionary which is an NSDictionary and
I can display it by connecting it to WOString's in each table cell but
can't seem to break it out using NSDictionary.objectForKey or something
like that.
I'm just not convinced I'm even going about this the right way.
Thanks
Mike
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.