Thanks for the input - a couple of questions on this.
1) Can't find ResourceManagerAdditions - what do I need to add?
2) Although not relevant for what I want to do, the frameworkName parameter
isn't used.
Thanks
Mark
On 3 Jan 2010, at 02:24, Chuck Hill wrote:
> Hi Mark,
>
> This not part of WO, possibly due to concerns about efficiency and
> optimization (see JavaDoc below). You can add a method to your component (or
> better, to a custom super class) to achieve this:
>
> /**
> * Allows a component to "inherit" the template (.html and .wod files)
> from another component.
> * <p>Usage:</p>
> * <pre>
> * public WOElement template() {
> * return inheritTemplateFrom("AddAddress", "CoreUI");
> * }
> * </pre>
> * This very simple implementation does have some limitations:
> * <ol>
> * <li>It can't he used to inherit the template of another component
> inheriting a template.</li>
> * <li>It can't handle having two components with the same name in
> different packages</li>
> * <li>It does not use WO template caching</li>
> * </ol>
> *
> * @see com.webobjects.appserver.WOComponent#template()
> *
> * @param componentName the name of the component whose template will be
> inherited
> * @param frameworkName name of the framework the component is in, or null
> if in the application
> * @return the template form the indicated component
> */
> public WOElement inheritTemplateFrom(String componentName, String
> frameworkName)
> {
> String componentPath = componentName + ".wo/" + componentName + ".";
> String htmlString =
> ResourceManagerAdditions.stringFromResource(componentPath + "html", null,
> session().languages());
> String wodString =
> ResourceManagerAdditions.stringFromResource(componentPath + "wod", null,
> session().languages());
> return WOComponent.templateWithHTMLString(htmlString, wodString,
> session().languages());
> }
>
>
> Enjoy!
>
>
> Chuck
>
>
> On Jan 2, 2010, at 6:20 PM, Mark Woollard wrote:
>
>> Maybe expanding will make things clearer...
>>
>> There is a base component FieldEditor which does in-place editing using the
>> AjaxInPlace component + 2 ERXWOTemplate instances for the edit and view
>> modes. I then am wanting to derive from this to create StringFieldEditor /
>> IntegerFieldEditor / etc that specialize the java to provide view and edit
>> values in different ways as required. The html in FieldEditor component
>> doesn't need to change, and it doesn't make sense to me to have multiple
>> copies in the derived classes. What I'd like to happen is the base class
>> html be used and the overridden getter methods in the derived java class
>> provide the data for display. Is this an approach that applicable to WO? If
>> not how would this be approached to limit duplication of code / html?
>>
>> Thanks
>> Mark
>>
>>
>> On 3 Jan 2010, at 02:04, Andrew Lindesay wrote:
>>
>>> Hi Mark;
>>>
>>> If I understand you correctly, I would typically create smaller re-usable
>>> components to put into two different larger components.
>>>
>>> cheers.
>>>
>>>> I have a component (java/html/api/woo/wod) and want to create a derived
>>>> component that specialises some of the java functionality, but doesn't
>>>> need to modify the html of the base component. I can't figure out how to
>>>> get the derived component to return the base class html since the derived
>>>> classes just extend the java class.
>>>
>>> ___
>>> Andrew Lindesay
>>> www.lindesay.co.nz
>>>
>>
>> _______________________________________________
>> 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/chill%40global-village.net
>>
>> This email sent to [email protected]
>
> --
> Chuck Hill Senior Consultant / VP Development
>
> Practical WebObjects - for developers who want to increase their overall
> knowledge of WebObjects or who are trying to solve specific problems.
> http://www.global-village.net/products/practical_webobjects
>
>
>
>
>
>
>
_______________________________________________
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]