javabeans

Java EE: how to access local EJB from web module?

↘锁芯ラ 提交于 2019-12-02 04:05:11
问题 I have created a local EJB that I want to access from a web module in the same VM. My code looks like this: @EJB private UserBeanLocal userBean; public UsuarioManagedBean() { InitialContext c = new InitialContext(); userBean = (UserBeanLocal) c.lookup("java:global/UsersApp/Users-ejb/UserBean!biz.users.beans.UserBeanLocal"); } public List<User> getUsers() { users = this.userBean.listUsers(); return users; } And this works fine. However, somebody told me that I don't need to do a lookup if I'm

JSF - Can @PostConstruct block setter method by using an ajax call?

冷暖自知 提交于 2019-12-02 02:01:10
问题 I think the question is clear by the title. This is my actual bean : @ManagedBean(name="selector") @RequestScoped public class Selector { private String profilePage; @PostConstruct public void init() { System.out.println("I'm PostConstruct"); if(profilePage==null || profilePage.trim().isEmpty()) { this.profilePage="main"; } } public String getProfilePage() { return profilePage; } public void setProfilePage(String profilePage) { this.profilePage=profilePage; System.out.println("I'm

What are the available options to retrieve Spring-managed beans in a Log4J Appender inside a Spring-managed web application?

*爱你&永不变心* 提交于 2019-12-02 00:27:15
问题 My current build lead has a great idea in theory - construct a custom Log4J appender that takes in Spring-managed beans and uses them to log errors to various other sources than just the standard log file. However, other than creating a singleton initialized at startup with the application context (code in just a moment), I can't seem to think of any other options of retrieving a Spring managed bean in a Log4J appender. public class SpringSingleton implements ApplicationContextAware { private

What are the available options to retrieve Spring-managed beans in a Log4J Appender inside a Spring-managed web application?

﹥>﹥吖頭↗ 提交于 2019-12-01 22:35:23
My current build lead has a great idea in theory - construct a custom Log4J appender that takes in Spring-managed beans and uses them to log errors to various other sources than just the standard log file. However, other than creating a singleton initialized at startup with the application context (code in just a moment), I can't seem to think of any other options of retrieving a Spring managed bean in a Log4J appender. public class SpringSingleton implements ApplicationContextAware { private static ApplicationContext context; public SpringSingleton() { super(); } public static

Can't use <jsp:useBean>: “Bean cannot be resolved to a type”

99封情书 提交于 2019-12-01 21:55:19
I'm just playing around with JSP. I just wanted to test some <jsp:useBean> stuff, but I can't. Every time if I'm using <jsp:useBean> , I get an error. Even if I just have this, I get an error: <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Test</title> </head> <body> <jsp:useBean id="mybean" class="Users" scope="session" > <jsp:setProperty name="mybean" property=

Between a jsf page and a managed bean, why the getter method is called twice

夙愿已清 提交于 2019-12-01 17:51:35
I have a jsf page with a form has an outputtext in it. The value of outputtext component is called from a backing bean (or managed bean). I know when I code it as #{MyBean.myString} Jsf rename it and calls getMyString() method. However the wierd thing is, when I put a breakpoint to the getter method of this component, I see it is called twice during the page is being rendered. The outputtext is in a h:form, and it is the only component wich is bind to a backingbean. I mean, it is so wierd that jsf should get the value when it first come to the getter method, however it needs to go to the

Between a jsf page and a managed bean, why the getter method is called twice

余生颓废 提交于 2019-12-01 17:23:58
问题 I have a jsf page with a form has an outputtext in it. The value of outputtext component is called from a backing bean (or managed bean). I know when I code it as #{MyBean.myString} Jsf rename it and calls getMyString() method. However the wierd thing is, when I put a breakpoint to the getter method of this component, I see it is called twice during the page is being rendered. The outputtext is in a h:form, and it is the only component wich is bind to a backingbean. I mean, it is so wierd

Inject managed-bean property into custom converter

早过忘川 提交于 2019-12-01 16:05:38
How can I inject a property of a managed-bean into a custom converter? For instance, a generic List so that I can extract my object from the list inside the converter? Mr.J4mes In several case, when you need to inject a bean such as ManagedBean, EJB, etc. into a Converter or a Validator , you can try annotating your Converter or Validator as a ManagedBean. For example, you can try this: @ManagedBean @RequestScoped public class MyConverter implements Converter { @EJB private MrEJBBean mrEJBBean; @ManagedProperty(value="#{mrsManagedBean}") private MrsManagedBean mrsManagedBean; @Override public

Inject managed-bean property into custom converter

我与影子孤独终老i 提交于 2019-12-01 15:57:37
问题 How can I inject a property of a managed-bean into a custom converter? For instance, a generic List so that I can extract my object from the list inside the converter? 回答1: In several case, when you need to inject a bean such as ManagedBean, EJB, etc. into a Converter or a Validator , you can try annotating your Converter or Validator as a ManagedBean. For example, you can try this: @ManagedBean @RequestScoped public class MyConverter implements Converter { @EJB private MrEJBBean mrEJBBean;

JavaBean 'value for the useBean class attribute classes.UserData is invalid' [duplicate]

放肆的年华 提交于 2019-12-01 11:16:26
This question already has an answer here: JasperException: The value for the useBean class attribute is invalid 6 answers I have two JSPs and a JavaBean that aren't working. I'm using Tomcat 6.0. The first JSP is GetName.jsp, located at C:\Tomcat\webapps\app1\GetName.jsp: <HTML> <BODY> <FORM METHOD=POST ACTION="NextPage.jsp"> What's your name? <INPUT TYPE=TEXT NAME=username SIZE=20><BR> What's your e-mail address? <INPUT TYPE=TEXT NAME=email SIZE=20><BR> What's your age? <INPUT TYPE=TEXT NAME=age SIZE=4> <P><INPUT TYPE=SUBMIT> </FORM> </BODY> </HTML> The second JSP is NextPage.jsp, located at