[jboss-user] [JBoss Seam] - Value injection not always working with Seam 1.1

andrew.rw.robinson do-not-reply at jboss.com
Tue Dec 19 17:02:59 EST 2006


I needed some functionality from seam 1.1 compared to 1.0.1, so I just tried to upgrade and I'm having some really bad luck. The worst is problems with the "@In(create=true)" annotation. 

Exception:
java.lang.NullPointerException
  |         at com.outlooksoft.cpm.usercontext.UserApplicationViewBean.getCurrentAppSet(UserApplicationViewBean.java:462)
  |         at com.outlooksoft.cpm.usercontext.UserApplicationViewBean.changeCurrentViewSelection(UserApplicationViewBean.java:492)
  |         at com.outlooksoft.cpm.usercontext.UserApplicationViewBean.selectMember(UserApplicationViewBean.java:294)
  |         at com.outlooksoft.cpm.faces.controls.UIMemberSelectionDialog.broadcast(UIMemberSelectionDialog.java:105)
  |         at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:94)
  |         at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:168)
  |         at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:343)
  |         at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
  |         at javax.faces.webapp.FacesServlet.service(FacesServlet.java:137)

In this code, what I am doing in the broadcast is looking up the bean:
(MemberSelectionDialogBean)context.getApplication().createValueBinding("#{memberSelectionDialogBean}")
  |       .getValue(context);
And then calling a method on that bean. The "MemberSelectionDialogBean" is session scoped:
@Name("memberSelectionDialogBean")
  | @Scope(ScopeType.SESSION)
  | public class MemberSelectionDialogBean
  |   implements Serializable {
  |   ... 
  |   private MemberSelectionDialogListener listener;
  |   ... }
It in tern, calls another session scoped bean:
@LoggedIn
  | @Name("currentView")
  | @Scope(ScopeType.SESSION)
  | public class UserApplicationViewBean
  |   implements Serializable, MemberSelectionDialogListener {
  |   ...
  |   @In(create=true)
  |   private UserSessionBean userSession;
  |   ... }

This user session bean is also session scoped:
@LoggedIn
  | @Name("userSession")
  | @Scope(ScopeType.SESSION)
  | public class UserSessionBean
  |   implements Serializable {...}

So to explain the stack:
1) a custom control (UIMemberSelectionDialog) processes the broacast during the INVOKE_APPLICATION phase
2) it looks up a bean from the faces context using a value binding (memberSelectionDialogBean)
3) it then calls a method on the UserApplicationViewBean

The problem seems to be that the MemberSelectionDialogBean uses a member variable to call the UserApplicationViewBean that is set programmatically (is not injected). It seams like all of the injections variables on that UserApplicationViewBean are set to null and are not re-set.

This worked fine on 1.0.1. I know it is ugly code (I need to fix it, but it is a large task). Any thoughts?

-Andrew



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3995136#3995136

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3995136



More information about the jboss-user mailing list