or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

framework-integration.mdindex.mdjson-processing.mdmarshalling.mdtype-conversion.md
tile.json

tessl/maven-org-jboss-errai--errai-common

Common utilities and foundational infrastructure for the Errai GWT-based framework

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/org.jboss.errai/errai-common@1.0.x

To install, run

npx @tessl/cli install tessl/maven-org-jboss-errai--errai-common@1.0.0

index.mddocs/

Errai Common

Errai Common provides foundational utilities and infrastructure for the Errai GWT-based framework. It contains essential client-side components including JSON encoding/decoding utilities, type marshalling and demarshalling infrastructure, callback frameworks, and GWT integration helpers that enable seamless communication between client and server components.

Package Information

  • Package Name: errai-common
  • Package Type: maven
  • Group ID: org.jboss.errai
  • Artifact ID: errai-common
  • Language: Java (GWT-compatible)
  • Installation:
    <dependency>
      <groupId>org.jboss.errai</groupId>
      <artifactId>errai-common</artifactId>
      <version>1.0.1</version>
    </dependency>

Core Imports

import org.jboss.errai.common.client.ErraiCommon;
import org.jboss.errai.common.client.framework.AcceptsCallback;
import org.jboss.errai.common.client.json.JSONEncoderCli;
import org.jboss.errai.common.client.json.JSONDecoderCli;
import org.jboss.errai.common.client.types.*;

Basic Usage

// JSON encoding/decoding
JSONEncoderCli encoder = new JSONEncoderCli();
String json = encoder.encode(myObject);

JSONDecoderCli decoder = new JSONDecoderCli();
Object decoded = decoder.decode(json);

// Type conversion
Object converted = TypeHandlerFactory.convert(String.class, Integer.class, "123");

// Custom marshalling
TypeMarshallers.addMarshaller(MyClass.class, new MyClassMarshaller());
Marshaller<MyClass> marshaller = TypeMarshallers.getMarshaller(MyClass.class);

// GWT text selection utility
ErraiCommon.disableTextSelection(element, true);

Architecture

Errai Common is built around several key components:

  • Type Conversion System: TypeHandlerFactory with built-in handlers for collections and numbers
  • Marshalling Framework: Marshaller and Demarshaller interfaces with registry classes
  • JSON Processing: Client-side JSON encoding/decoding with type awareness
  • Callback Framework: Standard callback interface for asynchronous operations
  • GWT Integration: Entry point and DOM utilities for GWT applications

Package Structure

org.jboss.errai.common.client/
├── ErraiCommon                    # Main GWT entry point class
├── framework/
│   └── AcceptsCallback           # Callback interface for async operations
├── json/
│   ├── JSONEncoderCli           # Client-side JSON encoding
│   └── JSONDecoderCli           # Client-side JSON decoding
└── types/
    ├── TypeHandler<V,T>         # Type conversion interface
    ├── Marshaller<T>            # Object to string marshalling interface
    ├── Demarshaller<T>          # JSON object to typed object interface
    ├── TypeHandlerFactory       # Central factory for type conversions
    ├── TypeMarshallers          # Registry for marshaller instances
    ├── TypeDemarshallers        # Registry for demarshaller instances
    ├── JSONTypeHelper           # JSON-type conversion utilities
    └── handlers/                # Built-in type handler implementations
        ├── collections/         # Collection to array/collection conversions
        ├── numbers/            # Number to primitive/Date conversions
        └── primitives/         # Limited primitive conversions

Capabilities

Type Conversion and Handling

Core type conversion system for converting between Java types, with built-in support for collections, numbers, and custom type handlers.

public class TypeHandlerFactory {
    public static <T> T convert(Class from, Class<? extends T> to, Object value);
    public static Map<Class, TypeHandler> getHandler(Class from);
    public static void addHandler(Class from, Class to, TypeHandler handler);
}

public interface TypeHandler<V, T> {
    public T getConverted(V in);
}

Type Conversion

JSON Processing

Client-side JSON encoding and decoding with support for custom marshalling and type-aware conversion.

public class JSONEncoderCli {
    public String encode(Object v);
    public String encodeMap(Map<Object, Object> map);
    public Map<String, String> getMarshalledTypes();
}

public class JSONDecoderCli {
    public Object decode(Object value);
}

JSON Processing

Marshalling Framework

Extensible marshalling system for converting objects to/from string representations and JSON objects.

public interface Marshaller<T> {
    public String marshall(T object);
}

public interface Demarshaller<T> {
    public T demarshall(JSONObject o);
}

public class TypeMarshallers {
    public static void addMarshaller(Class type, Marshaller d);
    public static <T> Marshaller<T> getMarshaller(Class<? extends T> type);
    public static boolean hasMarshaller(Class type);
}

public class TypeDemarshallers {
    public static void addDemarshaller(Class type, Demarshaller d);
    public static <T> Demarshaller<T> getDemarshaller(Class<? extends T> type);
    public static boolean hasDemarshaller(Class type);
}

Marshalling

Framework Integration

GWT integration utilities and callback framework for building interactive applications.

public class ErraiCommon implements EntryPoint {
    public void onModuleLoad();
    public static void disableTextSelection(Element e, boolean disable);
}

public interface AcceptsCallback {
    public static final String MESSAGE_OK = "OK";
    public static final String MESSAGE_CANCEL = "CANCEL";
    public void callback(Object message, Object data);
}

Framework Integration

Common Types

// GWT JSON types
import com.google.gwt.json.client.JSONObject;
import com.google.gwt.json.client.JSONValue;
import com.google.gwt.json.client.JSONArray;

// GWT DOM types
import com.google.gwt.dom.client.Element;

// Errai type system imports
import org.jboss.errai.common.client.types.JSONTypeHelper;

// Standard Java types
import java.util.*;
import java.io.Serializable;