| Author |
Message |
|
|
Post subject: Accessing Foreign Keys in customization template
Posted: Mar 29, 2012 - 04:50 PM
|
|
Joined: Feb 20, 2012
Posts: 11
|
|
Hello,
I am modifying the template crudEdit.jet to include a way to select a parent object without knowing the id, namely a "popup" list of values on which you double click the object's description and it assigns the textbox its id.
Anyways, by now I am able to read the child object's relationships and see if they are one to many or one to one and get the parent object's primary key but I was wondering if there is a way to get the child object's foreign key fields.
Is this possible?
Something like $fieldRelatedType/@primaryKey = 'true' in the example below but rather $dataType/@foreignKey = 'true' or similar...
| Code: |
...
<jet:iterate select="$dataType/relationships" var="relationship">
<jet:setVariable select="$relationship/targetDataType" var="relatedType" />
<jet:choose>
<jet:when test="string($relationship/@cardinality) = 'MANY'">
<!-- do nothing -->
</jet:when>
<jet:otherwise>
<jet:iterate select="$relatedType/fields" var="fieldRelatedType">
<jet:choose>
<jet:when test="string($fieldRelatedType/@primaryKey) = 'true'">
...
|
Thanks for your time! |
|
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Apr 06, 2012 - 11:41 PM
|
|

Joined: Apr 04, 2011
Posts: 196
|
|
Sorry, but it doesn't look like it's posible to do by querying a property on the model.
The DataType has these properties:
fields
relationships
modifiers
annotateGetters
persistent
The Field has these properties:
primaryKey
dataType
description
collection
name
initialValue
type
visibility
modifiers
The Relationship has these properties:
targetDataType
reverseRelationship
cardinality
parentDataType
description
collection
name
initialValue
type
visibility
modifiers
The only way I can think to do it is to iterate the relationships looking for primary keys that match the fields in the current data type. |
_________________ Cindy
MyEclipse for Spring Support
|
| |
|
|
|
 |
|
|
Post subject:
Posted: Apr 10, 2012 - 05:44 PM
|
|
Joined: Feb 20, 2012
Posts: 11
|
|
Thanks! I was doing exactly what you suggested but I wanted to know if there was a "more proper" way of doing it. |
|
|
| |
|
|
|
 |
|
|
| |