Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing Spring 3.0 container from displaytag java file

 
Josephsrm Rajan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I am using Spring 3.0 Framework and also I am using my customized PdfView from org.displaytag.export package kept in one of my packages. when I tried to access the property file in spring 3.0 from the PdfView Java file I am getting a result of null. I came to know from some of the forums that accessing the spring 3.0 container from dispaly tag needs some tuning. Can you suggest some ways to fix. A prompt response is highly appreciated.

Regards,

Joseph
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are going to need to post code snippets showing the problem. I am having a hard time understanding what it is you are trying to do.
 
Josephsrm Rajan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is my Customized PdfView Code from org.displaytag.export package. I am keeping this package inside a Spring container. I have my properties file and xml files where I have specified my path. Now when I tried to print the path value using the annotation from spring 3.0, I received a null value.Any updation to resolve this is appreciated.

public class TemplatePdfView extends PdfView {


String mypath;
//protected PageContext pageContext;
// private Table tablePDF;
/**
* The default font used in the document.
*/
// private Font smallFont;
// private Font smallFont;

@Autowired
private VelocityEngine velocityEngine;

@Value("${app_path.loc}")
public String appPath;

public void setAppPath(String appPath) {
this.appPath = appPath;
}
static final Logger logger = Logger.getLogger(TemplatePdfView.class);
method()
{

logger.info(app_path.loc);
}
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Use Code Tags it makes it much easier for us to read.

How is TemplatePdfView getting instantiated? Is it a Spring managed bean? I don't see any stereo type annotations on it to pick it up on a component scan. Are you wiring it up in your spring context? Spring annotations can only work in Spring managed beans, so lets start there.
 
Josephsrm Rajan
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes of course I use @Service("PdfView") above my TemplatePdfView class.
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok so we will move forward with the assumption you have the class annotated with @Service and you have a component scanner in your context that picks that up and registers it as a Spring bean.

A couple more questions.

1. Check your velocityEngine and make sure it is not null. This will tell us that you have the correct stuff registered to process Spring annotations.
2. If #1 was not null, do you have a PropertyPlaceholderConfigurer(if you are using spring 3.0) or a , PropertySourcesPlaceholderConfigurer (if you are using spring 3.1) registered in your application context? If the answer is yes please please show me the relevant bits of the application context where you define your scanners and Property placeholder stuff.

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic