Re: Is there a way to create rules programatically?
Re: Is there a way to create rules programatically?
- Subject: Re: Is there a way to create rules programatically?
- From: Ramsey Gurley <email@hidden>
- Date: Mon, 16 Jan 2012 13:23:48 -0700
localizer().takeValueForKey("The metric Name", "prt_quant_XX");
I'll bet you can even EOKeyValueCodingAdditions.Utility.takeValuesFromDictionary(localizer(), sessionDictionary);
Also, what David said.
Ramsey
On Jan 16, 2012, at 1:02 PM, David LeBer wrote:
> Why don't you do the same kind of thing for your propertyName component?
>
> Create a custom propertyName component that looks at the property key, if it matches "rpt_quant_XX-*" do your logic on it to extract the name, otherwise use default to ERMD2WPropertyName behaviour. Set it as the default propertyName component for the page.
>
> 100 : pageConfiguration = 'ListFoo' => propertyNameComponentName = "SooperSmartPropertyName" [com.webobjects.directtoweb.Assignment]
>
> --
> David LeBer
> Codeferous Software
>
> On 2012-01-16, at 2:23 PM, James Cicenia wrote:
>
>> I create an array of report keys from the Admin ->Metrics table for that session and that report:
>>
>> Sample Key:
>> rpt_quant_01-The metric Name
>>
>> rpt_quant tells me it is a quant metric and to use my custom property component.
>> I then parse the name after "rpt_quant_XX-", i.e. "The metric Name", this is then used to find the value. Works great. Maybe a bad approach?
>>
>> So now I move onto the displayName. Boom stuck.
>>
>> Though can Localizable.strings be dynamically created in the session?
>>
>> Thanks
>> James
>>
>>
>>
>> On Jan 16, 2012, at 12:52 PM, Ramsey Gurley wrote:
>>
>>>
>>> On Jan 16, 2012, at 11:22 AM, 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.
>>>
>>> I guess that's what has me confused. Where are you getting displayPropertyKeys if you don't know ahead of time? Are you doing something like
>>>
>>> 100: entity.name = "Report" => displayPropertyKeys = "session.reptHdrDict.allKeys"
>>>
>>> ? Where is that getting loaded? Because if you want the values to be the displayed headers, then you can teach your localizer the values when you load the dictionary, no?
>>>
>>>>
>>>> It works like a charm to fill in the list, but it is the displayNameForProperty that is confusing me.
>>>
>>> The displayNameForProperty is going to come out of Localization. So if you know what the possible keys are, then there's no problem. Just add this to your Localizable.strings file
>>>
>>> "PropertyKey.metricA" = "Metric A";
>>> "PropertyKey.metricB" = "Metric B";
>>>
>>>>
>>>>
>>>> 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
>>>>>>>>>
>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> 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
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> 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
>>>>>>
>>>>>> _______________________________________________
>>>>>> 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
>>>>>
>>>>
>>>> _______________________________________________
>>>> 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
>>>
>>
>> _______________________________________________
>> 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
>
_______________________________________________
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