On May 30, 2012, at 1:59 AM, Paul Hoadley wrote:

> Hi Ramsey,
> 
> On 30/05/2012, at 10:06 AM, Ramsey Gurley wrote:
> 
>> It shouldn't have made it to the dataSource() method. You should log what 
>> rules are firing for restrictedChoiceKey.  Open your log4j page and set up a 
>> d2w rule logger for that key. See what the console tells you when you load 
>> the page.
> 
> Ah, OK, this is subtle.  As I mentioned, this is an attribute I'm adding to 
> the model at runtime (Organisation.billingStatus).  As such, the Organisation 
> class knows nothing about it, and I don't get the opportunity to set a 
> default value.  So when the page calls object.billingStatus.allValues to get 
> the values for the drop-down, it gets a null at billingStatus.  Adding this 
> third line works:
> 
>             EditPageInterface epi = 
> D2W.factory().editPageForNewObjectWithEntityNamed(Organisation.ENTITY_NAME, 
> session());
>             epi.setNextPage(session().context().page());
>             ((ERMODWizardCreationPage) 
> epi).object().takeValueForKey(BillingStatus.Billed, "billingStatus");
> 
> But obviously that's going to be brittle—casting the EditPageInterface to an 
> ERMODWizardCreationPage.  (I don't see myself changing looks any time soon, 
> so it will work indefinitely, but it's still ugly.)  Got any better ideas?

Create a method called availableBillingStatuses() on the eo. It returns the 
list of possible billing statuses the object can have in its current state. 
Then just use object.availableBillingStatuses. 

Not only does that solve the problem, but it permits the removal of statuses 
that don't make sense. For example, if amountDue == $0, then billingStatus == 
PAST_DUE doesn't make sense.


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (Webobjects-dev@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to