Reload FXML because of language change

41 views
Skip to first unread message

Andreas

unread,
Sep 29, 2015, 5:22:42 PM9/29/15
to JRebirth Users
Hi Seb,

we want to change the language of our application at runtime.

I tried several approaches and searched in the internet for a solution. But it seams to be a generally issue for a lot of developers and I think we have to reload the FMXL again to reach our goal.

But, because of our "singleton" models, it will not be loaded again.

So I tried to change the "canReleased" flag at runtime, but the release self is handled in a thread.

And if I want to (re-)set the model of an FXMLController by releasing the old first and create directly a new one via retrieve() and the UniqueKey of model class name, I get still the old/existent instance, because the release thread not done yet.

It would be great, if we have a method on model for reloading an FXML manually. So I don't have to release/create my singleton models.

What do you think? Or is there any other approach to change language at runtime, prepared in JRebirth framework?

Thanks a lot!

Andreas

Sebastien Bordes

unread,
Sep 30, 2015, 3:54:21 AM9/30/15
to jrebirth-users
Hi Andreas,

Let your model listen a custom WaveType named LANGUAGE_UPDATE

then remove the rootNode of this model from its parent (store the parent into local var)
Recreate the view by trying to call JRebirth.run(this.createViewIntoJAT ? RunType.JAT_SYNC : RunType.SAME, this::prepareView);
Reattach the rootnode to the parent

Some test shall be done to achieve it for FXMLModel, SimpleModel and BaseModel

Some cleaning will be required (ie:detach parent listener if any)

Perhaps I could add a such feature within 8.1.0 version but I don't when it will be released.

Seb

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes "JRebirth Users".
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse jrebirth-user...@googlegroups.com.
Pour obtenir davantage d'options, consultez la page https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages