[jbossseam-issues] [JBoss JIRA] Updated: (JBSEAM-1730) Injecting uiComponent with required = false fails with NPE if FacesContext is not available

Daniel Young (JIRA) jira-events at lists.jboss.org
Thu Jul 26 21:27:49 EDT 2007


     [ http://jira.jboss.com/jira/browse/JBSEAM-1730?page=all ]

Daniel Young updated JBSEAM-1730:
---------------------------------

    Description: 
If you inject a UIComponent into a bean as follows:

 @In(required = false, value = "#{uiComponent['XXX']}")

It fails for any method call that occurs with no FacesContext present  (eg: in my case, a WebRemote method).

I think if the faces context is null, then UiComponent.get() should just return null, in a similar way to the JBSEAM-1628 change that added the catch statement for IllegalArgumentException from the Sun RI.

  was:
If you inject a UIComponent into a bean as follows:

 @In(required = false, value = "#{uiComponent['XXX']}")

It fails for any method call that occurs on the bean at a time when the component is unavailable under the ViewRoot.

An IllegalArgumentException is thrown by the Sun RI from UIComponentBase:588 if findComponent(id) is unsuccessful, whereas MyFaces simply returns null.  This can be fixed by patching org.jboss.seam.faces.UIComponent to catch the IllegalArgumentException and return null.

We were working around this by avoiding using @In for this and looking under the FacesContext.ViewRoot manually, but eventually decided to patch Seam ourselves until this issue is fixed in CVS.  The above fix is working well for us.



> Injecting uiComponent with required = false fails with NPE if FacesContext is not available
> -------------------------------------------------------------------------------------------
>
>                 Key: JBSEAM-1730
>                 URL: http://jira.jboss.com/jira/browse/JBSEAM-1730
>             Project: JBoss Seam
>          Issue Type: Bug
>          Components: Core
>    Affects Versions: 2.0.0.BETA1
>            Reporter: Daniel Young
>         Assigned To: Gavin King
>            Priority: Critical
>             Fix For: 2.0.0.CR1
>
>
> If you inject a UIComponent into a bean as follows:
>  @In(required = false, value = "#{uiComponent['XXX']}")
> It fails for any method call that occurs with no FacesContext present  (eg: in my case, a WebRemote method).
> I think if the faces context is null, then UiComponent.get() should just return null, in a similar way to the JBSEAM-1628 change that added the catch statement for IllegalArgumentException from the Sun RI.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://jira.jboss.com/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the seam-issues mailing list