FAQ Database Discussion Community


How to clear(empty) a string array in java?

java,arrays,javabeans
I am getting some details and stored in to a string array(Using getter and setter).After that i am setting it as a bean(huge amount of data is taken).To avoid heap space error i have to clear the string array everytime after setting it as a bean.Is there any methods to...

Refreshing a JSF/PrimeFaces interface from the backing Bean

jsf,primefaces,javabeans
My goal is to display a text on a web page, with JSF and/or PrimeFaces. The text is updated in real time by a process on the server side. <?xml version="1.0" encoding="ISO-8859-1" ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:p="http://primefaces.org/ui"> <h:body> <f:view id="view"> <f:event...

javax.mail.Session bean concurrency. How to control?

java-ee,javabeans,wildfly
I am running a @Singleton bean with an @Schedule method that polls a gmail imap service injected with @Resource and defined in the WildFly deployment. When I poll the service at a high frequency (every 5 secs) I get sometimes a too many simultaneous connections error. Probably because there are...

Java POJO Design with 200 variables

java,javabeans,pojo
I have to design a Java Bean with 200 variables? is this the correct way? (or) Should I break the Bean into smaller logical beans and add to Main bean P.S: I have a extract data from Legacy System and generate XML using Castor...

I cannot keep the bean stateful when the spring bean is value = “prototype”, proxyMode = ScopedProxyMode.TARGET_CLASS

spring,proxy,prototype,javabeans
here is the spring bean: @Repository @Scope(value = "prototype", proxyMode = ScopedProxyMode.TARGET_CLASS) public class TestBean { private String text; public String getText() { return text; } public void setText(String text) { this.text = text; } } and here is the very simple codes to access the bean: TestBean testBean =...

Looping Arraylist of Arrays java

java,arrays,jsp,arraylist,javabeans
I have a method in the model that creates an ArrayList array me from a resultset, I need is cross it from jsp, I could not do, any help? This is the code of the arraylist public ArrayList listar(){ String sql="select * from eventos"; ArrayList lista=new ArrayList(); try { st=con.createStatement();...

How to separate getters and setters from managed bean in JSF?

java,jsf,javabeans,getter-setter
I am developing a login page in JSF. I have two attributes email and password. I want to have two java classes. One for setters and getters, two for logic. So, how to separate setters and getters from managed bean. My code is private String email; private String password; private...

Beginner confusion about autowiring in Spring

spring,javabeans
All: I just begin the Spring study, there is one concept confused me so much: The Autowiring. The question I need to be clear is: What kind of thing can be autowired? Is it only other beans? If I define a class Bar: public class Bar { @Autowired public String...

Is it appropriate to update database from a javabean class?

java,mysql,javabeans
A little bit of context: I am creating somewhat of a game. In that game the player can own a house. The house may contain furniture objects, and those furniture may have custom textures set. One piece of furniture may contain different amounts of textures. A piece of furniture has...

Spring - - java.lang.IncompatibleClassChangeError

spring,exception,constructor,javabeans
Hi I use EclipseEE and Java8_40. I start with the Spring Framework and have some problem. When I want use constructor in beans.xml the program create a Exception. I have in CLASSPATH : - commons-logging-1.2.jar - commons-logging-1.2-javadoc.jar and Spring *.jars - spring-aop-4.1.5.RELEASE.jar - spring-asm-3.1.1.RELEASE.jar - spring-beans-4.1.5.RELEASE.jar - spring-context-4.1.5.RELEASE.jar - spring-aspects-4.1.5.RELEASE.jar...

Bad Operand types for binary operator '/' first type String second type int

java,jsp,servlets,web-applications,javabeans
New to javabeans so please forgive me if this is simplistic: Getting this error while writing a javabean page. The code basically asked to add 7 values together and then divide the total by 160. Code is: public String getAverage(){ return (Str1 + Str2 + Str3 + Str4 + Str5+...

Spring MVC refresh database beans in application context

spring,singleton,refresh,javabeans,apache-commons-dbcp
I am developping a Spring MVC web application that use the dbcp database connection pool. <bean id="datasourceAR_XXX" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" scope="singleton"> <property name="driverClassName"><value>oracle.jdbc.driver.OracleDriver</value></property> <property name="url"><value>jdbc:oracle:thin:@XXX.XXX.com:1500:SERVICE</value></property> <property name="maxActive"><value>100</value></property>...

Can't load Spring Context correctly

java,spring,service,javabeans,applicationcontext
What I'm doing: I'm loading my Spring application external JAR into another non-spring application. I'm doing it like this: ApplicationContext ap = new ClassPathXmlApplicationContext("classpath:/META-INF/spring/application-context.xml"); MyService myService = (MyService) ap.getBean("myBusinessService"); this is the exception that I receive: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myBusinessService': Injection of autowired dependencies failed; nested exception...

Controlling component from backing bean

jsf,richfaces,components,javabeans
I want to 'update' a component with a new component in the bean. XHTML <composite:interface> <composite:attribute name="rootKey" required="true" /> <composite:attribute name="id" required="true" /> </composite:interface> <composite:implementation> <rich:panel id="#{cc.attrs.id}" binding="#{myBean.customPanel}"/> <a4j:jsFunction name="createPanels" action="#{myBean.createPanels}" render="#{cc.attrs.id}"> <a4j:param name="rootId" assignTo="#{myBean.rootId}"/> <a4j:param...

Pass rich text editor value to bean

editor,javabeans,jdeveloper,jspx
I'm using Jdevloper 11g R2 and I have a .JSPX page that contains an ADF Rich Text Editor. This editor can contain text and Images and different styles. how can i pass the value of this editor to my bean? my goal is to take this value and send it...

Apache Shiro, can not pass values from login form to backing bean

jsf,java-ee,primefaces,javabeans,shiro
I can not pass values from my login form to backing bean to authenticate user by apache shiro in my web app. Does anybody know why? shiro.ini [main] authc.loginUrl = /login.jsf authc.successUrl = /pages/welcome.jsf [users] admin = 1234 [urls] /login.jsf = authc /pages/** = authc login.xhtml <ui:define name="content"> <div id="login_form">...

Need help in mapping XML to a Java Bean

java,xml,javabeans
I have an XML as follows ... <employeeId>323</employeeId> <name>Samuel DCosta</name> <department> <departmentId>2</departmentId> <name>Accounts</name> </department> <salary>11290</salary> I want to map these values to the Java Beans that I have .... the keys in the XML match with the name of the members in the beans ..... someone tell me if there...

idiomatic way to create a bean with parameter from command line?

java,spring,javabeans
for example, in my spring application, I need several DBWorker Beans: @Component @Scope("prototype") class DBWorker { @Autowired JdbcTemplate templ; @Autowired SomeOtherDependency dep; public void init() { // use jdbcTemplate to pull some // set up info from DB } public void run() { // pull maxNumberOfRows and print out }...

JavaFX beans vs. properties — why both?

java,clojure,javafx,javabeans
I'm looking at http://docs.oracle.com/javase/8/javafx/api/javafx/beans/property/SimpleObjectProperty.html and I'm somewhat confused. I can create a SimpleObjectProperty using the third constructor, SimpleObjectProperty(Object bean, String name, T initialValue) in Clojure as follows: (def sop (SimpleObjectProperty. 5 "mysop" 6)) This creates a SimpleObjectProperty with Bean value = 5 (of type java.lang.Long) and non-Bean value = 6,...

Diffrence Between 'class' and 'type' attribute in jsp

java,jsp,javabeans
In jsp I have found - <jsp:useBean id="user" class="com.test.UserDetails" /> By which I mean (Please correct me If I am wrong) - if a UserDetails instance is already exists then it will be assigned with an id user and if not exist then a new UserDetails object is created and...

Nested Exception in Java

java,exception,jdbc,javabeans
I'm dealing with a SEVERE exception in Java that looks like this: SEVERE: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'birtReportRenderer': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire method: public void com.convergys.raspberry.server.filemgmt.FileWorker.setFileAuditTbl(com.convergys.raspberry.server.database.FileAuditTbl); nested exception is...

Why when i call my class into a javabean the java reflection dosn't work?

java,java-ee,reflection,javabeans,java-ee-6
I try to show all my packages names with java reflection and it work perfectly when i test with a main method: The methode to get all packages names whitch is in a class named test1.java: public Set<String> findAllPackages(String packagebase) { List<ClassLoader> classLoadersList = new LinkedList<ClassLoader>(); classLoadersList.add(ClasspathHelper.contextClassLoader()); classLoadersList.add(ClasspathHelper.staticClassLoader()); Reflections reflections...

How to initialize bean's property to its name from Spring context?

java,spring,javabeans
Is it possible to know bean's name from @Bean-annotated method and put it into this same bean's property, so that bean knows its own name? If this way is impossible, then if there another way exist?...

Create a Java Bean to be of type HashSet and get error in editor

java,xpages,javabeans
This is my code: package ca.wfsystems.core; import lotus.domino.Base; import lotus.domino.Session; import lotus.domino.Database; import lotus.domino.View; import lotus.domino.NotesException; import lotus.domino.ViewEntry; import lotus.domino.ViewEntryCollection; import java.io.Serializable; import java.util.Collection; import java.util.HashMap; import java.util.HashSet; import java.util.Map; import java.util.Set; import java.util.Vector; import com.ibm.xsp.extlib.util.ExtLibUtil; import ca.wfsystems.core.*; **public class ssAppMenu...

What is a good use case of Java Beans?

java,javabeans
I just saw the Java Beans specification. I felt that using only getters, setters and empty constructor will make code more hectic plus developer needs to manage track to set all the required instances properly. Could somebody point me a good use case for using such design? I am unable...

Set a bean property from a dropdown box

java,html,jsp,netbeans,javabeans
Hi there I am trying to set a beans value from a drop down menu and I cant seem to get it working and wondered if any of you guys had some advice on how I could fix this I have put the useBean tag in my head <head> <link...

adding parts of a javabean together

java,jsp,javabeans
How do I take the return values of some methods that I wrote in a bean and add them together for an return? For instance: public double getPart1Average() { String[] average = new String[]{Part01, Part02, Part03}; int sum = 0; for (String input : average) { sum += Integer.parseInt(input); }...

Is there a way I can autowire a bean in my route without using the .bean keyword in Camel?

java,spring,apache-camel,javabeans,autowired
Lets say for example, I have the following route: from(.....) .choice() .when(condition1) .bean(Class1.class,"method1") .when(condition2) .bean(Class1.class,"method2") .otherwise() .bean(Class1.class,"method3") .end(); Is there a way I can autowire Class1 to use all the methods instead of using the .bean function in camel. If you know any other efficient method. Please do let me...

GWT : How to use beans from separate module?

java,gwt,javabeans,gwt-rpc
I am working on a project with seperated modules . backend for admins , client for users and core for share DAO layer amongs backend and client. backend module uses GWT and client uses Spring MVC. At backend module , core module was included by deployment assembly. My server side...

Problems creating a Java Bean inheritance structure

java,spring,inheritance,javabeans
I am trying to create create what I think is a simple inheritance structure with Java Beans (I have never worked with them before). I was given code which has a base class defined as public class CreateDialogFactory { priavte static beanId; protected CreateDialogFactory() { } protected CreateDialogFactory(String beanId) {...

Does Spring MVC cache bean files that are not loaded on start of the web app?

java,xml,spring,spring-mvc,javabeans
I'm just curious on if I am better off putting it in src/main/webapp/WEB-INF/context.xml or in my src/main/resources/something.xml path. Technically I do not need to load something.xml until a specific controller is called, but I also want to keep something.xml separate from context.xml because they are both pretty huge files... which...

How to make autowire object initialized in ApplicationListener?

java,spring,javabeans
I want to read data in ApplicationListener, but my object is not initialized. Below is my code: AppContextListener.java @Component public class AppContextListener implements ApplicationListener<ContextRefreshedEvent> { @Override public void onApplicationEvent(ContextRefreshedEvent event) { AppContext.getInstance(); } } AppContext.java public class AppContext { private static AppContext instance; @Autowired MyElasticsearchRepository repository; public AppContext(){ InitData(); }...

Cannot create bean when start the application

java,spring,javabeans,sftp,job-scheduling
I am facing some issue while creating the bean it gives error. Can someone please assist me. I will retrieve the files from sftp resource and will read those file with a spring task scheduler job. App-Config.xml <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" xmlns:task="http://www.springframework.org/schema/task"...

spring:batch listener issue

javabeans,spring-batch
I know this is probably a pretty simple fix but for some reason I'm not able to find anything on google. I created a Listener that will take a jobParameter, but for some reason it's not working and I'm not sure what I need to add to my code. It...

JavaBean documentation

java,javabeans,javadoc
I've been messing with making custom controls in Java, and I'm wondering what the proper way to add documentation is. I've got lots of private variables with getters and setters, and each variable has it's own PROP_[variable name] variable. I'm specifically looking for the way to document them that would...

Multiple Connection Factories

java,spring,apache-camel,activemq,javabeans
I'm using spring boot and setting up multiple connection factories (pooled and jms). The issue I'm getting is that it seems to be trying to autowire them to the same object in javax.jms.ConnectionFactory. So its resulting in this exception: Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private javax.jms.ConnectionFactory org.springframework.boot.autoconfigure.jms.JmsAutoConfiguration.connectionFactory; nested...

How to update on object at a certain position in an ArrayList?

java,list,arraylist,javabeans
I have one ArrayList of 10 Objects. List<Person> persons = new ArrayList<>(); persons.add(new Person("Jean", "Pol", "receptionist", 29)); persons.add(new Person("Jef", "Snijders", "guardener", 42)); persons.add(new Person("Piet", "Peters", "truck driver", 54)); persons.add(new Person("Peet", "Polders", "professor", 63)); persons.add(new Person("Nell", "Van Den Walle", "student", 19)); persons.add(new Person("Nady", "Van Toren", "cleaning", 27)); persons.add(new Person("Jenny", "De Koster",...