How to write controller in Java

Hi,
I’m a newbie and very happy with XP platform and Javascript API. My concern is, JS is a dynamic type language, it’s hard to maintain in long term. IMHO, I prefer a static type such as Java to write business code. I found https://github.com/enonic/starter-typescript but it seems to incompatible with XP v7.2.0. Is it possible to write controller in Java?
Thank you in advanced!

Hi,

1.4.0 is compatible with XP7 - https://github.com/enonic/starter-typescript/tree/v1.4.0, if not please report a bug on the issue-tab on the github repo.

You should read up on the Java-bridge, a way to write Java-code you can communicate with from your JavaScript controllers - https://developer.enonic.com/docs/xp/stable/framework/java-bridge

1 Like

thank you, I added a comment in a similar issue in that repo

Typescript starter is obsolete and only maintained for compatibility with pre-XP7 versions.

You should use the Webpack starter instead: it includes code samples in plain Javascript and Typescript (both server- and client-side), transpiled and built with Webpack.

2 Likes

thank you very much!

We (at Item Consulting) have open sourced some libraries that makes it easier to work with TypeScript in Enonic.

  1. enonic-ts-codegen for generating TypeScript interfaces based on XML-files in your enonic project (e.g Content Type)
  2. enonic-types which is typings for the different enonic libraries (e.g. lib-content).
  3. enonic-fp and enonic-wizardry if you are into doing Functional Programming.

Here is a blog post about TypeScript in XP that I wrote to help get started with the libraries.

3 Likes