Re: Formatter, WORepetition for rawRowsSQL results
Re: Formatter, WORepetition for rawRowsSQL results
- Subject: Re: Formatter, WORepetition for rawRowsSQL results
- From: David LeBer <email@hidden>
- Date: Thu, 6 Oct 2005 14:02:05 -0400
On 6-Oct-05, at 11:56 AM, Janice Cheung wrote:
Hi David,
The reason why I have to use raw rows is for creating PDF
reports using ReportMill, which takes the raw sql
keys and data (DNS_NAME, MODEL, etc) and outputs into an XML
file, returning nicely into defined report
templates.
Hmm, OK.
I've used ReportMill in the past and never had to revert to raw rows.
<http://www.reportmill.com/support/docs/WebObjects.pdf>
I can access the objects as m_strDvDepts.VENDOR,
m_strDvDepts.DNS_NAME, m_strDvDepts.MODEL, etc..
but these appear as an array (ie,
("IBM","IBM","IBM","IBM","IBM","IBM","IBM")) rather than in a table-
like
structure from a WORepetition.
Well that shows that you key-value coding is working.
Is there any way around rendering my WORepetition using the raw
rows rather than creating a fetch spec?
I checked the item binding, and no matter how many permutations
of "server" to item, and "m_strDvDepts"
to list, I can't seem to get my data outputted properly,
although my data is appearing in a horrifically messy array.
Yes, as I mentioned before. The 'item' bound to your WORepetition
needs to be an NSMutableDictionary. Then it should work.
//Java
public NSMutableDictionary server;
//.WOD
Repetition1: WORepetition {
item = server;
list = m_strDvDepts;
}
Bindings to the WOStrings (or whatever) in the WORepetion should be
like this:
String1: WOString {
value = server.VENDOR;
}
String2: WOString {
value = server.DNS_NAME;
}
//etc
Thanks again for trying to help me and for your insightful advice..
Best regards,
Janice
David LeBer wrote:
On 6-Oct-05, at 10:38 AM, Janice Cheung wrote:
Greetings!
How do I format my array of raw rows of SQL results using a
formatter in a WORepetition?
Here is my function:
public void fetchSixtyEx()
{
Session s = ((Session)session());
String sql = new String("select distinct DNS_NAME,
WARRANTY_EXP_DATE, MODEL_TYPE, WARRANTY_TYPE, IP, VENDOR, MODEL,
TAG, SERIAL_NUMBER
from server_mgmt_db.SERVER,a_db.V_DEVICE");
sql += " where SERVER.DEVICE_FK = V_DEVICE.DEVICE_ID";
sql += " and SERVER.WARRANTY_EXP_DATE < SYSDATE+60 and
SERVER.WARRANTY_EXP_DATE>=SYSDATE";
NSArray results = EOUtilities.rawRowsForSQL(session
().defaultEditingContext(), "server_mgmt", sql);
setM_strDvDepts((NSArray) results);
}
This is my error:
Error: java.lang.IllegalArgumentException: While trying to
set the field "server" on an object of type ViewServerReport we
expected a
Server but received a
com.webobjects.foundation.NSMutableDictionary with a value of
{MODEL_TYPE = "eServer x335"; DNS_NAME = "N114";
WARRANTY_EXP_DATE = 2006-06-15 04:00:00 Etc/GMT; SERIAL_NUMBER =
"ABCDE"; IP = "123.456.78.106"; VENDOR = "IBM"; MODEL = "xSeries
335 Intel Xeon"; TAG = "111423"; WARRANTY_TYPE = "24x7x4"; }.
This often happens if you forget to use a formatter.
However, I am using a formatter - well .. I am using a
WORepetition, with list attribute defined with a "m_strDvDepts"
binding,
and item attribute with a "server" binding. In this
repetition, I am trying to retrieve string "server.dnsAlias". I
tried putting in
string "DNS_ALIAS" (as retrieved from the sql query) but to
no avail. How can I get my WORepetition to properly format the
results of
my SQL query? How do I get the object keys for DNS_NAME,
WARRANTY_EXP_DATE, MODEL_TYPE, WARRANTY_TYPE, VENDOR,
MODEL, TAG, SERIAL_NUMBER to be displayed?
Thank you for helping me. Any advice and guidance is
greatly appreciated!
Best regards,
Janice
Well...
First I am going to assume you have a *very* good reason for
using raw rows at this point rather than just creating a fetch
spec and doing this the 'WebO way', cause from the complexity of
your fetch I cannot see it.
Secondly...
EOUtilities.rawRowsForSQL(ec, modelName, sqlstring) is
deprecated. You should use:
EOUtilities.rawRowsForSQL(EOEditingContext ec,
String modelName,
String sqlString,
NSArray keys)
The NSArray of keys allows you to specify the attribute keys in
the dictionaries returned by your fetch.
Thirdly...
The error is telling you it is not receiving a Server object when
it expects to, rather it is receiving an NSMutableDictionary.
Which is what you get when you do a raw rows fetch (an array of
dictionaries).
Check the item binding for your repetition. I bet it is a Server
object.
Fourthly...
No, really, do this with a fetch spec... That'll give you
Objects, which is the Objects part of Web*Objects*. It'll make
your life MUCH easier.
--
;david
--
David LeBer
"I am codeferous!"
Codeferous Software
site: http://www.codeferous.com
blog: http://david.codeferous.com
_______________________________________________
WebObjects-dev mailing list
email@hidden
http://www.omnigroup.com/mailman/listinfo/webobjects-dev
--
;david
--
David LeBer
"I am codeferous!"
Codeferous Software
site: http://www.codeferous.com
blog: http://david.codeferous.com
_______________________________________________
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