javabeans

Make JSF access a Map<String, ?> values from an EL instead of a bean fields?

≡放荡痞女 提交于 2019-12-05 07:10:57
Is there any proper way to override the way JSF accesses the beans fields from an Expression Language? The idea is to mimic this behavior in order to access a Map<String, ?> values, where the bean fields would be the map keys. In other words, is it possible anyhow to use #{beanContainingNestedMap.keyOfSaidNestedMap} , just as if keyOfSaidNestedMap were a field of the beanContainingNestedMap ? If not, what other solution may I have? Example: Holder.java public class Holder { private Map<String, Object> objects = new HashMap<String, Object>(); public void add(String key, Object value) { objects

Performance of BeanUtils vs. ReflectionToStringBuilder (for use in Bean classes)

做~自己de王妃 提交于 2019-12-05 06:23:28
I have a large number of Java bean classes in my web application, and I am trying to find a simple way to implement the toString() methods in these beans. The toString() method would be used for logging throughout the application, and should print the attribute-value pairs of all attributes in the bean. I am trying out two alternatives: 1. BeanUtils.describe() (Apache commons-beanutils) 2. ReflectionToStringBuilder.toString() (Apache commons-lang) Since this is a web application expected to have high traffic, the implementation has to be lightweight and should not impact performance. (Memory

Java Bean: how <jsp:setProperty> in <jsp:useBean> is generated into Java Code

妖精的绣舞 提交于 2019-12-05 05:17:36
问题 For example, I have this code: <jsp:useBean id="dog" class="Dog" scope="application"> <jsp:setProperty name="dog" property="breed" value="House Dog !!!"/> </jsp:useBean> I know how it works. But, sometimes, I change some some code in this, for example: "dog" to "newDog", I will meet error or unguested-result (with me). Please give me how above code is generated into Java. (maybe just a main idea) Thanks :) 回答1: JSPs ultimately get generated to .java classes which get compiled as servlets.

Why isn't “has”… the beginning of a valid JavaBean method signature? [closed]

我的梦境 提交于 2019-12-05 03:35:49
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 7 years ago . The JavaBeans methods' signature's has to follow certain conventions such as set.../get... and such. They have a convention for is...for instance isEven() could be a method for an Integer class to test a boolean. But then I wonder why

Spring No unique bean of type

泄露秘密 提交于 2019-12-05 03:01:08
i have a little trouble in Spring with two component of a service. I have this component: @Component public class SmartCardWrapper and this one: @Component public class DummySmartCardWrapper extends SmartCardWrapper The service autowire both but spring fails due this expection: org.springframework.beans.factory.NoSuchBeanDefinitionException: No unique bean of type [com.cinebot.smartcard.SmartCardWrapper] is defined: expected single matching bean but found 2: [dummySmartCardWrapper, smartCardWrapper] Why it doesn't use class names? That's one of the most basic concepts of Spring - Inversion of

Is a boolean property name prefixed by “is” still a valid Java Bean?

时间秒杀一切 提交于 2019-12-05 01:52:56
I just noticed something I didn't know. private boolean isCertified; public boolean isCertified() { return isCertified; } public void setCertified(boolean certified) { isCertified = certified; } The following getters and setters have been generated by Intellij. By the way, Lombok generate the same kind of getters and setters. I would have expected something like: private boolean isCertified; public boolean isIsCertified() { return isCertified; } public void setIsCertified(boolean certified) { isCertified = certified; } That's why I usually don't prefix my boolean attributes with ìs , despites

Why does PropertyDescriptor return a property name with uppercase as first character?

孤街醉人 提交于 2019-12-05 01:46:53
问题 I'm obtaining an information about a class via Introspector.getBeanInfo(this.getClass()).getPropertyDescriptors() then getting the property's name by invoking propery[i].getName() . Everything is fine if a property has no one-letter-part. For example, if a property has a name personAddress (meanwhile its getter/setter -> getPersonAddress() , setPersonAddress(String personAddress) ), is's OK, getName() returns personAddress . But if the property has a name rPersonId ( getRPersonId() ,

Generating Java Bean setters in Eclipse

こ雲淡風輕ζ 提交于 2019-12-05 00:22:51
问题 We use Java beans on some projects where I work, this means a lot of handcrafted boilerplate code like this. I'm after an Eclipse plugin, or a way of configuring Eclipse code templates that allows a developer to generate the setters from a simple skeleton class, in a similar fashion to the 'Generate Getters and Setters' does for POJOs. Input public class MyBean { private String value; } Expected output public class MyBean { private final PropertyChangeSupport pcs = new PropertyChangeSupport

Controller (Spring Managed Bean) Scope Question: Singleton, Request or Session?

感情迁移 提交于 2019-12-05 00:11:43
问题 The question is a bit long since it's conceptual. I hope it's not a bad read :) I'm working in a performance critical Spring MVC/Tiles web-app (10,000 users typical load). We load an update employee screen, where we load an employee details screen (bound to an employee business object) for updates via a MultiActionController. There are multiple tabs on this screen, but only tab1 has the updatabale data. Rest of the tabs are read-only stuff, for reference basically. Needless to say, we've

Spring ReloadableResourceBundleMessageSource bean unable to find external properties

≡放荡痞女 提交于 2019-12-04 20:00:04
I've tried to use the Mkyong's guide to access external properties file, without any success. This is my bean definition in web-osgi-context.xml file located in WEB-INF: <bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> <property name="basenames"> <list> <value>classpath:bundles/resource</value> <value>classpath:bundles/override</value> <value>file:c:/test/messages</value> </list> </property> <property name="cacheSeconds" value="10"/> </bean> Accessing the bean: @SpringBean private ReloadableResourceBundleMessageSource messageSource;