-
FEATURED COMPONENTS
First time here? Check out the FAQ!
How to change Page Title Dynamically from java using MVVM
it's not wrong.
In the end you are calling page.setTitle()
you simply found a complicated way to do so.
Instead you can just use the features MVVM provides - to avoid this kind of long chain of method calls. (just as in my previous example)
@AfterCompose
public void afterCompose(@ContextParam(ContextType.PAGE) Page page) {
page.setTitle("initial title");
}
I know this is not a pure MVVM since it requires direct access to the page object. But then this is most simple thing I could think of:
Simply call page.setTitle("updated title");
http://zkfiddle.org/sample/31tj128/1-mvvm-set-page-title
(you need to run this in a dedicated browser tab to see the title change http://temp.zkfiddle.org:1223/t862svt/31tj128/1/)
However this sounds too obvious and I assume you already tried that. In case you did: were there any difficulties on your side?
I saw the example. It is explicit i,e on button click. I want to load automatically. So i added the following line in afterCompose method and it works.
Executions.getCurrent().getDesktop().getFirstPage().setTitle("Homecare");
is this correct ?
Asked: 2019-09-26 00:28:40 +0800
Seen: 14 times
Last updated: Sep 26 '19
[Announcement] ZK 8.5.1 is now available!
Highlight new release changes/new features in demo app
How can I make a button change its image by clicking on the same button?
Problems calling function 'sec:isAnyGranted' with zkspring 3.2 and Spring Security 4
webapp folder of ZK spring boot?
Can I set in runtime a new value to library property: org.zkoss.zk.ui.processMask.enabled:
Package ZK Eclipse Tomcat Project For Deployment
AImage org.zkoss.zk.ui.UiException: java.io.FileNotFoundException