Get JSF managed bean by name in any Servlet related class

前端 未结 6 648
难免孤独
难免孤独 2020-11-22 01:33

I\'m trying to write a custom servlet (for AJAX/JSON) in which I would like to reference my @ManagedBeans by name. I\'m hoping to map:

http://host

6条回答
  •  梦谈多话
    2020-11-22 01:49

    Have you tried an approach like on this link? I'm not sure if createValueBinding() is still available but code like this should be accessible from a plain old Servlet. This does require to bean to already exist.

    http://www.coderanch.com/t/211706/JSF/java/access-managed-bean-JSF-from

     FacesContext context = FacesContext.getCurrentInstance();  
     Application app = context.getApplication();
     // May be deprecated
     ValueBinding binding = app.createValueBinding("#{" + expr + "}"); 
     Object value = binding.getValue(context);
    

提交回复
热议问题