aspose file tools*
The moose likes Spring and the fly likes Accessing Spring 3.0 container from displaytag java file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Accessing Spring 3.0 container from displaytag java file" Watch "Accessing Spring 3.0 container from displaytag java file" New topic
Author

Accessing Spring 3.0 container from displaytag java file

Josephsrm Rajan
Greenhorn

Joined: Jun 14, 2012
Posts: 4
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

Joined: Mar 07, 2010
Posts: 1676
    
    7

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.


[How To Ask Questions][Read before you PM me]
Josephsrm Rajan
Greenhorn

Joined: Jun 14, 2012
Posts: 4
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

Joined: Mar 07, 2010
Posts: 1676
    
    7

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

Joined: Jun 14, 2012
Posts: 4
Yes of course I use @Service("PdfView") above my TemplatePdfView class.
Bill Gorder
Bartender

Joined: Mar 07, 2010
Posts: 1676
    
    7

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing Spring 3.0 container from displaytag java file