skip to navigation
skip to content

Planet Jython

Last update: April 20, 2014 08:47 AM

April 13, 2014


James Abley

Things GDS doesn't tell you

Working at the Government Digital Service (GDS) changes a person. It’s not a thing we highlight; just acknowledge internally in furtive conversations. This post should expose a few truths about that.

Pedantry

Words are really important. A common effect of working at GDS is that large parts of the internet become unusable for you, since the writing is so poor. Caring about serial commas is the norm.

New ideas

Content design. User research. These are all things that were new to me, and it turns out they have a massive impact in creating award-winning web sites. Another portion of the internet becomes blacklisted since it fails to meet your minimum standards for user experience.

Intolerance

Working with amazing people every day has a horrible effect on an individual. Working with less talented people becomes very unattractive. This is a deliberate retention policy strategy, and seems to work very well.

Elitism

Presenting well is a learned skill. Once you’ve learned it from one of the best there is, you start to notice things. Bad things. Powerpoint things. You cannot unsee these things.

If these side-effects repulse you, make sure you don’t apply to work here.

April 13, 2014 01:26 PM

March 31, 2014


Josh Juneau

Resource Library Contracts with NetBeans 8 and PrimeFaces


It is critical to organize an application in such a way that it is easy for users to navigate and perform their work.  PrimeFaces includes a layout component that makes it easy to select the most fitting layout for your application.  Assuming that the layout should be utilized across all application views, a Facelets template should be created, and the PrimeFaces layout should be configured within the template.  

To create the template within NetBeans 8.0, add a resource library contract to the application.  To do so, right-click on the “Web Pages” application directory and then choosing “New”->”Other…”, and select “JavaServer Faces” from the category menu, and finally choose “JSF Resource Library Contract” as the file type (Figure 1). 




Figure 1:  Adding Resource Library Contract within NetBeans

On the “New JSF Resource Library Contract” dialog, enter a contract name and click on the “Create Initial Template” checkbox (Figure 2).


Figure 2: New JSF Resource Library Contract

PrimeFaces offers a number of layouts to develop a user-friendly interface.  To use the layouts, declare the PrimeFaces namespace within the template, and then specify the PrimeFaces Layout component as the first element within the body of the template.  The layout component creates a complex borderLayout model, enabling the development of sophisticated user interfaces.  To add the layout component, use the <p:layout>tag, and specify attributes to customize the layout such as style along with a number of client side callback attributes.  In this post, the fullPage="true" attribute is specified to ensure that the layout spans the entire page.

A series of layout units can be specified within the layout component, and these units are used to arrange the layout in a particular order.  There are 5 different layout units:  top, left, right, top, and bottom. Each layout unit is specified with a <p:layoutUnit> element, and the position attribute indicates where the unit should be placed within the layout.  Add <ui:insert> tags into each of the <p:layout> sections as shown in Listing 1.  The code in Listing 1 specifies a full-page layout for an application.

Listing 1:  PrimeFaces Template Layout

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
      xmlns:h="http://xmlns.jcp.org/jsf/html"
      xmlns:p="http://primefaces.org/ui">

    <h:head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <h:outputStylesheet name="./css/default.css"/>
        <h:outputStylesheet name="./css/cssLayout.css"/>
        <ui:insert name="title">Acme Pools</ui:insert>
    </h:head>

    <h:body>

        <p:layout fullPage="true"> 

            <p:layoutUnit position="north" size="150" header="Acme Pools" resizable="false" closable="false" collapsible="false"> 
              <ui:insert name="top"></ui:insert>
            </p:layoutUnit> 

            <p:layoutUnit position="south" size="70" style="background-color: #dddddd" resizable="false" closable="false" collapsible="false"> 
                Copyright 2014
                <br/>
                Author: J. Juneau
            </p:layoutUnit> 

            <p:layoutUnit position="west" size="200" header="Navigation" resizable="false" closable="false" collapsible="true"> 
                <ui:insert name="left"/> 
            </p:layoutUnit> 

     

            <p:layoutUnit position="center"> 
                <ui:insert name="content">Content</ui:insert>
            </p:layoutUnit> 

        </p:layout> 

    </h:body>

</html>
After applying the template to the index view, it will resemble the layout shown in Figure 3.


Figure 3:  PrimeFaces Page Layout

The layout in the example utilizes custom animation to hide the navigation pane, and PrimeFaces provides this functionality without any additional configuration.  As you can see, PrimeFaces and NetBeans 8.0 make it easy to generate a sophisticated user layout.


March 31, 2014 06:17 AM

March 21, 2014


Josh Juneau

GlassFish 4 - Let's Help as a Community

We know that GlassFish 4 works with JDK8, but it has not yet been officially sanctioned.  Let's help out as a community and test out GlassFish 4 using the latest nightly builds, and submit any issues that arise.  The more feedback that is provided, the more solid the next release of GlassFish will be!


Here's what you can do to help:

1)  Grab a recent nightly build of GlassFish 4 from here: http://dlc.sun.com.edgesuite.net/glassfish/4.0.1/nightly/

2)  Install the build, and configure it to use your installation of Java SE 8 by doing the following:

  Set the AS_JAVA property within your 
  <glassfish-path>\glassfish\config\asenv.conf configuration file equal to your Java 8 installation. 

  On OS X, this would look like the following:

AS_JAVA="/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home"

3)  Test your Java EE applications under GlassFish 4 using Java 8, and submit any reproducible issues to the Issue Tracker:  https://java.net/jira/browse/GLASSFISH

  - Please include the steps to reproduce the issue(s) when submitting them to the tracker.  The more information, the better!

If we do our part as a community, we can help GlassFish to become more stable on Java 8, and then we should see a stable 4.x release sanctioned for use with Java 8 sometime in the future.

HelloType helloLambda = 
          (String text) -> {System.out.println("Hello " + text);};

helloLambda.hello("GlassFish 4 on JDK 8");


March 21, 2014 11:14 AM

March 16, 2014


Josh Juneau

Running GlassFish 4 on Java 8: Experiment with Java 8 Functionality in Java EE 7 Applications

Do you want to use the features of Java 8 with your Java EE 7 application?  It is possible to run GlassFish 4.0 under JDK 8.  To explicitly define which JDK GlassFish 4.0 uses, set the AS_JAVA property within your <glassfish-path>\glassfish\config\asenv.conf configuration file equal to your JDK 8 installation.  On OS X, this would look like the following:

AS_JAVA="/Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home"

Once you've set this property and then start the GlassFish 4.0 server, it should be running under JDK 8, allowing any of the applications to utilize new Java 8 features, such as streams or lambdas.



Note:  This is for experimental use only, as Java EE 7 has not been sanctioned for use with Java 8 at the time of this post.  


I have successfully configured GlassFish 4.0 to run under Java 8 in my environment, and tested the use of streams within a Java EE 7 application without issue.  Here are some sources demonstrating basic use of streams within a CDI bean:

@Named
@SessionScoped
public class PoolController implements Serializable {
    List pools = new ArrayList();
    
    public PoolController(){
        pools.add("Pool One");
        pools.add("Pool Two");
        pools.add("Pool Three");
    }
    
    public String getPool(){
        System.out.println("The number of pools " + pools.stream().count());
        return  pools.stream().findFirst().toString();
    }

}

March 16, 2014 01:43 PM