I have a JSF managed bean and a JAX-RS web service.
ManagedBean - myBean class
@ManagedBean
@ViewScoped
public class MyBean implements Serializable {
private String id;//getters && setters ommited
}
Web Service - myService class
@ApplicationPath("/myService")
@Path("/")
@Consumes("application/json")
public class MyService extends Application {
@Inject
MyBean myBean;
@Path("doSth")
@POST
public Response doSomething(){
//make an action here and set myBean.id value
myBean.id = 'a random value';
}
}
I debugged the code above, but then I realised that inside myBean class, the property "id" was equal to null even though I had set it in the doSomething()
method before, is it possible to achieve the scenario described above with these technologies? Before @Inject
, I also tried the injection of my managedBean using @ManagedProperty
, but the managedBean was null and not injected.
Then I would like this myBean.id property to be changed for the bean when I call it using myBean.id
, is that feasible?
Thanks in advance!