| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="utf-8"> |
| <meta name="viewport" content="width=device-width,initial-scale=1"> |
| <title>Hints and Tips :: Apache Isis</title> |
| <link rel="canonical" href="https://isis.apache.org/vw/latest/hints-and-tips.html"> |
| <meta name="generator" content="Antora 2.2.0"> |
| <link rel="stylesheet" href="../../_/css/site.css"> |
| <link rel="stylesheet" href="../../_/css/site-custom.css"> |
| <link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,700,700i|Raleway:300,400,500,700,800|Montserrat:300,400,700" rel="stylesheet"> |
| <link rel="home" href="https://isis.apache.org" title="Apache Isis"> |
| <link rel="next" href="exceldownload/about.html" title="Excel Download"> |
| <link rel="prev" href="extending.html" title="Extending"> |
| </head> |
| <body class="article"> |
| <header class="header"> |
| <nav class="navbar"> |
| <div class="navbar-brand"> |
| <a class="navbar-item" href="https://isis.apache.org"> |
| <span class="icon"> |
| <img src="../../_/img/isis-logo-48x48.png"></img> |
| </span> |
| <span>Apache Isis</span> |
| </a> |
| <button class="navbar-burger" data-target="topbar-nav"> |
| <span></span> |
| <span></span> |
| <span></span> |
| </button> |
| </div> |
| <div id="topbar-nav" class="navbar-menu"> |
| <a class="navbar-end"> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a class="navbar-link" href="#">Quick Start</a> |
| <div class="navbar-dropdown"> |
| <span class="navbar-item navbar-heading">Starter Apps</span> |
| <a class="navbar-item" href="../../docs/latest/starters/helloworld.html">Hello World</a> |
| <a class="navbar-item" href="../../docs/latest/starters/simpleapp.html">Simple App</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Demos & Tutorials</span> |
| <a class="navbar-item" href="../../docs/latest/demo/about.html">Demo App</a> |
| <a class="navbar-item" href="https://danhaywood.gitlab.io/isis-petclinic-tutorial-docs/petclinic/1.16.2/intro.html">Petclinic (tutorial)</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Resources</span> |
| <a class="navbar-item" href="../../docs/latest/resources/cheatsheet.html">Cheatsheet</a> |
| <a class="navbar-item" href="../../docs/latest/resources/icons.html">Icons</a> |
| </div> |
| </div> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a class="navbar-link" href="#">Guides</a> |
| <div class="navbar-dropdown"> |
| <span class="navbar-item navbar-heading">Development</span> |
| <a class="navbar-item" href="../../setupguide/latest/about.html">Setup Guide</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Core</span> |
| <a class="navbar-item" href="../../userguide/latest/about.html">User Guide</a> |
| <a class="navbar-item" href="../../refguide/latest/about.html">Reference Guide</a> |
| <a class="navbar-item" href="../../testing/latest/about.html">Testing Guide</a> |
| </div> |
| </div> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a class="navbar-link" href="#">Libraries</a> |
| <div class="navbar-dropdown"> |
| <span class="navbar-item navbar-heading">For Use in Apps</span> |
| <a class="navbar-item" href="../../subdomains/latest/about.html">Subdomain Libraries</a> |
| <a class="navbar-item" href="../../valuetypes/latest/about.html">Value Types</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Integrate between Apps</span> |
| <a class="navbar-item" href="../../mappings/latest/about.html">Bounded Context Mapping Libraries</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Other</span> |
| <a class="navbar-item" href="../../incubator/latest/about.html">Incubator</a> |
| <a class="navbar-item" href="../../legacy/latest/about.html">Legacy</a> |
| </div> |
| </div> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a class="navbar-link" href="#">Components</a> |
| <div class="navbar-dropdown"> |
| <span class="navbar-item navbar-heading">Viewers</span> |
| <a class="navbar-item" href="../../vw/latest/about.html">Wicket UI</a> |
| <a class="navbar-item" href="../../vro/latest/about.html">Restful Objects (REST)</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Security</span> |
| <a class="navbar-item" href="../../security/latest/about.html">Security Guide</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Persistence</span> |
| <a class="navbar-item" href="../../pjdo/latest/about.html">DataNucleus (JDO)</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Extensions</span> |
| <a class="navbar-item" href="../../extensions/latest/about.html">Extensions Catalog</a> |
| </div> |
| </div> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a class="navbar-link" href="#">Support</a> |
| <div class="navbar-dropdown"> |
| <span class="navbar-item navbar-heading">Contact</span> |
| <a class="navbar-item" href="../../docs/latest/support/slack-channel.html">Slack</a> |
| <a class="navbar-item" href="../../docs/latest/support/mailing-list.html">Mailing Lists</a> |
| <a class="navbar-item" href="https://issues.apache.org/jira/browse/ISIS">JIRA</a> |
| <a class="navbar-item" href="https://stackoverflow.com/questions/tagged/isis">Stack Overflow</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Releases</span> |
| <a class="navbar-item" href="../../docs/latest/downloads/how-to.html">Downloads</a> |
| <a class="navbar-item" href="../../relnotes/latest/about.html">Release Notes</a> |
| <a class="navbar-item" href="../../docs/latest/archive/1-x.html">Archive (1.x)</a> |
| <hr class="navbar-divider"/> |
| <span class="navbar-item navbar-heading">Framework</span> |
| <a class="navbar-item" href="../../conguide/latest/about.html">Contributors' Guide</a> |
| <a class="navbar-item" href="../../comguide/latest/about.html">Committers' Guide</a> |
| <a class="navbar-item" href="../../core/latest/about.html">Core Design</a> |
| </div> |
| </div> |
| <div class="navbar-item has-dropdown is-hoverable"> |
| <a class="navbar-link" href="#">ASF</a> |
| <div class="navbar-dropdown"> |
| <a class="navbar-item" href="http://www.apache.org/">Apache Homepage</a> |
| <a class="navbar-item" href="https://www.apache.org/events/current-event">Events</a> |
| <a class="navbar-item" href="https://www.apache.org/licenses/">Licenses</a> |
| <a class="navbar-item" href="https://www.apache.org/security/">Security</a> |
| <a class="navbar-item" href="https://www.apache.org/foundation/sponsorship.html">Sponsorship</a> |
| <a class="navbar-item" href="https://www.apache.org/foundation/thanks.html">Thanks</a> |
| <hr class="navbar-divider"/> |
| <a class="navbar-item" href="https://whimsy.apache.org/board/minutes/Isis.html">PMC board minutes</a> |
| </div> |
| </div> |
| <a class="navbar-item" href="../../docs/latest/about.html"> |
| <span class="icon"> |
| <img src="../../_/img/home.png"></img> |
| </span> |
| </a> |
| </div> |
| </div> |
| </nav> |
| </header> |
| <div class="body "> |
| <div class="nav-container" data-component="vw" data-version="latest"> |
| <aside class="nav"> |
| <div class="panels"> |
| <div class="nav-panel-pagination"> |
| <a class="page-previous" rel="prev" href="extending.html" title="Extending"><span></span></a> |
| <a class="page-next" rel="next" |
| href="exceldownload/about.html" title="Excel Download"><span></span></a> |
| <!-- |
| page.parent doesn't seem to be set... |
| <a class="page-parent disabled" rel="prev" href="" title="Extending"><span></span></a> |
| --> |
| </div> |
| <div class="nav-panel-menu is-active" data-panel="menu"> |
| <nav class="nav-menu"> |
| <h3 class="title"><a href="about.html">Wicket Viewer</a></h3> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="0"> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="configuration-properties.html">Configuration Properties</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="features.html">End-user Features</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="security.html">Security</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="customisation.html">Customisation</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <a class="nav-link" href="extending.html">Extending</a> |
| </li> |
| <li class="nav-item is-current-page" data-depth="1"> |
| <a class="nav-link" href="hints-and-tips.html">Hints-n-Tips</a> |
| </li> |
| <li class="nav-item" data-depth="1"> |
| <button class="nav-item-toggle"></button> |
| <span class="nav-text">Extensions</span> |
| <ul class="nav-list"> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="exceldownload/about.html">Excel Download</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="fullcalendar/about.html">fullcalendar</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="gmap3/about.html">GMap3</a> |
| </li> |
| <li class="nav-item" data-depth="2"> |
| <a class="nav-link" href="pdfjs/about.html">pdf.js</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </nav> |
| </div> |
| <div class="nav-panel-explore" data-panel="explore"> |
| <div class="context"> |
| <span class="title">Wicket Viewer</span> |
| <span class="version">latest</span> |
| </div> |
| <ul class="components"> |
| <li class="component"> |
| <span class="title"> </span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../docs/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../docs/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">BC Mappings Catalog</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../mappings/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../mappings/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Committers' Guide</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../comguide/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../comguide/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Contributors' Guide</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../conguide/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../conguide/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Core Framework</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../core/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../core/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Extensions Catalog</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../extensions/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../extensions/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Incubator Catalog</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../incubator/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../incubator/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">JDO/DataNucleus</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../pjdo/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../pjdo/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Legacy Catalog</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../legacy/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../legacy/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Reference Guide</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../refguide/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../refguide/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Release Notes</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../relnotes/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../relnotes/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Restful Objects Viewer</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../vro/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../vro/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Security Guide</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../security/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../security/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Setup Guide</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../setupguide/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../setupguide/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Subdomains Catalog</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../subdomains/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../subdomains/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Testing Guide</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../testing/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../testing/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">User Guide</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../userguide/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../userguide/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component"> |
| <span class="title">Value Types Catalog</span> |
| <ul class="versions"> |
| <li class="version is-latest"> |
| <a href="../../valuetypes/latest/about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../../valuetypes/2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| <li class="component is-current"> |
| <span class="title">Wicket Viewer</span> |
| <ul class="versions"> |
| <li class="version is-current is-latest"> |
| <a href="about.html">latest</a> |
| </li> |
| <li class="version"> |
| <a href="../2.0.0-M3/about.html">2.0.0-M3</a> |
| </li> |
| </ul> |
| </li> |
| </ul> |
| </div> |
| </div> |
| </aside> |
| </div> |
| <main role="main"> |
| <div class="toolbar" role="navigation"> |
| <button class="nav-toggle"></button> |
| <a href="../../docs/latest/about.html" class="home-link"></a> |
| <nav class="breadcrumbs" aria-label="breadcrumbs"> |
| <ul> |
| <li><a href="about.html">Wicket Viewer</a></li> |
| <li><a href="hints-and-tips.html">Hints-n-Tips</a></li> |
| </ul> |
| </nav> |
| <div class="page-versions"> |
| <button class="version-menu-toggle" title="Show other versions of page">latest</button> |
| <div class="version-menu"> |
| <a class="version is-current" href="hints-and-tips.html">latest</a> |
| <a class="version" href="../2.0.0-M3/hints-and-tips.html">2.0.0-M3</a> |
| </div> |
| </div> |
| <div class="edit-this-page"><a href="https://github.com/apache/isis/edit/ISIS-2062/viewers/wicket/adoc/modules/ROOT/pages/hints-and-tips.adoc">Edit</a></div> |
| </div> |
| <article class="doc"> |
| <a name="section-top"></a> |
| <h1 class="page">Hints and Tips</h1> |
| <div id="preamble"> |
| <div class="sectionbody"> |
| <div class="admonitionblock warning"> |
| <table> |
| <tr> |
| <td class="icon"> |
| <i class="fa icon-warning" title="Warning"></i> |
| </td> |
| <td class="content"> |
| TODO: this content has not yet been reviewed/updated for v2.0 |
| </td> |
| </tr> |
| </table> |
| </div> |
| <div class="paragraph"> |
| <p>This chapter provides some solutions for problems we’ve encountered ourselves or have been raised on the Apache Isis mailing lists.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="per-user-themes"><a class="anchor" href="#per-user-themes"></a>Per-user Themes</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>From <a href="http://isis.markmail.org/thread/kb4442niwwbnghey">this thread</a> on the Apache Isis users mailing list:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><em>Is it possible to have each of our resellers (using our Apache Isis application) use there own theme/branding with their own logo and colors? |
| Would this also be possible for the login page, possibly depending on the used host name?</em></p> |
| </li> |
| </ul> |
| </div> |
| <div class="paragraph"> |
| <p>Yes, you can do this, by installing a custom implementation of the Wicket Bootstrap’s <code>ActiveThemeProvider</code>:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="title">IActiveThemeProvider implementation</div> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">public class UserSettingsThemeProvider implements ActiveThemeProvider { |
| ... |
| @Override |
| public ITheme getActiveTheme() { |
| if(IsisContext.getSpecificationLoader().isInitialized()) { |
| final String themeName = IsisContext.doInSession(new Callable<String>() { |
| @Override |
| public String call() throws Exception { |
| final UserSettingsService userSettingsService = |
| lookupService(UserSettingsService.class); |
| final UserSetting activeTheme = userSettingsService.find( |
| IsisContext.getAuthenticationSession().getUserName(), |
| ACTIVE_THEME); |
| return activeTheme != null ? activeTheme.valueAsString() : null; |
| } |
| }); |
| return themeFor(themeName); |
| } |
| return new SessionThemeProvider().getActiveTheme(); |
| } |
| @Override |
| public void setActiveTheme(final String themeName) { |
| IsisContext.doInSession(new Runnable() { |
| @Override |
| public void run() { |
| final String currentUsrName = |
| IsisContext.getAuthenticationSession().getUserName(); |
| final UserSettingsServiceRW userSettingsService = |
| lookupService(UserSettingsServiceRW.class); |
| final UserSettingJdo activeTheme = |
| (UserSettingJdo) userSettingsService.find( |
| currentUsrName, ACTIVE_THEME); |
| if(activeTheme != null) { |
| activeTheme.updateAsString(themeName); |
| } else { |
| userSettingsService.newString( |
| currentUsrName, ACTIVE_THEME, "Active Bootstrap theme for user", themeName); |
| } |
| } |
| }); |
| } |
| private ITheme themeFor(final String themeName) { |
| final ThemeProvider themeProvider = settings.getThemeProvider(); |
| if(themeName != null) { |
| for (final ITheme theme : themeProvider.available()) { |
| if (themeName.equals(theme.name())) |
| return theme; |
| } |
| } |
| return themeProvider.defaultTheme(); |
| } |
| ... |
| }</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>and</p> |
| </div> |
| <div class="listingblock"> |
| <div class="title">Using the ActiveThemeProvider</div> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@Override |
| protected void init() { |
| super.init(); |
| |
| final IBootstrapSettings settings = Bootstrap.getSettings(); |
| settings.setThemeProvider(new BootswatchThemeProvider(BootswatchTheme.Flatly)); |
| |
| settings.setActiveThemeProvider(new UserSettingsThemeProvider(settings)); |
| }</code></pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="i18n-label-in-wicket-viewer"><a class="anchor" href="#i18n-label-in-wicket-viewer"></a>How i18n the Wicket viewer?</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>From <a href="http://isis.markmail.org/thread/ctppmtcbsf4iskzi">this thread</a> on the Apache Isis users mailing list:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p><em>I am trying to internationalize the label descriptions of form actions, eg those in <code>ActionParametersFormPanel</code>. |
| Referencing those via their message id inside a .po file didn’t work either. |
| Can this be done?</em></p> |
| </li> |
| </ul> |
| </div> |
| <div class="paragraph"> |
| <p>Yes, it <em>is</em> possible to internationalize both the Wicket viewer’s labels as well as the regular translations of the domain object metadata using the <code>.po</code> translation files as supported by the <a href="../../refguide/latest/applib-svc/TranslationService.html" class="page"><code>TranslationService</code></a>.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Full details of the <code>msgId</code>s that must be added to the <code>translations.po</code> file can be found in <a href="../../userguide/latest/btb/i18n.html#wicket-viewer" class="page">i18n</a> section of the <a href="../../userguide/latest/btb/about.html" class="page">beyond the basics</a> guide.</p> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="highlight-current-row"><a class="anchor" href="#highlight-current-row"></a>Highlight Current Row</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>Demo App: Highlighting Current |
| As a by-the-by, the demo app has one further "trick up its sleeve". |
| If you run the app you’ll notice that the currently selected <code>DemoObject</code> is highlighted in the left-hand table of the <code>HomePageViewModel</code>.</p> |
| </div> |
| <div class="paragraph"> |
| <p>This is accomplished by having the view model collaborate with a subscribing domain service that configures a CSS class.</p> |
| </div> |
| <div class="paragraph"> |
| <p>We start by ensuring that the <code>DemoObject</code> emits an event for its CSS class:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="title">DemoObject.java</div> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">@DomainObjectLayout( |
| ... |
| cssClassUiEvent = DemoObject.CssClassUiEvent.class |
| ) |
| public class DemoObject ... { |
| |
| public static class CssClassUiEvent |
| extends org.apache.isis.applib.events.ui.CssClassUiEvent<DemoObject> {} |
| ... |
| }</code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>Next, we define the domain service to act as the subscriber:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="title">HomePageViewModel.java</div> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">import org.springframework.context.event.EventListener; |
| import org.springframework.stereotype.Service; |
| |
| public class HomePageViewModel { |
| |
| @Service |
| public static class CssHighlighter { |
| @EventListener(DemoObject.CssClassUiEvent.class) |
| public void on(DemoObject.CssClassUiEvent ev) { |
| if(getContext() == null) { return; } |
| if(ev.getSource() == getContext().getSelected()) { <i class="conum" data-value="1"></i><b>(1)</b> |
| ev.setCssClass("selected"); |
| } |
| } |
| private HomePageViewModel getContext() { <i class="conum" data-value="2"></i><b>(2)</b> |
| return (HomePageViewModel) scratchpad.get("context"); |
| } |
| void setContext(final HomePageViewModel homePageViewModel) { |
| scratchpad.put("context", homePageViewModel); |
| } |
| @Inject |
| Scratchpad scratchpad; <i class="conum" data-value="3"></i><b>(3)</b> |
| } |
| |
| }</code></pre> |
| </div> |
| </div> |
| <div class="colist arabic"> |
| <table> |
| <tr> |
| <td><i class="conum" data-value="1"></i><b>1</b></td> |
| <td>If the domain object is the currently selected then set the CSS class</td> |
| </tr> |
| <tr> |
| <td><i class="conum" data-value="2"></i><b>2</b></td> |
| <td>Provide methods to set and get the current <code>HomePageViewModel</code> (acting as the context)</td> |
| </tr> |
| <tr> |
| <td><i class="conum" data-value="3"></i><b>3</b></td> |
| <td>Store the context using the <code>Scratchpad</code> domain service (request-scoped so thread-safe).</td> |
| </tr> |
| </table> |
| </div> |
| <div class="paragraph"> |
| <p>The <code>HomePageViewModel</code> is responsible for setting itself as the context for the domain service:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="title">HomePageViewModel.java</div> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-java hljs" data-lang="java">public class HomePageViewModel ... { |
| ... |
| public TranslatableString title() { |
| cssHighlighter.setContext(this); <i class="conum" data-value="1"></i><b>(1)</b> |
| ... |
| } |
| ... |
| @javax.inject.Inject |
| CssHighlighter cssHighlighter; |
| }</code></pre> |
| </div> |
| </div> |
| <div class="colist arabic"> |
| <table> |
| <tr> |
| <td><i class="conum" data-value="1"></i><b>1</b></td> |
| <td>set the context on the domain service</td> |
| </tr> |
| </table> |
| </div> |
| <div class="paragraph"> |
| <p>Finally we just need some CSS, in the <code>application.css</code> file:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="title">application.css</div> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-css hljs" data-lang="css">.selected { |
| font-style: italic; font-weight: bolder; |
| }</code></pre> |
| </div> |
| </div> |
| </div> |
| </div> |
| <div class="sect1"> |
| <h2 id="svg-support"><a class="anchor" href="#svg-support"></a>SVG Support</h2> |
| <div class="sectionbody"> |
| <div class="paragraph"> |
| <p>(As per <a href="https://issues.apache.org/jira/browse/ISIS-1604">ISIS-1604</a>), SVG images can be used:</p> |
| </div> |
| <div class="ulist"> |
| <ul> |
| <li> |
| <p>as Logo in the upper left corner (Wicket Menubar)</p> |
| </li> |
| <li> |
| <p>on the Login Page (<code>login.html</code>)</p> |
| </li> |
| <li> |
| <p>as favicon (<code>image/svg+xml</code>, cf. <a href="https://issues.apache.org/jira/browse/ISIS-1115">ISIS-1115</a>)</p> |
| </li> |
| </ul> |
| </div> |
| <div class="paragraph"> |
| <p>However, SVGs are not, by default, displayed on the welcome page. |
| SVGs can be attached as <code>Blob</code>s, but they are displayed as bitmaps (by means of the Batik rasterizer) and do not scale. |
| The rasterizer (of course) can not deal with animations (cf. attachment).</p> |
| </div> |
| <div class="paragraph"> |
| <p>To fix this, you can add the following dependencies:</p> |
| </div> |
| <div class="listingblock"> |
| <div class="content"> |
| <pre class="highlightjs highlight"><code class="language-xml hljs" data-lang="xml"><dependency> |
| <groupId>com.twelvemonkeys.imageio</groupId> |
| <artifactId>imageio-batik</artifactId> <!-- svg --> |
| <version>3.3.2</version> |
| </dependency> |
| <dependency> |
| <groupId>com.twelvemonkeys.imageio</groupId> |
| <artifactId>imageio-batik</artifactId> <!-- svg --> |
| <version>3.3.2</version> |
| <type>test-jar</type> |
| <scope>test</scope> |
| </dependency> |
| <dependency> |
| <groupId>org.apache.xmlgraphics</groupId> |
| <artifactId>batik-transcoder</artifactId> |
| <version>1.8</version> |
| </dependency></code></pre> |
| </div> |
| </div> |
| <div class="paragraph"> |
| <p>However, <strong>please note</strong> that these dependencies have high CVE values, and so may constitute a security risk.</p> |
| </div> |
| <div class="paragraph"> |
| <p>Further discussion on <a href="https://lists.apache.org/thread.html/68f16dd0306a8101c1cde06e5e6309b8d1b81b388a1f59e123cfc2f3@%3Cusers.isis.apache.org%3E">this mailing list thread</a>.</p> |
| </div> |
| </div> |
| </div> |
| </article> |
| <aside class="article-aside toc" role="navigation"> |
| <p class="toc-title">On this page</p> |
| <div id="article-toc"></div> |
| </aside> |
| </main> |
| </div> |
| <footer class="footer"> |
| <div class="content"> |
| <div class="copyright"> |
| <p> |
| Copyright © 2010~2020 The Apache Software Foundation, licensed under the Apache License, v2.0. |
| <br/> |
| Apache, the Apache feather logo, Apache Isis, and the Apache Isis project logo are all trademarks of The Apache Software Foundation. |
| </p> |
| </div> |
| <div class="revision"> |
| <p>Revision: SNAPSHOT</p> |
| </div> |
| </div> |
| </footer> |
| <script src="../../_/js/site.js"></script> |
| <script async src="../../_/js/vendor/highlight.js"></script> |
| <script src="../../_/js/vendor/jquery-3.4.1.min.js"></script> |
| <script src="../../_/js/vendor/jquery-ui-1.12.1.custom.widget-only.min.js"></script> |
| <script src="../../_/js/vendor/jquery.tocify.min.js"></script> |
| |
| <script> |
| $(function() { |
| $("#article-toc").tocify( { |
| showEffect: "slideDown", |
| hashGenerator: "pretty", |
| hideEffect: "slideUp", |
| selectors: "h2, h3", |
| scrollTo: 120, |
| smoothScroll: true, |
| theme: "jqueryui", |
| highlightOnScroll: true |
| } ); |
| }); |
| </script> |
| </body> |
| </html> |