spring

Spring and the scope attribute

Hi everyone, I am facing a problem in my Spring learning and would need some help, I don't think this require strong Spring skills as this is a beginner question. I was learning about the prototype scope of a bean, which basically mean that each time this bean will be required by someone or some other beans, Spring will create a new b...

spring portlet MVC and request params

Hi, Im setting a number of params in a URL (page.jsp?param1=value&param2=value2). When the url is requested it passes control to a Controller class, extending AbstractConrtoller , which overrides handleRenderRequestInternal to do my logic. Inside here i try to retrieve the request attributes using request.getAttribute and getParameter ...

Spring Advice - submitting a form

Hi, I am having serious problems with code I have written with Spring so I have decided to start from scratch and ask for advice. Here are my requirements: When the page first loads I need a list of objects retrieved from the DB that I can access on the JSP. I use this list to populate a drop down. When the user selects an object...

Using Spring JUnit4 and JMock together

When I run my Junit4 tests now I use the @RunWith(SpringJUnit4ClassRunner.class) annotation which allows me to inject Spring Beans into my test class. I would like to use the JMock 2 framework (which I have no real experience of) but examples I see require the following @RunWith(JMock.class). So my question is can I use JMock and Sprin...

Spring MVC Annotations with Global Context context:component-scan?

I have a spring dispatcher servlet with servlet-name "spring-mvc". The spring-mvc-servlet.xml appears as follows: <bean id="viewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver"> <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/> <property name="prefix" valu...

Which java web framework to choose for client side and server side validation?

We are currently searching for a java framework , that made validation easily on server side and both client side,Spring,Hibernate,Play are the framework choices that we are searching,we are using annotation based development and this framework will determine our javascript choice too.Which is better framework (architecturally) at valida...

Spring configuration in GWT Project?

I am developing a GWT-Spring-Hibernate project and I want to use Spring Autowired annotation in GWT Service Servlet but my autowired annotated service is not injected. it is null. Is there a configuration detail that I missed? I add <context:annotation-config /> <context:component-scan base-package="com.org" /> to my ApplicationConte...

Multiple @ManyToMany sets from one join table

Hi guys, I'm mapping a proprietary database to Hibernate for use with Spring. In it, there are a couple of jointables that, for entity A and entity B have the following schema: CREATE TABLE AjoinB ( idA int not null, idB int not null, groupEnum enum ('groupC', 'groupD', 'groupE'), primary key(idA, idB, groupEnum) ); As you ca...

How to tie the Lifecycle for a Spring Bean to the webapps' lifecycle ?

I want to create a bean that has start() and stop() methods. When the webapp's context is active, start() is called during Spring's runtime bootup. When the webapp is undeployed or stopped, the stop() method is invoked. Is this correct: I annotate my start() method with @PostConstruct and the stop() method with @PreDestroy ? Normally ...

Rewrite spring-security redirect URLs

I'm trying to get Tuckey UrlRewriteFilter to tidy up URLs for my webapp. One problem I've got is that when spring-security notices that an anonymous user is trying to access a protected resource it redirects to a URL which includes the servlet path. What I'd like is, by example: > GET http://localhost:8080/my-context/protected-resource...

How to restart transactions on deadlock/lock-timeout in Spring?

Hi, What is the best practice on implementing a transaction restart upon deadlock or lock timeout exceptions when using Spring (specifically the Spring recommended approach: declarative transactions) ? Thanks, Asaf ...

ref vs idref attributes in spring bean declaration

Can someone tell me the difference and which one has to be used when ? <bean id="b1" class="" /> <bean id="" class=""> <property name="b1" ref="b1" /> </bean> vs <bean id="" class=""> <property name="b1" idref="b1" /> </bean> ...

multi-staged form using spring

hi all, please forgive me for this stupid questions. I just started developing web application using spring yesterday. The project that i worked on, have a multi staged form, that require users to complete them before the data can be persisted on the database. Is there any way to keep those input in a temporary storage eg: session scope...

Getting server name in ContextLoaderListener

My listener is filling Cache (Terracota) and if something goes wrong at application start, ExceptionInInitializerError is thrown. I would like to get server name (like on HttpServletRequest - getServerName()) to know where this happened. How can I come to this information?? import javax.servlet.ServletContextEvent; import net.f.core.s...

Spring - share web application context between different webapps

Hi, I have a multi-module maven project. One of the modules is a util layer that has some spring beans. I want to share the same spring beans within the other modules. The other modules are deployed as non-related web-applications, so ideally my util beans would be singletons and I would only have one ref to these singletons throughout ...

Where I can find good Spring project example with Hibernate?

I need to make project with Spring + Hibernate, where I could find good example project how basic things are done? ...

How to user Hibernate @Valid constraint with Spring 3.x?

I am working on simple form to validate fields like this one. public class Contact { @NotNull @Max(64) @Size(max=64) private String name; @NotNull @Email @Size(min=4) private String mail; @NotNull @Size(max=300) private String text; } I provide getter and setters hibernate dependencies ...

Access properties file programatically with Spring?

We use the code below to inject Spring beans with properties from a properties file. <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="locations" value="classpath:/my.properties"/> </bean> <bean id="blah" class="abc"> <property name="path" value="${the.path}"/> </bean> Is th...

Spring workflow of HandleRenderedRequestInternal and OnSubmitAction

In my portlet application I have a spring SimpleFormController with a HandleRenderedRequestInternal method that is called when the page loads. On submitting a form I want the OnSubmitAction to be called and then the HandleRenderedRequestInternal to be called. Is this possible? At the moment when I submit a form it is going into handle...

Spring vs EJB. Can Spring replace EJB?

Since Spring is able to use transactions just like EJB. For me, Spring is able to replace the requirement of using EJB. Can anyone tell me what are the extra advantages of using EJB? ...