javabeans

Overriding property file using spring

风格不统一 提交于 2019-11-29 15:16:42
问题 I have the following property file defined in one of my Spring (3.1) XMLs: <context:property-placeholder location="classpath:MyConfigFile.properties"/> I want to be able to define a second optional property file which will override the "MyConfigFile.properties" file and will get loaded instead of it. In Other words I want my application to load the "MyConfigFile.properties" file, but if a "StrogerConfigFile.properties" will be available at the classpath- it will get loaded instead. Anyone

h:selectOneMenu generic converter for all entities without calling DB again and again

*爱你&永不变心* 提交于 2019-11-29 15:01:26
I want to get selected object from <h:selectOneMenu> , but the problem is I couldn't find any generic converter for all type of entities. My first question is, is there a generic converter for all type of entities? I don't want to write another converter again for each other entity. My second question is, is there a way to get selected object without any converter? I don't want to call the DB again and again. I have a Car entity with id and name properties. BalusC My first question is, is there a generic converter for all type of entities? This does indeed not exist in standard JSF. The JSF

How to define private getter method in Groovy Bean?

一曲冷凌霜 提交于 2019-11-29 14:53:46
I used following code. class Bike{ def manufacturer; private getManufacturer(){ manufacturer } } But I was able invoke getter method from another class. tim_yates You can't using the private modifier. This is scheduled for Groovy 2.0 I believe Related questions: groovy call private method in Java super class Groovy Parent/Child Private Field Access Weirdness With Closure 来源: https://stackoverflow.com/questions/3819794/how-to-define-private-getter-method-in-groovy-bean

dynamically change spring beans

断了今生、忘了曾经 提交于 2019-11-29 14:41:02
问题 how do I dynamically change the properties of a bean at runtime using java spring? I have a bean mainView, which should use as property "class" either "class1" or "class2". This decision should be made on base of an property-file, where the property "withSmartcard" is "Y" or "N". ApplicationContext: <bean id="mainView" class="mainView"> <property name="angebotsClient" ref="angebotsClient" /> <property name="class" ref="class1" /> </bean> <bean id="class1" class="class1"> <constructor-arg ref=

Convert String to Enum using Apache BeanUtils

允我心安 提交于 2019-11-29 13:40:19
I've implemented a converter for Apache BeanUtils library for converting String to an enum constant: class EnumConverter implements Converter { @Override public <T> T convert(Class<T> tClass, Object o) { String enumValName = (String) o; Enum[] enumConstants = (Enum[]) tClass.getEnumConstants(); for (Enum enumConstant : enumConstants) { if (enumConstant.name().equals(enumValName)) { return (T) enumConstant; } } throw new ConversionException(String.format("Failed to convert %s value to %s class", enumValName, tClass.toString())); } } I use it in the following way: // Register my converter

What's the point of beans?

﹥>﹥吖頭↗ 提交于 2019-11-29 13:25:59
I've bean doing some JSP tutorials and I don't understand what the point of a bean class is. All it is, is get and set methods. why do we use them? public class UserData { String username; String email; int age; public void setUsername( String value ) { username = value; } public void setEmail( String value ) { email = value; } public void setAge( int value ) { age = value; } public String getUsername() { return username; } public String getEmail() { return email; } public int getAge() { return age; } } and the jsp is <jsp:useBean id="user" class="user.UserData" scope="session"/> <HTML> <BODY>

Could not autowire. No beans of SimpMessagingTemplate type found

爱⌒轻易说出口 提交于 2019-11-29 11:38:51
问题 I am configuring Websockets in Spring basically by following the guide provided in the documentation. I am currently trying to send a message from the server to the client as explained in the section "Sending messages from anywhere" Following the example, you can Autowire a class called SimpMessagingTemplate @Controller public class GreetingController { private SimpMessagingTemplate template; @Autowired public GreetingController(SimpMessagingTemplate template) { this.template = template; }

Confused about naming of JavaBean properties, with respect to getters and setters

情到浓时终转凉″ 提交于 2019-11-29 11:01:01
I am making an application that uses Drools planner. The @ValueRangeFromSolutionProperty is supposed to refer to a property from another class ( NQueens in this case). From the JavaDocs for @ValueRangeFromSolutionProperty : propertyName The property name of which exists a getter on the Solution that returns a Collection. But I noticed an inconsistency : the annotator uses the property rowList from NQueens . But rowList (as opposed to RowList ) is a private variable (see snippets below). If it were supposed to infer a property by introspection (from it's getter and setter methods), shouldnt it

Executing the ActionListener of a (Primefaces) menu item leads to an IllegalStateException

a 夏天 提交于 2019-11-29 10:39:31
In JSF backed bean I got an IllegalStateException when the programmatically added action listener of a programmatically added Primefaces menu item is called. I tried both request and session scope but both are leading to the same error. Obviously there's need -- according to the stack trace -- to restore the view when an action listener is executed and I let my ToolbarBean implement Serializable with no different effect. What should I consider in order to get this to work? User interface definition <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional

Can an EJB bean implement multiple interfaces?

不羁的心 提交于 2019-11-29 10:30:36
Can an EJB bean implement multiple user defined interfaces, except business interfaces (@Local, @Remote) or No-Interface view (@LocalBean)? For example define two interfaces UserInterface1 , UserInterface2 , with no annotation. Is this legal to implement: @Stateless public class MyBean implements UserInterface1, UserInterface2 { ... Then I have another confusion: @Stateless public class MyBean implements Runnable { ... //inside I won't try to manage thread } Is this legal or illegal, I found that glassfish support this situation. The given example is illegal, but nevertheless accepted by quite