[jboss-user] [JBoss Seam] - Re: can factory methods have parameters?

matt.drees do-not-reply at jboss.com
Sun Sep 23 04:40:18 EDT 2007


"matt.galvin" wrote : 
  | There are two options that I've thought of.  First, I can use a commandLink and pass an id of the selected item through it, then look up the object in the method that is called.  I haven't done it, but can't think of why it wouldn't work.  It just doesn't feel "correct".
  | 

I don't think it's incorrect.  This is what seam gen apps do.  And my gut feel is you'll encounter less trouble this way.

"matt.galvin" wrote : 
  | The second was to switch to using a DataModel to back each table and use the DataModelSelection functionality.  This is what I think I should be doing.  The problem is, I don't know how to create the DataModel using a factory method that needs to take a parameter (ie, make the findCalculations method above be a factory).  
  | 

Right, factory methods can't have parameters.

"matt.galvin" wrote : 
  | Alternatively, I could remove the method parameters and add an injected property:
  | @In private Integer categoryId
  | But then I don't know how to have the proper value injected for each of the dataTables.
  | 
You could (I'm pretty sure) do something like

  | @In(value="#{category.id}") private integer categoryId
  | 

However, I don't think you should use the @DataModel / @DataModelSelection approach here.  The reason is you need multiple dataModels (one for each category), and @DataModel only gives you a single dataModel per variable.  You could use multiple dataModels with a more traditional JSF approach, though I think your first idea is easier.

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

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4087613



More information about the jboss-user mailing list