You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ofbiz.apache.org by Christopher Snow <sn...@snowconsulting.co.uk> on 2010/04/21 23:14:09 UTC

getting parent component name

Is it possible to get the name of the component that an entity belongs 
too?  E.g. something like:

Delegator delegator = (Delegator) request.getAttribute("delegator");
ModelReader reader = delegator.getModelReader();
ModelEntity entity = reader.getModelEntity("myEntity");
// return the name of the component that an entity belongs to
String entityComponent = entity.getComponentName();

Many thanks in advance,

Chris

Re: getting parent component name

Posted by Bob Morley <rm...@emforium.com>.

Adrian Crum wrote:
> 
> You can get the file's location - look at Entity Reference in Web Tools.
> 
> -Adrian
> 
> Christopher Snow wrote:
>> Is it possible to get the name of the component that an entity belongs 
>> too?  E.g. something like:
>> 
>> Delegator delegator = (Delegator) request.getAttribute("delegator");
>> ModelReader reader = delegator.getModelReader();
>> ModelEntity entity = reader.getModelEntity("myEntity");
>> // return the name of the component that an entity belongs to
>> String entityComponent = entity.getComponentName();
>> 
>> Many thanks in advance,
>> 
>> Chris
>> 
> 
> 

Somewhat from memory; I think the delegator has a getModelReader that has
the resources that were used to load the entities.  The resource handler
would have the file that was used to load the entities (if it was a file) --
what I mean here is that Ofbiz typically uses an xml representation of the
model defined in each component; but I would suggest it does not have to be
this way.  The model could be built dynamically -- what comes to mind is the
modeling of Screen/Form that is built for a survey where the model is
assembled in memory based on database artifacts to build up the form.

Perhaps your use case could rely on something in the model entity definition
itself such as the package-name?  This is likely spotty as well; but I know
we use this in-house when doing code generation on the entity model.
-- 
View this message in context: http://n4.nabble.com/getting-parent-component-name-tp2019708p2019983.html
Sent from the OFBiz - User mailing list archive at Nabble.com.

Re: getting parent component name

Posted by Adrian Crum <ad...@hlmksw.com>.
You can get the file's location - look at Entity Reference in Web Tools.

-Adrian

Christopher Snow wrote:
> Is it possible to get the name of the component that an entity belongs 
> too?  E.g. something like:
> 
> Delegator delegator = (Delegator) request.getAttribute("delegator");
> ModelReader reader = delegator.getModelReader();
> ModelEntity entity = reader.getModelEntity("myEntity");
> // return the name of the component that an entity belongs to
> String entityComponent = entity.getComponentName();
> 
> Many thanks in advance,
> 
> Chris
>