Re: How does ERXComponentContent get access to the parent component...
Re: How does ERXComponentContent get access to the parent component...
- Subject: Re: How does ERXComponentContent get access to the parent component...
- From: Johann Werner <email@hidden>
- Date: Tue, 13 Nov 2012 10:04:16 +0100
Hi Louis,
Am 07.10.2012 um 07:43 schrieb Louis Demers <email@hidden>:
> Hi,
>
> I have a lot of different hierarchical data ( Bill of Materials or BOM, Manifest, Revisions ...) So I wanted to write a generic Hierarchy component that would iterate through the relationships to build the hierarchy. I would then reuse this component, properly configured with keypaths and simply design new display components (BOMCell, RevisionCell, ManifestCell...) for each types of data I need to display.
> I assume that ERXComponentContent is the key or at least part of the solution
>
> <wo:Hierarchy rootObject="$ro">
> <wo:BOMCell />
> </wo:Hierarchy>
>
> <wo:Hierarchy rootObject="$ro">
> <wo:RevisionCell />
> </wo:Hierarchy>
>
> etc.
>
>
> In my Hierarchy.wo I have
>
> <wo:loop list="$children" item= "$aChild">
> <wo:ERXWOComponentContent />
> </wo:loop>
>
> Or even have it recurse down the tree...
>
> <wo:loop list="$children" item= "$aChild">
> <wo:Hierarchy rootObject="$aChild">
> <wo:ERXWOComponentContent />
> </ wo:Hierarchy>
> </wo:loop>
>
>
> I imagine my BOMCell would look like
>
> <div>
> [
> <wo:string value="$^aChild" />
That would only work if BOMCell had a binding "aChild" (besides being non-synchronizing or stateless) which it doesn't.
You could create an interface for the hierarchy class, lets say IRootObjectProvider and call parent() in your BOMCell checking for that interface and if the parent component does implement it get the object to work with (otherwise probably throw an exception or just do nothing).
public class Hierarchy extends ERXComponent implements IRootObjectProvider {
public EOEnterpriseObject rootObject;
…
public EOEnterpriseObject rootObject() {
return rootObject;
}
}
public class BOMCell extends ERXStatelessComponent {
…
public EOEnterpriseObject rootObject() {
WOComponent parent = parent();
if (parent instance of IRootObjectProvider) {
return ((IRootObjectProvider)parent). rootObject();
}
return null;
}
}
> ]
> </div>
>
> I've looked through similar components in Wonder and I can't seem to get it to work. My problem seems to be that my BOMCell component never gets to the node data...
>
> I also investigated making Hierarchy a ERXDynamicComponent without success, but I suspect that too would be a clean way of doing it.
>
> Thanks for any clues...
>
>
> Louis Demers eng.
> www.obzerv.com
_______________________________________________
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