Tag Archives: list

When to use valueChangeListener or f:ajax listener?

Questions: What’s the difference between the following two pieces of code – with regards to listener placement? <h:selectOneMenu …> <f:selectItems … /> <f:ajax listener=”#{bean.listener}” /> </h:selectOneMenu> and <h:selectOneMenu … valueChangeListener=”#{bean.listener}”> <f:selectItems … /> </h:selectOneMenu> Answers: The valueChangeListener will only be invoked when the form is submitted and the submitted value is different from the initial… Read More »

Class “model.Address” is listed in the persistence.xml file but not mapped

Questions: I have created a JPA project. In that Eclipse displays the following error on the entity class. Class “model.Address” is listed in the persistence.xml file but not mapped How am I supposed to map the entity class in persistance.xml? Here is the model.Address entity: package model; import java.io.Serializable; import javax.persistence.*; @Entity public class Address… Read More »

Weird problem when binding a dynamic list

Questions: INITIAL QUESTION (UPDATED BELOW) I’m using an AutoPopulatingList list to instatiate an object invoking a constructor with some parameters. Something like the code below. I had used it before without any problems but I can’t get it working now. public class Tree { … private List<Node> nodes = new AutoPopulatingList<Node>(new ElementFactory<Node>() { @Override public… Read More »

Configuring RequestContextListener in SpringBoot

Questions: I have a Spring-Boot application which uses Spring-Security. I have a request scoped bean that I want to autowire into one of my custom Filters in the security filter chain, but at the moment it is not working. I understand that some config is needed to use request scoped beans outside of the DispatcherServlet,… Read More »

ClassCastException: RestTemplate returning List<LinkedHashMap> instead of List<MymodelClass>

Questions: I’m trying to access getter methods on my MyModelClass but my code is returning List<LinkedHashMap> instead of List<MyModelClass>. This is my code. List<MyModelClass> myModelClass=(List<MyModelClass>) restTemplate.postForObject(url,mvm,List.class); System.out.println(“Response= ” + myModelClass); I tried to print the response and I got the JSON Response that I’m expecting. but when I tried to run this code. System.out.println(“Response= “… Read More »

How to extend already defined lists and maps in Spring application context?

Questions: Imagine a staged application context with different phases. We start with an early phase to define the necessary infrastructure. The xml application contexts are loaded sequentially. The reason to split up these files is an extension/plugin mechanism. Stage 01-default-configuration.xml We prepare and declare the map with id exampleMapping to enhance them later with data.… Read More »

Adding event listener to audio HTML5 tag in javascript

Questions: Hi I’m creating a new audio tag element in Javascript this is the code: var audio = document.createElement(“audio”); audio.setAttribute(“id”,”myid”); audio.setAttribute(“autoplay”,”autoplay”); document.body.appendChild(audio); before appending it to the body, I’d like to place an onended event handler, I tried something like this: audio.onended = foo; where foo is something like: function foo(){alert(‘Hola’)} and audio.setAttribute(“onended”,”foo()”); in both… Read More »

receiving json and deserializing as List of object at spring mvc controller

Questions: My code is as below: controller @RequestMapping(value=”/setTest”, method=RequestMethod.POST, consumes=”application/json”) public @ResponseBody ModelMap setTest(@RequestBody List<TestS> refunds, ModelMap map) { for(TestS r : refunds) { System.out.println(r.getName()); } // other codes } TestS pojo public class TestS implements Serializable { private String name; private String age; //getter setter } Json request var z = ‘[{“name”:”1″,”age”:”2″},{“name”:”1″,”age”:”3″}]’; $.ajax({ url:… Read More »

Map JSON array of objects to @RequestBody List<T> using jackson

Questions: I’m having issues using Jackson to map a Javascript posted JSON array of hashes (Tag). Here is the data received by the controller @RequestBody (It is send with correct json requestheader): [{name=tag1}, {name=tag2}, {name=tag3}] Here is the controller: @RequestMapping(value = “purchases/{purchaseId}/tags”, method = RequestMethod.POST, params = “manyTags”) @ResponseStatus(HttpStatus.CREATED) public void createAll(@PathVariable(“purchaseId”) final Long purchaseId,… Read More »