• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Using spring within a taglib-class

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

I wrote my own taglib by extending javax.servlet.jsp.tagext.TagSupport.
Now I want to inject some properties with spring into this taglib-class.

Putting this stuff in my spring-context doesn't work.
Is there any possibility to use spring within a taglib?

Thanks
 
Ranch Hand
Posts: 15304
6
Mac OS X IntelliJ IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why would you want to do that? What spring bits are you trying to inject? I think you may be trying to do it in the wrong place since taglibs purpose are very View centric.
 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Chris,

As far as I know about spring you should simple have the public getters and setters in the class where you want to inject any property . The property itself should be the private instance variable(to repect java encapsulation). for ex:-

Class ABC{
private String name;

public String getName(){
return name;
}
public void setName(String name){
this.name=name;
}
}

Now spring config file will look as follows for injecting the property to this class.

<bean id="abc" class ="ABC">
<property name="name" value="XYZ"/>
</bean>

Please let me know if I have interpret your question in a wrong way, hope the above info is of some help.

Regards

Guru
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic