[jboss-user] [JBoss Seam] - Re: Entity Injection question

jacob.orshalick do-not-reply at jboss.com
Mon Oct 1 14:14:11 EDT 2007


In the scenario you describe, the only time an entity is going to be automatically created is if it is a named Seam component and it has the annotation @AutoCreate.  Is this how your entity is annotated?

...
  | @Entity
  | @Name("someEntity")
  | @AutoCreate
  | public class SomeEntity {
  | ...

Otherwise you would have to have a factory method somewhere...

@Factory(value="someEntity")
  | public SomeEntity initSomeEntity() {
  |   return new SomeEntity();
  | }

You have to specify when Seam should create instances of components.

As far as the following code...

  | public void submit() {
  | if (someEntity.someProperty != null) {
  |    log.debug("Entity's Property IS NOT NULL");
  | else {
  |    log.debug("Entity's Property IS NULL");
  | }
  | }

This code is necessary depending on what you're doing.  If you performing validation this could actually be done through <s:validate> or <s:validateAll> and use of @NotNull on your entity attribute.  Hope that helps.

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

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



More information about the jboss-user mailing list