javabeans

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

强颜欢笑 提交于 2019-12-07 03:59:42
问题 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

Understanding Spring context initialization order

不打扰是莪最后的温柔 提交于 2019-12-07 03:11:36
问题 I have a complex set of beans and dependencies between them. All beans are @Service , @Repository or @Controller annotated and I use the @PostConstruct annotation. There are some circular dependencies but still the system was correctly initialized by Spring. Then I added a simple Controller with just a dependency to one of the Services. Theoretically, the system should be able to boot because theoretically it could first set up the system as before and then the new Controller. But Spring

Autowiring Spring superclass

怎甘沉沦 提交于 2019-12-07 03:07:52
问题 Why does Spring automatically choose the superclass types during autowiring? For instance, if I have @Component public class Foo {} @Component public class Bar extends Foo {} and someone autowires @Autowired private Foo foo; How come Spring always chooses the supertype Foo ? Shouldn't this be an " ambiguous " mapping (and cause Spring to throw an error)? Don't you technically have two Foo candidates? (e.g., Bar gets automatically picked when @Component is removed from Foo...) 回答1: That might

Clarify a situation with a cleaning Spring Prototype-beans from memory

痞子三分冷 提交于 2019-12-07 02:50:47
问题 I would like to understand whether I should clean prototype-beans from memory manually by myself. In the Spring documentation you can see: "The client code must clean up prototype-scoped objects and release expensive resources that the prototype bean(s) are holding." So from this it seems that you should clean prototype-beans by yourself. However. I'm using VisualVM memory profiler . I have created a number of prototype-beans. You can see 51 instances of them. Then you can see the situation

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

喜你入骨 提交于 2019-12-07 01:31:01
问题 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

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

不羁岁月 提交于 2019-12-06 23:43:25
问题 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..

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

删除回忆录丶 提交于 2019-12-06 21:46:03
问题 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) {

JSF & ui:repeat - issue with adding an object to cart

限于喜欢 提交于 2019-12-06 21:01:28
Once again I need some help with my pizza-search-programm I have written with Java Server Faces. The program: A user can search for pizzas by entering a form. A filtered search is possible as the user can decide whether he searches for a pizza name, a pizza id or other specified criteria. The program will generate a SQL query which returns pizza objects and stores it into a list of objects. A JSF page displays the list of pizza objects by iterating them through a ui:repeat tag. Pizza name, pizza ID, available sizes (displayed as radio buttons) and a list of possible quantities are displayed.

How to “logic:iterate” just one object?

和自甴很熟 提交于 2019-12-06 16:41:10
So, I have this code: logic:iterate name="nameForm" property="name" id="nameId" indexId="index" bean:write name="nameId" property="field1"/ bean:write name="nameId" property="field2"/ This works great because I'm receiving a "table of objects" so I can do the iterate without issues. Now, on another page I need to do the same but the issue is I am not receiving a "table of objects" but an object itself. I tried it nonetheless and - as expected - got the error: Cannot create iterator for this collection I've RTFM'd and I'm still more confused than before. I get how the "name" inside the "logic

jersey 2 multipart pojo is always null

﹥>﹥吖頭↗ 提交于 2019-12-06 15:11:09
I'm trying to write a rest service to upload a file along with some other file information, using Jersey + Jackson. Using multipart, the file is uploaded correctly, and simple fields are OK as well, but the POJO that's supposed to contain additional data, is always null. Simplified example POJO: public class Test { public String name; public Test() {} public String getName() { return name; } public void setName(String name) { this.name = name; } } Application: @ApplicationPath("myapp") public class JerseyApp extends ResourceConfig { public JerseyApp() { register(MultiPartFeature.class);