Skip to main content

Spring ApplicationContext inside JSR-168 Portlet

Use following code to get Spring ApplicationContext inside portlet

PortletContext portletContext = this.getPortletContext();
ApplicationContext context = PortletApplicationContextUtils.getWebApplicationContext(portletContext);

then use context to retrieve beans

context.getBean("beanName");

Note : spring-webmvc-portlet.jar is required.

Another more generic way of accessing Spring Application Context
http://mdshannan1.blogspot.com/2010/11/easy-access-to-spring.html

Comments

Anonymous said…
Hi! Thank u for a very fresh idea. I am wondering why i have never though of this as well. I will definately try to use your blog for getting some more fresh info!

Thanks!

R, Aaron
here's my site too
Anonymous said…
Can I clone your article to my blog? Thank you…
Anonymous said…
keep up the great work , I read few articles on this web site and I think that your web blog is very interesting and has lots of excellent information.
some really fantastic info , Gladiola I noticed this.
Anonymous said…
Hi !!! Good job!
Wuzzap?
Anonymous said…
Useful publication and excellent presentation!
Anonymous said…
Thanks. I repost it on my Facebook.
Bob Peters, CA
Anonymous said…
Good Article
Anonymous said…
Good Article
Anonymous said…
Thanks for this post, it is great
Anonymous said…
I have tried many other services but yours appeared to be the best. Lots of thanks.
Anonymous said…
Very interesting subject , thanks for posting .
Unknown said…
Сайт nadietax.com - женский сайт о диетах, здоровом образе жизни, красоте, женском здоровье
Anonymous said…
to black; this means the flesh has become bruised or mouldy. If you buy green bananas a handy tip for speeding up their ripening is to put them in http://buyviagraonlineauviagra-au.com#1,6865E+84 buy Viagra au Is there? He, he was apparently and then on the Saturday or Sunday h h he, he started to reject so he had to go back in. http://buyviagra100mgcostviagraonline.co.uk#5192 buy viagra uk 221 In fact, this niche now comprises a growing segment of the beauty market
Anonymous said…
In most cases, fibroids treatment is not necessary in women uk lumigan Common side effects of the usage of Chinese herbal remedies are having stomach upsets due to digestion disorders
In the event that theses are not flushed out they'll can be become very dangerous buy cymbalta cost People often get affected by weather changes. We know how to avoid it!
The usage of nitrate preparations induces relaxation to patient's internal sphincter experiencing severe hemorrhoid generic Viagra for women There are around 30 different exercises that you can do at different stages to continuously trigger growth
While most diet pills cost around $50 a bottle, OxyElite Pro can be found for around $35 at most online stores, which is a pretty good deal buy generic iressa This is also the reason why women prefer this because they can actually perform these exercises wherever they are
Penis Enlargement PillsYou have to be careful of what you buy and what you take if you want to be successful in getting a larger penis Astelin Tip 1 - Eat A Rainbow Every DayThe American diet is very conductive in producing a toxic environment in which disease and illness thrive and can easily invade and cripple our system

Popular posts from this blog

Access multiple Databases in JPA

According to JPA specification we can define multiple "persistence-unit" elements (i.e. like below) in persistence.xml file and can easily refer them inside Dao layers as this. public class PolarDaoImpl {     @PersistenceContext(unitName="PolarPU")     protected EntityManager entityManager; -- } public class BearDaoImpl {     @PersistenceContext(unitName="BearPU")     protected EntityManager entityManager; -- } Checkout sample persistence.xml <?xml version="1.0" encoding="UTF-8"?> <persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">     <!-- Database 1 -->     <persistence-unit name="PolarPU" transaction-type="RESOURCE_LOCAL">         <

JPA 2 new feature @ElementCollection explained

@ElementCollection is new annotation introduced in JPA 2.0, This will help us get rid of One-Many and Many-One shitty syntax. Example 1: Stores list of Strings in an Entity @Entity public class Users implements Serializable {     private static final long serialVersionUID = 1L;     @Id     @GeneratedValue(strategy = GenerationType.AUTO)     private Long id;     @ElementCollection     private List<String> certifications = new ArrayList <String> ();     public Long getId() {         return id;     }     public void setId(Long id) {         this.id = id;     }     public List <String> getCertifications() {         return certifications;     }     public void setCertifications(List <String> certifications) {         this.certifications = certifications;     } .. }         Users u = new Users();         u.getCertifications().add("Sun Certified Java Programmer");         em.persist(u); Generated Tables    Users    Co

Reuse JPA Entities as DTO

Note : Major design advantages of JPA Entities are they can detached and used across tiers and networks and later can by merged. Checkout this new way of querying entities in JPA 2.0 String ql = " SELECT new prepclass2.Employee (e.firstname, e.lastname) FROM Employee e "; List<Employee> dtos = em.createQuery(ql).getResultList(); The above query loads all Employee entities but with subset of data i.e. firstname, lastname. Employee entity looks like this. @Entity @Table(name="emp") public class Employee implements Serializable {     private static final long serialVersionUID = 1L;     @Id     @GeneratedValue(strategy = GenerationType.AUTO)     private Long id;     @Column     private String firstname;     @Column     private String lastname;     @Column     private String username;     @Column     private String street;     @Column     private String city;     @Column     private String state;     @Column     private String zipc