Re: Accessing single element from NSArray of objects
Re: Accessing single element from NSArray of objects
- Subject: Re: Accessing single element from NSArray of objects
- From: Randall Perry <email@hidden>
- Date: Tue, 13 Apr 2004 14:51:41 -0400
> You can't do anything even slightly complicated in bindings alone.
> You need to write Java code to do what you want, and write bindings
> to a method or variable in your WOComponent java code. In Java, to do
> that, it would be something like:
>
> EOEnterpriseObject eo = (EOEnterpriseObject) CustInfo.objectAtIndex(0);
> //Warning: it is Java convention to name variables with initial lower case;
> //you will confuse other developers using an upper case variable name like
Yeah, I tried using lower case but when I added the binding to ResultPage.wo
it made it upper.
> that
> String value = eo.cust();
>
> You could provide a method that did that and returned the value, and
> bind to that method in your WOComponent.
>
Ok, created the following method in ResultPage.java:
public String getCust()
{
EOEnterpriseObject eo = (EOEnterpriseObject) CustInfo.objectAtIndex(0);
String value = eo.cust();
return value;
}
When I compile I get the error "Cannot resolve symbol: method cust()"
I also tried:
String value = eo.cust;
And got similar error.
So there's no shorthand to directly access an object property within an
array of objects? I can do it in one line in perl, php.
> If you haven't yet, the Apple WO tutorial introduction called I
> think, "Developing Web Applications", is pretty good and worth a
> read.
>
> --Jonathan
>
> At 12:11 PM -0400 4/13/04, Randall Perry wrote:
>> I've got an NSArray var, custInfo, which fetches an array of objects via a
>> direct action:
>>
>> custInfo = ec.objectsWithFetchSpecification(fetchSpec);
>>
>> It then loads a component page passing the array:
>>
>> ResultPage nextPage = (ResultPage) pageWithName("ResultPage");
>> nextPage.takeValueForKey(custInfo, "CustInfo");
>> return nextPage;
>>
>> On ResultPage I can access a single element of all obj arrays by setting
>> it's value to a property:
>> CustInfo.cust
>>
>> But, how do I access a property of a single row? I tried this, but it throws
>> an exception:
>> CustInfo[0].cust
>>
>>
>>
--
Randall Perry
sysTame
Xserve Web Hosting/Co-location
Website Development/Promotion
Mac Consulting/Sales
http://www.systame.com/
_______________________________________________
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.