mockend v0.0.3 introduces Server Sent Event (SSE) support

Server Sent Support (SSE) was added to: mockend, the "mock backend" for Single Page Applications (SPAs), with the v0.0.3 release.

CRUD operations like e.g. curl -XPOST "http://localhost:8080/crud" -H "Content-Type: application/json" -d "{\"message\":\"hello, mockend\"}" are mirrored as SSE events. The events are emitted via the URI curl -N http://localhost:8080/sse as e.g.


: crud-events
event: crud-event
id: 1620452701200
data: {"httpMethod":"POST","path":"/","payload":{"hello":"world","id":"1620452701199"}}    

Also in this release common curl commands were added to the startup screen as hints.

Hiding and disclosing optional content with the "details" and "summary" HTML elements / tags

With the "details" and "summary" HTML elements / tags optional content can be rendered in a space-saving manner without any JavaScript or CSS.

The details element is used at the top (episode numbers) of the airhacks podcast website: airhacks.fm to disclosure the episodes index:

Gradle vs. Maven, Transactions, Servlets, JS in old browsers, Bidding, HTTP Sessions, Retries, Timers, Web Servers--or 86th airhacks.tv

The 86th airhacks.tv covering:

"Gradle vs. Maven, Transactions in Servlets, modern JavaScript in old browsers, web server recommendations, HTTP session replication, a JavaEE-stic bidding system, reactive programming, schedules and retries ...and the coupon code redux4free"

is available:

See you every first Monday of the month at https://airhacks.tv 8pm CET (UTC+1:00). Show is also announced at: meetup.com/airhacks.

Any questions left? Ask now: https://gist.github.com/AdamBien/38e1754782c901f5d63e45968f3df610 and get the answers at the next airhacks.tv.

Bulkheads, Async, Schedule, WebServers, Bidding Systems, Modern JavaScript--or 86th airhacks.tv

Questions and topics: https://gist.github.com/AdamBien/165d26f83101c599fda4b8b46fc54828 for the 86th airhacks.tv:

  1. the first Big Airhacks Debate afterglow
  2. preventing EJB exception wrapping
  3. @Asynchronous + @TransactionAttribute(TransactionAttributeType.REQUIRES_NEW): does asynchronous imply a transaction?
  4. gradle vs. maven
  5. is it possible to start a transaction in a servlet?
  6. current browser support for modern JavaScript features
  7. a simple pipeline to deploy frontend and backend applications
  8. where to place configuration in frontend applications
  9. web servers recommendations for production
  10. the first Monday of the month problem
  11. the per-user Bulkhead
  12. limitations and approaches for HTTP sessions replication in containers
  13. frontend and backend deployment strategies
  14. JAX-RS, @ApplicationPath and the interference with the web assets
  15. book recommendations
  16. the JavaEE-stic way to build a real-time bidding system
  17. @Schedule and retries

Any questions left? Ask now: https://gist.github.com/AdamBien/165d26f83101c599fda4b8b46fc54828 and get the answers at the next airhacks.tv.

Testing Service Workers, TypeError: undefined is not an object (evaluating 'navigator.serviceWorker.register') and SSL with Quarkus

Service Workers can be only developed on localhost or a via a SSL connection. On iPhone an access to ServiceWorker over http causes:


TypeError: undefined is not an object (evaluating 'navigator.serviceWorker.register')    
    

In this screencast I'm configuring quarkus to act as a plain web server with a self-signed SSL-certificate for developing and testing Service Workers on mobile devices (iPhone):

How Grails and Micronaut happened--an airhacks.fm podcast

Subscribe to airhacks.fm podcast via: spotify| iTunes| RSS

The #138 airhacks.fm episode with Graeme Rocher (@graemerocher) about:
QuakeC, the advent of Grails and Micronaut, standards, annotation processors vs. reflection, runtime vs. build complexity, clouds, productivity, CDI, MicroProfile and Java
is available for

The (hopefully) shortest Java 16 Maven quickstarter

To create a Java 16 / Apache Maven project:

  1. git clone https://github.com/AdamBien/java16-plain
  2. cd java16-plain
  3. mvn package

The project is available from: https://github.com/AdamBien/java16-plain

The impact of the meta tag "viewport" on layout of mobile devices

The impact of:

<meta name="viewport" content="width=device-width, initial-scale=1">

to the layout on a mobile device (2 mins):

https://github.com/adambien/bce.design was used as sample application.

Java 16: Converting a JSON array to Java types with Pattern Matching

A JSON array, containing a JSON string and a number, loaded with JSON-P:


import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonNumber;
import javax.json.JsonString;
import javax.json.JsonValue;    

JsonArray load() {
    var jsonArray = """
                    ["hello,duke",42]
                    """;
    return Json.createReader(new StringReader(jsonArray)).readArray();
}

...can be converted to Java data types with the Java 16+ (JEP 394: Pattern Matching for instanceof) without any casting:

Object convert(JsonValue value) {
    if (value instanceof JsonNumber n) {
        return n.intValue();
    }
    if (value instanceof JsonString s) {
        return s.getString();
    }
    return value.toString();
}

The output of the following method:


@Test
public void jsonToJava() {
    var jsonArray = this.load();
    var javaList = jsonArray.stream().map(this::convert).toList();
    System.out.println(javaList);

}

yields: [hello,duke, 42]

See it in action (5 mins):

A "What was your first computer?" conversation with BalusC / Bauke / OmniFaces

What was your first computer?

Commodore 64. That was around 1986 when I was only 8. It was primarily used to play games on. With those 5.25" floppy disks and a lot of LOAD"$",8 commands :)

How you started programming?

With a Simons' BASIC cartridge plugged in that Commodore 64. That was around 1989 when I was only 11. My dad gave me it along with a bunch of C= magazines containing code examples to try out. I still remember that I once accidentally killed a C64 with a wrong "poke" command. It made me very sad, so my dad had to arrange a new one.

What was your first programming language?

BASIC :) I remember having written code to draw detailed Dutch and German locomotives on screen and print it using a matrix printer so I could color them.

How did you get into Java Server Pages?

When my first employer IBM decided to migrate some VM/REXX based website to WebSphere/J2EE/JSP. That was around 2003. Using "Scriptlets" was already forbidden by them, so I already learned using JSP the right way, right away.

How does your day look like?

I work from home. I wake up around 4:00 in the morning. I read programming and science related tweets and blogs with a cup of Nespresso. Then I start working for 4h. After that I take a pool break for max half an hour, whereby I swim intensively for about 500 meters. Just for my condition. Sitting behind a desk all day is not super healthy, you know ;) Then I continue working for another 4h, followed by a second pool break for max half an hour. Finally I usually continue working for another 2 to 4 hours, depending on the workload. Generally around 16:00 I shut down my computer for the rest of the day. Then I usually read the news and watch Netflix series until max 22:00. On weekends I usually don't touch my PC and I'm usually at some beach bar or a snack bar playing domino, but these pandemic days whereby you're forced to stay home all day and therefore get bored really quick, I turn on the PC to contribute yet more to the open source community.

Beach Bars? Where are you located, Hawaii?

I'm located in Curaçao, a Dutch Caribbean island in the southern Caribbean Sea. I'm myself a Dutch guy and I primarily wanted to escape the horrible Dutch weather which makes me sick every year again. Cumulative, I live 9 years in Curaçao.

Are your times getting better over time? What's more fun: swimming or programming?

Frankly, I don't pay attention to my swim times :) I love programming and therefore I need to swim regularly in order to be able to continue programming as long as possible.

Should a beginner learn JSF today?

Not before the beginner JSF developer has learnt HTML, CSS, JavaScript, Java and Servlets first. It's otherwise a pretty deep and slippery hole as JSF abstracts away quite a lot, basically everything. The aforementioned basics are essential in order to properly understand the inner workings of JSF. After that, the seasoned JSF developer will ultimately highly appreciate the high degree of customizability of JSF due to its high degree of abstraction.

Do you think JSF have a bright future?

The abstractness, customizability and extensibility of JSF made it still relevant after 20 years. The community is also still actively using and working on JSF, which will by the way be renamed to Faces with upcoming version 4.0 and be released as part of Jakarta EE 10 within one year. The download numbers of open source JSF libraries such as OmniFaces and PrimeFaces also speak for themselves. So I'd say Yes.

Is it a good idea to combine Web Components with JSF?

It's technically possible :) JSF can be used to componentize web components.

How OmniFaces happened?

Around 2010 I joined a JSF team where I met Arjan Tijms for the first time. In the end we observed that we were basically copy pasting the same kind of utility tools and utility components across JSF projects in order to reduce the verboseness of JSF API and to solve frequently recurring JSF spec/impl related shortcomings. We also observed at forums and Q&A sites such as Stack Overflow that many people were doing the same thing. So we have boiled them all down into the open source OmniFaces library which was first released 1 June 2012, so that everyone can benefit from it. At the moment it's downloaded over 25.000 times a month, slowly increasing over years.

You are a Stack Overflow fame: https://stackoverflow.com/users/157882/balusc. What motivates you to contribute to Stack Overflow or is it an "after dark" activity?

A long time ago, before Stack Overflow, I was active on forums.sun.com since about 2005. I basically started answering programming questions over there when I got jobless after I stopped at IBM. I'm deaf, so job interviews never went flawless and companies always hesitated to hire me. So I really had to show off my knowledge in some way to prove that I'm worth hiring, so I started building my online identity, and forums.sun.com was a good place to start. After the takeover of Sun by Oracle around 2009, which eventually changed the ambience at forums.sun.com, I migrated to Stack Overflow and continued building my identity over there. It actually helped in the long term :) Companies started to recognize me by my online identity and didn't anymore hesitate to hire me. In fact, they've been asking me to come working for them. I didn't anymore need to look for jobs and get nervous about job interviews. At this moment, Stack Overflow is nearly saturated with frequently asked questions related to Java / JSF / Servlet based web development, so I actually contribute much less now as compared to 10 years ago. These days my biggest task at Stack Overflow is keeping my answers up to date with the current state of technology.

What is OmniFaces' killer feature?

Its @ViewScoped annotation with the "immediately destroy bean instance and associated view state on unload of page instead of letting it linger in the session" feature. There have been production applications whereby memory usage was reduced by at least 70% by merely swapping out the JSF-native @ViewScoped for the OmniFaces one.

What applications or use cases are not well suited for JSF?

API endpoints. There you have JAX-RS for.

What new frontend technology would you like to learn (if you had time)?

PrimeFaces being available for NG, React and Vue as PrimeNG, PrimeReact and PrimeVue has really caught my attention. If I had time then I'd probably play around with one of them as the first new thing.

What is your current project?

I'm currently hired by mercury1.co.uk as developer and consultant for mytutor.co.uk. I'm also hired by tribalscale.com to help improve the quality of web applications of their clients. Finally I'm also hired by virtua.tech (from Kito Mann who you likely also know) to help migrate old web applications of their clients.

Can people hire you?

Yes definitely. I've been freelancing since 2010 already. But at the moment I'm already saturated. I'll probably be available again as of January 2022.

Thanks!

Cheers, Bauke / @OmniFaces

Online Workshops
...the last 150 posts
...the last 10 comments
License