Sunday Jul 29, 2012

JSF 2.0 - Action event model

If you are working with JSF 2.0 there are different ways to interact with backend methods and passing params to action methods. A useful link for this topic can also seen here

So for example if you have a JSF page with the following command link you use different ways to bound your backing bean:

<h:commandLink action="#{workflowController.editAction(workitem)}"
               actionListener="#{workflowController.doEdit}">
        <h:outputText value="click me" />
   <f:setPropertyActionListener
               target="#{workflowController.workitem}" value="#{workitem}" />
</h:commandLink>

The important thing here is the order which the jsf framework will trigger the differnt methods of the backingBean 'worklfowController'

  1. The actionListener method will be called
  2. The setPropertyActionListener will trigger the setter method of the property 'workitem'
  3. The action method with a custom param will be called

 So in this case you backingBean can look something like this - note that there are two different ways to pass a param:

 

   // first the actionListener method will be called   
public void doEdit(ActionEvent event) throws Exception {
        // do something...
       .....
    }

// next the setter for the property will be called
   public void setWorkitem(Data aworkitem) {
// do something   
}

// last the action method will be called
public String editAction(String action) {
        // do something
        return action;     
    }


Friday Jul 20, 2012

Glassfish - 3.1.x - CDIExtension not found

Today I run into a problem when trying to deploy a EAR with more than one web modules using CDI. Deploying such a EAR on Glassfish 3.1.1 or 3.1.2 will fail with the following exception:

Root exception is javax.naming.NameNotFoundException: CDIExtension not found

As you can read in this posting this is a known bug.

http://www.java.net/forum/topic/glassfish/glassfish/gf-311-jdk1716-linux-64bit-application-running-windows-7-does-not-deploy-linux

 

http://java.net/jira/browse/JERSEY-601

 

You can solve the problem when setting the system-property "com.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true".

This can be done from the GlassFish server console.

  • Select the node ->Configuration->server-config->JVM Settings
  • change to the tab 'JVM Options'
  • add a new entry
    -Dcom.sun.jersey.server.impl.cdi.lookupExtensionInBeanManager=true
  • restart your server

This will solve the deployment problem.