Issue Getting Field Names to Display Correctly

I have a module in which I cannot get the field names to display properly. There have been times where it does work, but rarely.

For example, I have been able to get it to do this:

But most of the time it looks like this

The property record looks like this

Noun=Kafka Setting
Noun.Plural=Kafka Settings

Brokers.Name=Brokers (ADDRESS:PORT)
Enabled.Name=Enabled
UseStoreAndFwd.Name=Use Store & Forward
UseSSL.Name=Use SSL

Source.Name=Source
DispPath.Name=Display Path
SrcPath.Name=Source Path
AlarmsEnabled.Name=Enable Alarms

AuditEnabled.Name=Enable Audit

Category.Configuration=Producer Settings
Category.Alarms=Alarm Settings
Category.Audit=Audit Settings

Usage Looks like this

public class KafkaSettingsRecord extends PersistentRecord {

    public static final RecordMeta<KafkaSettingsRecord> META = new RecordMeta<KafkaSettingsRecord>(
            KafkaSettingsRecord.class, "KafkaSettingsRecord").setNounKey("KafkaSettingsRecord.Noun").setNounPluralKey(
            "KafkaSettingsRecord.Noun.Plural");

    public static final IdentityField Id = new IdentityField(META);

    //Kafka Settings
    public static final StringField BrokerList = new StringField(META, "Brokers", SFieldFlags.SMANDATORY);
    public static final BooleanField Enabled = new BooleanField(META, "Enabled").setDefault(false);
    public static final BooleanField UseStoreAndFwd = new BooleanField(META, "UseStoreAndFwd").setDefault(false);
    public static final BooleanField UseSSL = new BooleanField(META, "UseSSL").setDefault(false);

If anyone has experienced a similar issue in the past and has a way to fix it through code (not reseting the gateway) I’d appreciate the help fixing this non-critical, but visually very annoying problem.

Thanks,

Nick

I think this has been a development issue since the beginning… there is no fix I’m aware of aside from restarting the gateway, and there is no fix coming until this entire SORM/record system doesn’t exist any more in Ignition 8.2.

edit: although the underlying issue may be in the BundleUtil stuff… which is not part of the SORM system… hmm.

I do see this when installing the module. The module functionality is fine and we are able to get data up to Kafka, just the labels won’t cooperate:

Nick

Hmm. The issue I’m talking about is that basically on subsequent installs the properties can’t be resolved, like in your second screenshot.

After a gateway restart, and on any first install of the module when it doesn’t already exist, the properties resolve, right?

This gateway was fresh when I installed it (never had this module on it before) and the labels didn’t work.

I restarted just now via EAM and it didn’t make them show up.

Nick

Inside of the BundleUtil what should we be passing.

In this module which we use for buffered TCP messages, it’s like this based on the OPC-UA device driver example provided by IA:

BundleUtil.get().addBundle(BufferedTcpDevice.class);

That module has zero issues displaying the labels. However in the module I am having issues displaying the labels it is like this:

BundleUtil.get().addBundle("kafka", getClass(), "kafka");

Try this instead:

BundleUtil.get().addBundle("kafka", getClass().getClassLoader(), "kafka");

Don’t use BundleUtil with PersistentRecord properties. They load themselves. Name the properties file the same as the record’s class name with localization suffixes then .properties.

You’ll still need to restart the gateway if you modify the properties file, but otherwise should work automatically.

1 Like

I have never been able to resolve the issue of field names not appearing and have spent a good amount of time going over it without success so I'm coming back here once more.

The issues are in 2 places:

1 - Config and Status Screen Labels

image

image

2 - Configuration Fields

image

The resource structure looks like this:

image

a bundle is created and removed on start and shutdown in the gateway hook. Things such as the panel title are referenced like this:

    public KafkaSettingsPage(final IConfigPage configPage){
        super(configPage, null, new LenientResourceModel("kafka.nav.settings.panelTitle"),
                ((IgnitionWebApp) Application.get()).getContext().getPersistenceInterface().find(KafkaSettingsRecord.META, 0L)

        );
    }

I always get this error when loading the module which I think is related to the issue but I cannot prevent it from occurring so far:

java.util.MissingResourceException: Can't find bundle for base name com/walmart/ignition/gateway/kafka/kafka, locale en_US

Thanks,

Nick

Construct links for each .properties with the same name but suffixes _en and _en_US. It isn’t really a proper bundle for Ignition without the localization suffixes. At least, that’s what I’ve been doing for ages now.

{ I see I’m repeating myself. You didn’t take this earlier advice. }

It's not that I didn't take the advice, I'm just confused because I am trying to follow the SDK webpage example module (whose labels works perfect). I don't see _en_US anywhere in the SDK examples.

Gateway Webpage Example File Structure
image

Usage in Code

    public static final ConfigCategory CONFIG_CATEGORY =
        new ConfigCategory("HomeConnect", "HomeConnect.nav.header", 700);

I don't know what you mean by "construct links". Could you potentially show an example?

Thanks,

Nick

In Linux,

ln -s kafka.properties kafka_en.properties
ln -s kafka.properties kafka_en_US.properties

I quit using Windows for this sort of thing long before Windows had soft links. Perhaps just copy instead of linking.

I think there’s something else going on here. I’m currently building my modules without the language suffixes (correctly or not) and am able to get bundles working properly on my English language only system.

Are you restarting after your changes? I always make sure to uninstall/restart whenever messing with bundles.

As you’ve identified, your two issues are separate from each other - the KafkaSettingsRecord.properties is loaded for you, but your kafka.properties needs to be loaded yourself. Can we see your kafka.properties contents and your BundleUtil::addBundle call?

@bmusson I have tried the restart gateway thing but it never helps. In general its also not a solution that we’d want to rely on anyways because more often than not, we cannot just reset a server when we want since it will cause customer interruptions.

Here is the contents of kafka.properties:

We simply try to mimic what is in the gateway webpage example

nav.header=Kafka
nav.settings.title=Settings
nav.settings.panelTitle=Kafka Settings
nav.status.header=Kafka Status

KafkaSettingsRecord.Category.Configuration=Producer Settings
KafkaSettingsRecord.Category.Alarms=Alarm Settings
KafkaSettingsRecord.Category.Audit=Audit Settings

Here is where where Bundle Util is called at Gateway Hook Startup

    @Override
    public void setup(GatewayContext gatewayContext) {
        this.context = gatewayContext;
        log.debug("Beginning setup of Kafka module");

        BundleUtil.get().addBundle("kafka", getClass(), "kafka");

Here is where the bundle is removed at shut down

    @Override
    public void shutdown() {
        scriptModule.shutDownSinks();
        this.context.getAlarmManager().removeListener(this.alarmFilter, alarmListener);
        BundleUtil.get().removeBundle("kafka");
        log.info("Successfully removed data sinks from kafka module!");
    }

I’ve been trying to get these darn labels to work for a long time by looking at the gateway webpage module as a reference but so far I have been unsuccessful.

To IA’s credit, the gateway webpage example loads the labels perfectly the first time…

Thanks,

Nick

See my previous suggestion: Issue Getting Field Names to Display Correctly - #7 by Kevin.Herron

Also like it or not you will need to restart the gateway for any bundle changes. Use a dev gateway to develop and test your modules.

Sorry for not replying back then. I did try when you suggest it back then and I tried again today but this didn't work.

I am working in a gateway where I can restart freely (non-production use) and after I installed the new build, restarted via EAM. Unfortunately it doesn't make the labels appear correctly.

I'll keep working on it.....

Nick

I never did find the exact reason, but I ended up rebuilding the module from the gateway webpage example and then things started to show up correctly. Since all the code was copy and pasted over, it feels more like a project property/POM/other issue rather than any issue with the code itself.

In any case, the result is all that matters and it works now so I’m satisfied with that.

Nick

2 Likes

Running into the exact same issue right now...

The logs say

java.util.MissingResourceException: Can't find bundle for base name <module_name_here>, locale en_US

I tried add .classLoader() when registering the GatewayHook.class with BundleUtils, duplicating my property files with _en and _en_US suffixes, tried restarting the Ignition gateway service and still I get badly formatted labels on the gateway config page.

I started this whole process off by cloning the gateway-webpage module, building it and adding it to the gateway. Then I used Maven to set up a brand new project based off of the client-designer-gateway archetype, like so:

(quotes were requred around the flags and values on Windows)

mvn archetype:generate "-DarchetypeGroupId=com.inductiveautomation.ignitionsdk" "-DarchetypeArtifactId=client-designer-gateway-archetype" "-DarchetypeVersion=1.2.0"

I then went step by step through the gateway-webpage project and did the same thing for my new project. I was able to build a module, but now what I'm stuck at is none of the labels showing correctly.

@Kevin.Herron @pturmel when you say restart the gateway, you mean the Ignition service not the host machine, right?

Yes, just the service.

1 Like

I ended up resolving this issue by browsing the forums a little more and finding this comment by @Kevin.Herron that was key in fixing the label problems for me:

I cloned the gateway-webpage example (and added it as a module to my gateway to see how it works) and then immediately created a new project based on the client-designer-gateway-archetype. This then requires you to either set up a directory or package structure and for me, the issue was that the java and resources directories weren't 100% mirrored so some of the properties weren't being found.

Also, another thing that was tripping me up was that, for instance, in GatewayHook.java, we import the SettingsPage and SettingsRecord classes, but when you reference properties in that file (like nav.header and nav.settings.title - two of the labels that showed up incorrectly for me), they're actually coming from HomeConnect.properties, NOT HCSettingsRecord.properties.

If you set up everything correctly and you still get incorrect labels, you might need to do a gateway service restart. I restarted so many times (and repackaged the module) I don't know whether it would've worked the first time without a restart even if I had set everything up correctly.