Using a “Please select” f:selectItem with null/empty value inside a p:selectOneMenu

When the select item value is null, then JSF won’t render <option value>, but only <option>. As consequence, browsers will submit the option’s label instead. This is clearly specified in HTML specification (emphasis mine): value = cdata [CS] This attribute specifies the initial value of the control. If this attribute is not set, the initial … Read more

Convert xlsx to csv in Linux with command line

The Gnumeric spreadsheet application comes with a command line utility called ssconvert that can convert between a variety of spreadsheet formats: $ ssconvert Book1.xlsx newfile.csv Using exporter Gnumeric_stf:stf_csv $ cat newfile.csv Foo,Bar,Baz 1,2,3 123.6,7.89, 2012/05/14,, The,last,Line To install on Ubuntu: apt-get install gnumeric To install on Mac: brew install gnumeric

Docx to Pdf Converter in java

The main problem with this is that those PdfOptions and PdfConverter are not part of the apache poi project. They are developed by opensagres and first versions were badly named org.apache.poi.xwpf.converter.pdf.PdfOptions and org.apache.poi.xwpf.converter.pdf.PdfConverter. Those old classes were not updated since 2014 and needs version 3.9 of apache poi to be used. Do using the much … Read more

How to convert BASE64 string into Image with Flutter?

There’s a simpler way using ‘dart:convert’ package Image.memory(base64Decode(base64String)); Implementation and some useful methods : import ‘dart:convert’; import ‘dart:typed_data’; import ‘package:flutter/widgets.dart’; Image imageFromBase64String(String base64String) { return Image.memory(base64Decode(base64String)); } Uint8List dataFromBase64String(String base64String) { return base64Decode(base64String); } String base64String(Uint8List data) { return base64Encode(data); }

Implement converters for entities with Java Generics

Easiest would be to let all your JPA entities extend from a base entity like this: public abstract class BaseEntity<T extends Number> implements Serializable { private static final long serialVersionUID = 1L; public abstract T getId(); public abstract void setId(T id); @Override public int hashCode() { return (getId() != null) ? (getClass().getSimpleName().hashCode() + getId().hashCode()) : … Read more