Re: D2W and rule controlled visibleEntityNames
Re: D2W and rule controlled visibleEntityNames
- Subject: Re: D2W and rule controlled visibleEntityNames
- From: Ramsey Gurley <email@hidden>
- Date: Wed, 09 Nov 2011 11:25:20 -0700
It should still work. The QueryAllPage is the page component. The MenuHeader is a child component of the QueryAllPage. All D2W pages have a session. So, in your deployment properties located at
/etc/WebObject/[ApplicationName]/Properties
add a property like
com.mydomain.application.region=europe
or whatever. Each deployment properties file will be specific to the deployment on that machine. In your Application class, add a method like:
public String region() { return ERXProperties. stringForKey("com.mydomain.application.region"); }
Then in your rules, specify
100: session.context.page.application.region = 'europe' => visibleEntityNames = ('Entity1', 'Entity2') [Assignment]
100: session.context.page.application.region = 'na' => visibleEntityNames = ('Entity2', 'Entity3') [Assignment]
That should be sufficient to find the proper region in your d2w pages.
Ramsey
On Nov 9, 2011, at 2:16 AM, Markus Ruggiero wrote:
>
> On 08.11.2011, at 17:33, Ramsey Gurley wrote:
>
>> If it is a per application setting, then it should be on your application class. You could set this value through your properties file, so you could supply a different value per deployment.
>>
>> You're right, it doesn't belong in the page wrapper. On the app, you could reach it in a rule using session.context.page.application.region. There may be a shorter way to get to that, but I've never needed an application value in my rules before.
>>
>> Ramsey
>>
>
> Thanks Ramsey, but I don't understand your suggestion. Please bear with me.
> I have a property that passes the region code to the app (currently done via a properties file, could be done via command line). The problem is that the rule to find visibleEntityNames fires twice (which I understand). The first time it fires right after clicking login on Main (which is session less). At that moment I have not yet pushed the region code into D2WContext. This rule firing is used to populate the entities popup in MenuHeader. This list is then cached. The second time the rule fires is when the default QueryAllPage is generated. At that moment the region code has been set (as per my code in awake of PageWrapper) and the correct list of visibleEntityNames is retrieved. So my question is: how can I set the region code early enough? What is the first moment I have access to D2WContext so that I can push a value for "region" into it. An how do I access D2WContext.
>
> Thanks
> ---markus---
>
>>
>> On Nov 8, 2011, at 3:22 AM, Markus Ruggiero wrote:
>>
>>> I am trying to control the list of visible entities through a rule file. That works as expected. However the same app is deployed in several regions. Each region has its own requirements for the visibleEntityNames. So I create a key "region" in the D2WContext and use this in various places throughout the app to show/hide (non-)relevant fields. I inject the region-key into the D2WContext in the pageWrapper awake() (probably overkill)
>>>
>>> public void awake() {
>>> super.awake();
>>> D2WContext ctx = d2wContext();
>>> if (ctx != null) {
>>> Application application = (Application)Application.application();
>>> String region = "UNKNOWN";
>>> if (application.isEurope()) {
>>> region = "europe";
>>> }
>>> else if (application.isPefa()) {
>>> region = "pefa";
>>> }
>>> else if (application.isNorthAmerica()) {
>>> region = "na";
>>> }
>>> ctx.takeValueForKey( region, "region" );
>>> }
>>> }
>>>
>>> It works everywhere except for visibleEntityNames. Obviously this list is built before the first pageWrapper is instantiated. At that moment region is not yet set. The resulting list of entities is never rebuilt later, so my rule
>>>
>>> region="europe" => visibleEntityNames=....
>>>
>>> never fires. How can I solve this? When is the list of entity names built? Where would I have to inject the region key into the D2WContext for the proper rule to fire?
>>>
>>> Thanks
>>> ---markus---
>>>
>>>
>>> _______________________________________________
>>> 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