javabeans

What is an Enterprise Java Bean really?

柔情痞子 提交于 2019-12-04 09:15:43
问题 On the Tomcat FAQ it says: "Tomcat is not an EJB server. Tomcat is not a full J2EE server." But if I: use Spring to supply an application context annotate my entities with JPA annotations (and use Hibernate as a JPA provider) configure C3P0 as a connection pooling data source annotate my service methods with @Transactional (and use Atomikos as JTA provider) Use JAXB for marshalling and unmarshalling and possibly add my own JNDI capability then don't I effectively have a Java EE application

Why do we need beans.xml while working with JSF web application?

心已入冬 提交于 2019-12-04 07:31:08
I started web development using JSF, after studying JSP and Servlets for a while. When you create a JSF web application you always(may be often but I am not sure if it always or not) have to create beans.xml and you don't write anything in it. But, if that file doesn't exist the JSF web app will not work. What is the reason behind that? Why we need that file? Please, detailed explanation. Adding to the answer of Micheal; CDI is not only useful in combination with JSF because of the injection support, but also because of its support to be used with EL (expression language). This is a feature

How to get Bean data in JSP

南楼画角 提交于 2019-12-04 06:34:32
问题 I have bean defined as PersonBean in session scope. What I want is find the PersonBean.personId in jsp page. I want it in jsp page, because I want to do some calculation based on this personId . Anyone have idea how to get the same. In JSP, I am able to print the same using jsf <h:outputText value="#{PersonBean.personId}" /> However I need this value assigned to some integer value in jsp as shown below. <h:outputText value="#{PersonBean.personId}" /> <% int i = new PersonBean().getPersonId; ^

setter for a boolean variable named like isActive

那年仲夏 提交于 2019-12-04 05:20:48
I have a property called isActive in my pojo class. When I generated the accessors for this property using Eclipse IDE, it generates following getters and setters Getter : isActive() Setter : setActive() However, when I try to write this property using ibatis framework by mentioning property name as "isActive" , it cribs about not able to find any WRITEABLE propery named 'isActive'. The problem I think lies with not able to deduce the correct property name by inferring setter as setIsActive(). What is the best way to go about this without changing the property name or getter ? primitive

Can I use ObjectChangeListener to listen for changes on any object?

核能气质少年 提交于 2019-12-04 05:18:26
问题 I've got an Integer called x; if it changes then i would like to update my table in a GUI. To listen to "x" I have tried ChangeEvent y = new javax.swing.event.ChangeEvent(x); and I implement javax.naming.event.ObjectChangeListener : class HDIManagementView extends FrameView implements ObjectChangeListener, ActionListener, TableModelListener { and I override the objectChanged method to update my table. Nothing happened public void objectChanged(javax.naming.event.NamingEvent name){ //gets

Output a String from an array in JSP

依然范特西╮ 提交于 2019-12-04 04:34:19
问题 I want to make a quiz, I want to have to output an array of questions after a form is submitted. I know to use a bean I think but how would I do this? Thanks 回答1: Use the JSTL <c:forEach> for this. JSTL support is dependent on the servletcontainer in question. For example Tomcat doesn't ship with JSTL out of the box. You can install JSTL by just dropping jstl-1.2.jar in /WEB-INF/lib of your webapplication. You can use the JSTL core tags in your JSP by declaring it as per its documentation in

Spring: Configuring Bean with a two argument setter

吃可爱长大的小学妹 提交于 2019-12-04 04:22:23
I would like to configure a HttpParams using spring setter injection but HttpParams has a two argument setter ( setParameter(String name, Object object) ). Is anyone aware of a way to configure this in spring? The closest I can think of is like you would do a List, Set, or Property configuration: http://www.mkyong.com/spring/spring-collections-list-set-map-and-properties-example/ Thanks! Strictly speaking: A setter with two parameters is not a setter. It violates the JavaBeans convention, on which Spring builds. There is no simple way to solve that. As an alternative, here's a Helper class you

Copy java object/class from one classloader to another classloader

你离开我真会死。 提交于 2019-12-04 03:37:36
Hi is there a way to copy one class loaded context (atrributes etc) from one classloader (for instance a 'made' class Point) to another classloader? Making clear, Example: I have an object Point on CL 1. Now running on another CL2, I want to creat this object in CL 3. Some obj: class Point { int x; int y; public Point() {} //getters and setters Scenery: ... class CL2 { // Running on CL 2 ... // Point obj from CL 1 Object point = gotFromCL1(); // Want to create the object on Cl2 Object pointCL2 = point.conversion(); But I can't use sun.reflection (not available) and serialization doesn't work

Logging Spring bean initialization with Log4J

半城伤御伤魂 提交于 2019-12-04 02:23:56
When I run my application, it stops when beans are initializing but doesn't show any logs entries. So I don't know what happened: Log4j.properties log4j.rootLogger=DEBUG, stdout, R log4j.appender.stdout=org.apache.log4j.ConsoleAppender log4j.appender.stdout.layout=org.apache.log4j.PatternLayout org.springframework=DEBUG org.springframework.beans.factory.support=DEBUG log4j.logger.org.springframework.beans.factory.support=DEBUG log4j.logger.org.springframework.beans=DEBUG log4j.category.org.springframework.beans.factory=DEBUG log4j.logger.org.springframework=DEBUG log4j.logger.org.hibernate.hql

Unable to Import persistence.xml within applicationContext.xml file

一个人想着一个人 提交于 2019-12-04 02:21:48
问题 I'm using eclipse juno IDE I have Java application which have src folder. within the folder I have: 1) applicationContext.xml 2) persistence.xml I also have DBInterface and i implemented it with JPA. Now in the applicationContext.xml file I have a bean for the JPA implemention. When I tried to inject the bean i got an excpetion that said something like "No Persistence Provider was found". So I tried to import the persistence file within the applicationContext file but i'm getting another