• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is there a way to create rules programatically?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is there a way to create rules programatically?


  • Subject: Re: Is there a way to create rules programatically?
  • From: Jesse Tayler <email@hidden>
  • Date: Mon, 16 Jan 2012 13:28:09 -0500


I think you want a significant key, perhaps something like 

session.unusuallyObtusePropertyKey 

in your rules.

if you add this key to D2Ws significant keys, it should always recalculate and you can return something different each call if you like.

ya?


On Jan 16, 2012, at 1:22 PM, James Cicenia wrote:

What I am trying to accomplish is to se the displayNameForProperty dynamically based upon the key.

So, somehow, pass the key that returns a value to displayNameForProperty.

Now I don't know what the property key is ahead of time. This comes from data in the session.

It works like a charm to fill in the list, but it is the displayNameForProperty that is confusing me.


Admin
  Metrics
Metric A
Metric B
Metric C
etc.


Current Portfolio
Project A
Metric Value A
Metric Value B
Metric Value C

Project B
Metric Value A
Metric Value B
Metric Value C


Report

Project  A    Metric A    Metric B   Metric C
.
.
.



Thanks
James


On Jan 16, 2012, at 12:02 PM, Ramsey Gurley wrote:

I'm still in the dark about what James is actually trying to accomplish.

100: propertyKey = 'metricA' => displayNameForProperty = "PropertyKey.metricA" [ERDLocalizedAssignment]

Why does that require a custom rule?

Ramsey

On Jan 16, 2012, at 10:51 AM, Jesse Tayler wrote:

I missed this thread, but don't you just want to identify significant keys which are calculated at runtime each time you fire the rule?



On Jan 16, 2012, at 12:20 PM, Farrukh Ijaz wrote:

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@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Is there a way to create rules programatically? (From: James Cicenia <email@hidden>)
 >Re: Is there a way to create rules programatically? (From: Farrukh Ijaz <email@hidden>)
 >Re: Is there a way to create rules programatically? (From: James Cicenia <email@hidden>)
 >Re: Is there a way to create rules programatically? (From: Farrukh Ijaz <email@hidden>)
 >Re: Is there a way to create rules programatically? (From: Jesse Tayler <email@hidden>)
 >Re: Is there a way to create rules programatically? (From: Ramsey Gurley <email@hidden>)
 >Re: Is there a way to create rules programatically? (From: James Cicenia <email@hidden>)

  • Prev by Date: Re: Is there a way to create rules programatically?
  • Next by Date: Re: Is there a way to create rules programatically?
  • Previous by thread: Re: Is there a way to create rules programatically?
  • Next by thread: Re: Is there a way to create rules programatically?
  • Index(es):
    • Date
    • Thread