javabeans

JPS useBean with HashMap

会有一股神秘感。 提交于 2019-12-11 01:08:05
问题 How do I use jsp:useBean with collections like Lists and Maps correctly? I can get Lists by using type="List<MyObject>" but I cannot get the List to instantiate if nothing is passed. class="ArrayList<MyObject>" And the above attribute gives an error: The value for the useBean class attribute ArrayList <MyObject > is invalid. And both the attributes fail for a HashMap. Currently, I'm reading the objects using getAttribute() but it'll be cleaner to use the tags and set them up. 回答1: Have you

List into other List jasper report

青春壹個敷衍的年華 提交于 2019-12-11 00:57:33
问题 I have this object structure, to use like Java Bean in mi jasper report, public class Person{ private String name; private String lastname; private List<Job> jobs; } public class Job{ private String jobName; private String companyName; private List<Reponsability> responsabilities; } All class with corresponding setters and getters When I create a list into jasper report I define the "job list" JRDataSource expression this way: new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F

How to have a class use applicationContext beans?

时光怂恿深爱的人放手 提交于 2019-12-10 23:09:38
问题 I'm working on my first java struts2 webapp and want to be able to inject bean parameters into any arbitrary class that is called. But I find that I can only do this with struts action classes... Let's say I have this bean in my applicationContext.xml file: <bean id="BeanTest" class="BeanTest"> <property name="test" value="someval" /> </bean> If I have a struts action class setup called BeanTest (like so), and I add a setter (public void setTest()), then the test parameter will be set and I

Emulating jsf 2.0 view scope in JSF 1.2 with Spring beans

送分小仙女□ 提交于 2019-12-10 22:26:17
问题 I'm working on a project using JSF 1.2 deploying a portlet to WebSphere Portal Server 6.1 on top of WAS 7. For various contractual/political reasons, we're stuck with JSF 1.2. However. we are using Spring beans throughout our application in order to get AoP logging. It is somewhat annoying that we can't use JSF 2.0. In particular, view scope would be ideal for our app. It will be a high usage site and keeping all the page beans in session scope is wasteful and I'm sure will cause raised

Copy property with different names between beans using BeanUtils

删除回忆录丶 提交于 2019-12-10 17:50:02
问题 I would like to copy the property values from Class A to Class B with BeanUtils which has same fields but with different names . Is it possible to provide a map of property name to differentName, age to differentAge etc., and achieve the copying? I am interested to know if this is possible by any means using only Apache Commons utilities (not any other tools). class ClassA{ private String name; private Integer age; ... // Setter and Getter methods } class ClassB{ private String differentName;

Java Bean Specifications for boolean field

笑着哭i 提交于 2019-12-10 16:45:56
问题 I have Java bean with the field activeRecord private Boolean activeRecord; @Override public Boolean isActiveRecord() { return activeRecord; } @Override public void setActiveRecord(Boolean activeRecord) { this.activeRecord = activeRecord; } when I send it in List as Jasper Report data source List<Branch> dataList = new BranchLogic().selectAll(); JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(dataList); I get the error message net.sf.jasperreports.engine

Invoke Backing bean method from JavaScript + JSF

試著忘記壹切 提交于 2019-12-10 14:59:52
问题 I want to invoke backing bean method from javascript function in JSF. Please could you guide me how to achive this. Regards, Ravi Krish 回答1: Since, Backing bean method id Server side so you need to make request to server better way for your case would be Richfaces JSFunction , Live Demo Link Ajax4JSF 来源: https://stackoverflow.com/questions/3581499/invoke-backing-bean-method-from-javascript-jsf

Injecting a SessionScoped Stateful bean in EntityListener

旧时模样 提交于 2019-12-10 13:44:58
问题 I'm trying to implement some sort of auditing in a Java EE JPA application on GlassFish 3. I have added a @EntityListeners annotation on my @MappedSuperclass entity, the listener has the @PrePersist and @PreUpdate annotation on its methods which are invoked happily at runtime. In these methods, I'm trying to use ( @Inject ) a @Named , @Stateful , @SessionScoped bean ( UserSession ) in order to get current user's id. The listener class has no annotations at all. The problem is that I can't get

constructor-arg and property together in bean definition

混江龙づ霸主 提交于 2019-12-10 12:59:40
问题 <bean id="cObject" scope="request" class="x.y.z.CClass"/> <bean id="bObject" scope="request" class="x.y.z.BClass"/> <bean id="aObject" scope="request" class="x.y.z.AClass"> <constructor-arg ref="bObject" /> <property name="cRef" ref="cObject" /> </bean> aObject.cRef is not getting set for some reason. Note that constructor-arg and property are used in the same definition. I have not seen an example / post with similar feature. 回答1: Mixing <constructor-arg> and <property> is generally a bad

Spring Bean property 'xxx' is not writable or has an invalid setter method

帅比萌擦擦* 提交于 2019-12-10 12:48:30
问题 I'm a Spring newbie with a seemingly simple Spring problem. I worked on this for hours without luck. Here is the exception, followed by the code (thank you in advance): Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'graphiteWriterSession' defined in file [/home/user/resources/jmxtrans.graphite.xml]: Error setting property values; nested exception is org.springframework.beans.NotWritablePropertyException: Invalid property