Hi,

I'm new to Seam and I'm trying to use the @Factory annotation to initialize the 
properties of a Managed Bean upon request of a jsf page, no matter if the 
request comes from a JSF context or not (ex. from another servlet).

My bean is super simple (see included code below), it only has 2 properties 
(postDate and postText) which need to be initialized to a value fetched from 
the database. I'd like to make the initialization take place when the page is 
requested using a Factory method (myFactory). The page gets displayed but the 
method myFactory is never called. What am I doing wrong?

Thanks!
Math


  | ...
  | 
  | @Name("newsBean")
  | @Scope(ScopeType.SESSION)
  | public class NewsBean implements Serializable {
  |     
  |     private static final long serialVersionUID = 1L;
  |     @In
  |     ToolbarBean toolbarBean;
  |     @In
  |     SessionBean sessionBean;
  |     @Out(required=false)
  |     Date postDate;
  |     @Out(required=false)
  |     String postText;
  |     
  |     public String process(){
  | 
  |             try {
  |                     // update toolbar
  |                     
toolbarBean.setCurrentReport(ToolbarBean.CURRENT_REPORT_NOT_SET);
  |                     
toolbarBean.setPrinterFriendlyPath("/dynamic/faces/dataview/newsPF.jsf");
  |                     toolbarBean.setShowExportToExcel(false);
  |                     
toolbarBean.setReportName(TextResource.getTextResourceString(new 
TextKey("News"),null,sessionBean.getCurrentLocale()));
  |                     toolbarBean.setRefreshAction("newsBean.process");
  | 
  |                     Language language = 
LanguageDAO.getInstance().findByPk(sessionBean.getLanguageCode());
  |                     News news = NewsService.getInstance().findCurrentNews();
  |                     postDate = news.getNewsTime();
  |                     postText = news.getNewsDescription().getText(language);
  | 
  |             } catch (Exception ex){
  |                     MessageHandler.handleGenericException(ex);
  |                     return "error";
  |             }
  |             
  |             return "success";
  |     }
  |     
  |     @Factory("postDate")
  |     public void myFactory(){
  |             process();
  |     }
  | 
  | ...
  | 

View the original post : 
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4046532#4046532

Reply to the post : 
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4046532
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user

Reply via email to