Foreign Keys display JPA identifier rather than values in edit and browse

Edit and browse screens don’t show the value of foreign keys, but some JPA identifier.

What can I do to have this display the values?

Attached are screen shots

productbrowse

productedit

James,

Your problem is that you haven’t defined Instance Names for your entities. You can find it in CUBA Studio in the second tab of the entity designer.

Regards,

Aleksey

I have added an Instance Name for the org field, all I did was click on the field on the second tab.

It moved to the Name Pattern Attributes column

and there is now an annotation per attached

package com.digicerts.digicert.entity;
...
import com.haulmont.cuba.core.entity.BaseIntegerIdEntity;
import com.haulmont.chile.core.annotations.NamePattern;

@NamePattern("%s %s|org,unitMeasure")

I would expect some sort of annotation to be generated as per https://doc.cuba-platform.com/manual-6.1/entity_class_annotations.html

Reading

@NamePattern
Determines the way of getting the name of the instance returned by the Instance.getInstanceName() method.

The annotation value should be a string in the {0}|{1} format, where:

{0} – formatting string according to the String.format() rules, or this object method name with the prefix #. The method should return String and should have no parameters.
{1} – a list of field names separated by commas, corresponding to {0} format. If the method is used in {0}, the list of fields is still required as it forms the _minimal view.
Examples:

@NamePattern("%s|name")
@NamePattern("#getCaption|login,name")

I wonder if #getCaption should refer to a function
String getCaption(String login, String name)

On the right is says I can edit my source, but I can’t do that in Studio.

My objective is to display the org_cd field corresponding to the org_id chosen after choosing select.

productInstance

James,

It’s all explained in java docs with an example.

Regarding editing the sources, you shouldn’t do it in the Studio, but in your IDE. See this chapter of the documentation.

Finally, I would strongly recommend starting with our QuickStart guide, then move to the Hands on Lab. After completing these tutorials, which shouldn’t take longer than 3-4 hours, lot’s of things will be much more clear.

Regards,

Aleksey

Hi, What if we WANT to edit the sources within the Studio, and not in the IDE? It is annoying to have to open the page in the IDE and then come back and have the Studio have to reload the page, when all I might want to do is change a single element.

Hi @g.cook.a!

You can edit sources in Studio, however, it is not capable of auto-completing, refactoring and so on. We are trying to find the way to make developer’s experience better and, hopefully, in 2018 you will be able to work from a single IDE.

Regards,
Aleksey

Hi, thank you for the reply. What is the method for editing the Source from within Studio? Right now when I click the Source tab the code is read-only,

Hi @g.cook.a,

It works for screens and their controllers only.

Regards,
Aleksey

I have looked at https://github.com/cuba-platform/cuba/blob/d77b25a67dbd2e25fbaebdda0157beef6f091c70/modules/global/src/com/haulmont/chile/core/annotations/NamePattern.java

and

https://doc.cuba-platform.com/manual-6.2/qs_create_entities.html

And I fail to figure out how to get the value displayed.

In my case I have a foreign key mfr_id to mfr table with a unique mfr_cd

When displaying my product table I would like to display mfr.mfr_cd

create table mfr (
mfr_id serial primary key,
mfr_cd varchar(8),
unique(mfr_cd)
);

create table product (
product id serial primary key,
mfr_id integer references mfr);