Hi Ted,

On 2-Dec-08, at 6:23 PM, Ted Archibald wrote:

Is there an easy way to add an id attribute to a D2W Component?

I assume you're talking about a property level component?

I don't know that I would call it "easy" but I think it can be done. Keep in mind I am no expert in D2W. :-)

In working through the source for ERD2WEditString I find that a maxLength binding has been created. How is it assigned? In the WOD you'll see it is bound to a d2wcontext key called maxLength.

EditString: WOTextField {
        size = length;
        value = value;
        maxlength = d2wContext.maxLength;
}

How is the d2wcontext told about the maxLength key? Here are some example rules referring to maxLength:

0 : *true* => maxLength = 255 [com.webobjects.directtoweb.Assignment],
0 : smartAttribute.width > 0 => maxLength = smartAttribute.width [er.directtoweb.ERDKeyValueAssignment], 10 : smartAttribute.className = 'java.math.BigDecimal' => maxLength = 30 [com.webobjects.directtoweb.Assignment], 100: (task = 'list' and entity.name = 'Comment' and propertyKey = 'textDescription') => maxLength = 50

It looks like the d2wclientConfiguration.plist (see the Resources folder of er.directtoweb) may need to be updated with your new attribute as well.

There are two entries related to maxLength in that file:

        ERD2WEditString = {
            comment = "there is no formatter used?";
            editors = (maxLength);
inspectionInformation = "Allows specifing the maxLength for a WOTextField.";
        };

       maxLength = {
class = "com.apple.client.directtoweb.TextFieldComponentConfigurationPanel";
            comment = "";
            editingFor = property;
            inputSize = 5;
            inspectionInformation = "";
            title = "Max Length";
            type = stringEmptyIsNull;
        };



Is the only way to subclass the component and do the work there or is
there a better way?

Based on the above, I'd say you'd need to subclass



I tried ERD2WCustomComponentWithArgs/ ERD2WStatelessCustomComponentWithArgs
but all I'm getting is a null pointer exception with the rules:
extraBindings = "{id = \"idTemp\"; }"
customComponentName = "ERD2WEditNumber" (plus I tried other variations
here as well)

Are extraBindings what you want here? I think that this is used by ERD components so that they can be used in non-D2W applications. I haven't seen examples of them being used, so I am not certain...

er.directtoweb.components.ERDCustomComponent
Base class of many custom components.
Has a lot of nifty features including resolving bindings against the rule system and inherits all the value pulling methods fromERXNonSynchronizingComponent. Subclasses should be able to run stand alone without a D2W context. This is achieved by pulling values first from the bindings, then from the d2wContext and finally from an "extraBindings" binding.

David




_______________________________________________
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/programmingosx%40mac.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