Try this:

Implement your own D2WModel the way you like but make sure you can actually add 
remove rules to your model. Perhaps you need to define your own methods similar 
to "addMyRule" or "removeMyRule" etc.

Override application's didFinishLaunching() method and add following code.

@Override
public void didFinishLaunching() {
        super.didFinishLaunching();
        D2WModel.setDefaultModel(MyD2WModel.singleton());
}

>From this point and onwards I hope you'll be able to use your dynamic rules in 
>d2w components as well. Even if you add rules to by adding / removing rules in 
>your code anywhere using MyD2WModel.singleton().addMyRule(...) will affect the 
>behaviour of d2w components.

Farrukh

On 2012-01-16, at 4:52 PM, James Cicenia wrote:

> You already seem experienced in this manner!  :-)
> 
> I could see how this works. Creating my own on the fly rule model could solve 
> the problem.
> 
> But like you said... where? 
> 
> Have to be session specific.
> 
> James
> 
> 
> On Jan 15, 2012, at 1:50 AM, Farrukh Ijaz wrote:
> 
>> It's possible. You need to play around with the D2WContext, D2WModel and 
>> Rule classes.
>> 
>> Start with creating your own D2WModel class since it has methods to update 
>> Rules.
>> 
>> public class MyD2WModel extends D2WModel {   
>>      public MyD2WModel(NSArray<Rule> rules) {
>>              super(rules);
>>      }
>>      public void addMyRule(Rule newRule) {
>>              super.addRule(newRule);
>>      }
>> }
>> 
>> You can override other methods as needed.
>> 
>> I would suggest implement a singleton pattern for MyD2WModel, and use that 
>> whenever you want to infer keys. Whenever you need to access D2WContext with 
>> your rules, do something like this:
>> 
>> D2WContext d2wContext = new D2WContext(session);
>> d2wContext._setModel(MyD2WModel.singleton());
>> 
>> Just hack around and see where you need to place it to make it accessible in 
>> your templates. May be some guru out there can point out the exact place to 
>> hack ;)
>> 
>> Have fun coding!
>> 
>> Farrukh
>> 
>> On 2012-01-13, at 8:20 PM, James Cicenia wrote:
>> 
>>> Ok, is it possible to dynamically load up a rule set?
>>> 
>>> If that is possible I could create the a rule for each dynamic key.
>>> 
>>> Thanks
>>> James
>>> 
>>> 
>>> 
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list      ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/webobjects-dev/farrukh.ijaz%40fuegodigitalmedia.com
>>> 
>>> This email sent to [email protected]
>> 
> 
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list      ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/farrukh.ijaz%40fuegodigitalmedia.com
> 
> This email sent to [email protected]

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

This email sent to [email protected]

Reply via email to