• 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: Dynamically append CSS class in D2W
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamically append CSS class in D2W


  • Subject: Re: Dynamically append CSS class in D2W
  • From: Fabian Peters <email@hidden>
  • Date: Tue, 24 Jan 2012 16:46:23 +0100

Hi list, hi David,

>> I'm open to suggestions, but I don't think ERMDDefaultCSSAssignment currently supports CSS appending.

I've played a bit more with this and created my own subclass to override classForAttributeColumn:

    public String classForAttributeColumn(D2WContext c) {
        String base = (String) c.valueForKey("baseClassForAttributeColumn");
        String auxiliaryCssClass = (String) c.valueForKey("auxiliaryCssClass");
        base = base + " " + cssClassForPropertyKey(c.propertyKey()) + base;
        if (auxiliaryCssClass != null) {
            base = base + " " + auxiliaryCssClass;
        }
        return base;
    }

Using two rules, I get what I want:

100 : (pageConfiguration = 'ListSalesOrder' and propertyKey = 'customer.id') => classForAttributeColumn = <ERMDDefaultCSSAssignment> [com.elumo.d2w.assignments.ELCSSAssignment],
100 : (pageConfiguration = 'ListSalesOrder' and propertyKey = 'customer.id') => auxiliaryCssClass = object.customer.paymentBehaviour [er.directtoweb.ERDDelayedKeyValueAssignment],

But, surprisingly for me, I have to declare "object" as a dependant key for it to work:

    @SuppressWarnings("unchecked")
    protected static final NSDictionary keys = ERXDictionaryUtilities.dictionaryWithObjectsAndKeys( new Object [] {
            new NSArray(new Object[] {"object"}), "classForAttributeColumn"
    });

I thought that since I'm using ERDDelayedKeyValueAssignment in the second rule, this should not be necessary? Then again, I guess by default my assignment would be caching according to the dependant keys in the superclass?

Anyway, as this is my first foray into writing assignments - is this an OK approach or could this be handled differently?

Fabian

P.S.: I got really confused when rules I had disabled in RuleModeler were being evaluated and in the course changed the caching behaviour. Is this normal?


> Ok, thanks! I wasn't sure whether I overlooked something.
>
>> Could you do something like:
>>
>> 100 : (pageConfiguration = 'EditProduct' and object.isEditingClone = 1) => classForHeader = "Header EditHeader EditProductHeader EditProductHeaderClone"
>
> Sure, but this gets used on a number of entities and I have other conditions which make use of some CSS to mark certain conditions. I'll see whether I can keep it simple, otherwise I'll play with an addition to ERMDDefaultCSSAssignment.
>
> Thanks, Fabian
>
>> On 2012-01-23, at 10:54 AM, Fabian Peters wrote:
>>
>>> Hi,
>>>
>>> I'm setting a CSS class via a rule like:
>>>
>>>  100 : (task = 'edit' and object.isEditingClone = 1) => classForHeader = editingClone [com.webobjects.directtoweb.Assignment]
>>>
>>> The above works fine, but it of course removes all existing classes on the header div:
>>>
>>> <div class="Header EditHeader EditProductHeader"> => <div class="editingClone">
>>>
>>> Is there a "pretty good practice" to handle this in a generic fashion (read: on headers, rows etc.) so that the new class only gets appended?
>>>
>>> I looked at ERMDDefaultCSSAssignment and came up with baseClassForXY, but this also does not do exactly what I'm looking for. Which made me think about using a subtask like "cloned", so that it would get included via ERMDDefaultCSSAssignment. But the required configuration seems too much of a hassle right now (probably because I have no experience with using custom subtasks).
>>>
>>> Any input much appreciated,
>>>
>>> Fabian
>>> _______________________________________________
>>> 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


References: 
 >Dynamically append CSS class in D2W (From: Fabian Peters <email@hidden>)
 >Re: Dynamically append CSS class in D2W (From: David LeBer <email@hidden>)
 >Re: Dynamically append CSS class in D2W (From: Fabian Peters <email@hidden>)

  • Prev by Date: Re: new system: all installed, but eogeneration is a no-op
  • Next by Date: ERD2W qualifying restrictingFetchSpecification
  • Previous by thread: Re: Dynamically append CSS class in D2W
  • Next by thread: Re: my embedded ERXD2WList crashes.
  • Index(es):
    • Date
    • Thread