Java 8 introduces the concept of default methods to interfaces and this post looks at the cost of adding state to them.
This information pertains to the pre-release version of Java 8 mentioned in a previous post.
Miscellaneous Computer Code
Java 8 introduces the concept of default methods to interfaces and this post looks at the cost of adding state to them.
This information pertains to the pre-release version of Java 8 mentioned in a previous post.
Update: Java 8 has been released and I've implemented a library with a more elegant approach to exception handling than the one described in this post: details + downloads; source code; blog posts.
This post looks at the effect of lambdas on checked exception handling.
This code uses a pre-release Java 8 build. See the previous post for more.
Pre-release builds of Java 8 with lambda support are available for download. This post looks at lambda-8-b50-linux-x64-26_jul_2012.tar.gz.
The Contexts and Dependency Injection (CDI) API introduced in Java EE 6 complements the JSF framework. There are good reasons to favour it over JavaServer Faces (JSF) managed bean mechanisms.
CDI doesn't do everything and there are edge cases where you might want to make use of Expression Language (EL) bindings during dependency injection. Fortunately, the gaps between these APIs are easy to fill.
Some users can run afoul of Portal's user-agent rules. Symptoms include the inability to log in and form submissions just causing page refreshes where all the form data is lost.
The problem is an intersection of two things:
See Technote 1441915 for IBM's support analysis.
define(["dojo/text!./path/some.txt"], function(textData) {
Dojo's AMD loader has some useful contextual loading features.
Note the exclamation mark in the dependency.
dojo/text! can be used to load character data;
dojo/has! can be used to load different modules based on
environment.
Writing your own plugin is relatively trivial.
A short post about setting up a trial WebSphere Portal Express server on the (unsupported) CentOS operating system.
Like many programmers, I like to run virtual machines to isolate development and test environments from everything else I do on my laptop. My Lenovo ThinkPad didn't support all the virtualization features I wanted out of the box, but it was relatively trivial to enable them.
Errors from virtualization software manifest as complaints about missing VT-x support or a failure enabling long mode. Virtualization support needs to be enabled in the BIOS. Instructions are provided in the user guide.
This post demonstrates a way to use the Dojo 1.7 AMD loader to provide mock/stub/fake/dummy artefacts in place of the defined dependencies.
Along with a few other JavaScript libraries, Dojo is making the transition to the Asynchronous Module Definition (AMD) API. This post presents a few minimal files written to make use of it.
A previous
post discussed how to inject the FacesContext into managed
beans using a
broker. This post demonstrates how to build on that approach with
greater levels of abstraction.
It is generally possible to remove direct JSF dependencies from managed bean code. You might want to do this to reduce coupling, improve cohesion or in the interests of writing testable code.
The code was written against Java 6, JSF 2 and JUnit 4 but the approach could be adapted to earlier versions of all of these.
Referencing the FacesContext
directly in Java classes makes managed beans more difficult to unit
test. This post discusses how to mock the context for testing outside
the application container.
These examples use Mockito with JUnit. Familiarity with JSF and unit testing Java is assumed.
I've used thejavax.faces.bean annotations but the
techniques apply for other bean management mechanisms (e.g. using faces-config.xml
or Spring).
One criticism developers have of JavaServer Faces is that it is
not possible to add arbitrary attributes to the resultant markup.
Problems arise when they wish to add custom attributes specific to
JavaScript frameworks (e.g. dojoType for the Dojo toolkit)
or HTML 5 attributes (such as data- or placeholder.)
However, this is not a technical limitation of the JSF framework; only a limitation of the standard control library.
I've been doing a bit of work recently with JAX-RPC on WebSphere Application Server 6.1. This is hardly cutting edge software (WAS 8 is out; JAX-RPC has been superceded by JAX-WS) but platforms can have a long shelf-life in the enterprise.
This post describes how to migrate from client bindings developed using RAD to automated generation via Ant. JAX-RPC isn't restricted to consuming SOAP in WARs, but this post confines itself to that topic.
For convencience, the sample code reuses the MaintainAddress.wsdl from a previous post.
JAX-WS is built into Java 6. This makes it a low-dependency choice for writing SOAP-based web service code. This post covers the basics of JAX-WS development with a sample web service.
An understanding of the following is beneficial: Servlets; XML Schema Definition (XSD); Web Services Description Langauge (WSDL); XPath; JAXB.
Server code was tested on Glassfish 3; client code was tested on Java 6.
The code here describes a contract-first web service; it is possible to do this the other way round, starting with Java code and generating descriptors from it.
After upgrading the iPads to a new version, we started seeing a
logon issue with servers protected by TAM
WebSEAL. After successfully authenticating, users were redirected to the
resource apple-touch-icon.png which resulted in a 404 "Not Found" error.
Let's take a JavaScript string: "€100". This
is going to be sent from a browser input box and stored in a web
server's database. The database is using the UTF-8 encoding and the
constraint on the column is CHAR(4). Spot the problem?
When you see a JSP document, you might wonder why it specifies the UTF-8 encoding three or four times. This is a post about what those declarations mean.
Comments are moderated and will not appear until I approve them.
Corrections and constructive criticism are welcome.
The method System.console()
can return null if there is no console device present. This
comes as a surprise to people when they run
their code in an IDE. This post is about overcoming such problems.