This content has been marked as final.
Show 2 replies
-
1. Re: Injection doesn't work during TestNG test
gavin.king May 26, 2006 10:51 AM (in response to superfis)that looks like it should work
note that bijection happens at _invocation time_ in Seam, not at component instantiation time! -
2. Re: Injection doesn't work during TestNG test
superfis Jun 2, 2006 4:49 AM (in response to superfis)Hi.
Doscouraged @In(jection) problem I prepared simple app dedicated to be focused on this problem only.
After I started my test app within Jboss AS, results terrified me ;) ... I can't understand why it doesn't work.
Seam action bean:@Stateful @Name( "showAction" ) // @Intercept( InterceptionType.ALWAYS ) // added to check if it could help public class ShowActionBean implements ShowAction { // this doesn't work @In( create = true ) @Out private TestAction testAction; @Begin( join = true ) public String go( ) { // this solution works // testBean = (Test) Contexts.getSessionContext( ).get( "testBean" ); System.out.println( "id=" + testBean.getId( ) ); System.out.println( "name=" + testBean.getName( ) ); return "next"; } @Destroy @Remove public void destroy( ) { } }
Back bean:@Stateful @Name( "testBean" ) public class TestBean implements Test { private int id; private String name; public int getId( ) { return id; } public void setId( int id ) { this.id = id; } public String getName( ) { return name; } public void setName( String name ) { this.name = name; } @Destroy @Remove public void destroy( ) { } }
I've got created jsf site where are 2 text inputs and submit action performing showAction.go( ) method.
When I fill up text inputs on the site and click submit button, I receive Caused by: java.lang.NullPointerException in go( ) method for System.out.println( "id=" + testBean.getId( ) ) line.
When I use testBean = (Test) Contexts.getSessionContext( ).get( "testBean" ), everything works correctly and I have received testBean from CONVERSATION context.
How to make @In(jections) working?
Regards, Slawek