Quantcast
Channel: Mendix Forum Questions
Viewing all articles
Browse latest Browse all 82395

SDK - Create page title

$
0
0

It appears the Mendix SDK creates empty page titles. Why is this happening?

I have the following function:

function setPageTitle(page: pages.Page, entity: domainmodels.Entity) {
let pageTitle = page.title;
if (pageTitle == null) {
    console.log('DEBUG: page title not found');
    pageTitle = texts.Text.createInPageUnderTitle(page);
}
let set = false;

let trList = pageTitle.translations;
console.log('DEBUG: translations found: ' + trList.length)
trList.forEach(tr => {
    set = true;
    tr.text = entity.name + ' Overview';
})
if (set == false) {
    console.log('DEBUG: set was false')
    let englishText = texts.Translation.createIn(pageTitle);
    englishText.text = entity.name + ' Overview';
    englishText.languageCode = 'en_US';
}     
}

In the console, I get the following output:

DEBUG: translations found: 1

This is as expected. However, when I now update my model and inspect the page, the title is empty!

To understand this, I wrote the following code:

function deconstructPageTitle(page: pages.Page){
let title = page.title;
console.log('PROPERTIES FOR TITLE');
title.allProperties().forEach(element => {
    console.log('Property: ' + element.name + ' with value: ' + element.observableValue);
})
let translations = title.translations;
translations.forEach(translation => {
    console.log('PROPERTIES FOR TRANSLATION ' + translation.id)
    translation.allProperties().forEach(element => {
        console.log('property: ' + element.name + ' with value: ' + element.observableValue);
    })
})
}

In the console, I now see the following:

PROPERTIES FOR TITLE
Property: translations with value: [mobx.array] [object Object],[object Object]
PROPERTIES FOR TRANSLATION 9180bfcd-091a-4945-9a36-2f588ac08669
property: languageCode with value: ObservableValue@1646[en_US]
property: text with value: ObservableValue@1647[]
PROPERTIES FOR TRANSLATION ee22e298-f6c8-4431-900c-e528694342c0
property: languageCode with value: ObservableValue@1648[en_US]
property: text with value: ObservableValue@1649[Customer Overview]

Where did this second translation in the title come from? Why is it empty? How do I fix this?

Furthermore, this seems to happen to every translation: this also applies to captions of columns in data grids.


Viewing all articles
Browse latest Browse all 82395

Trending Articles