In an attempt to learn Seam I am experimenting with a simple CRUD example, 
partly based on the Yuan/Heute book.

The integration example shows an edit link as:
<a href="person.seam?pid=#{fan.id}">Edit</a>

With the Person class having:
@Entity
  | @Name("person")
  | public class Person {
  |   private long id;
  |   @Id @GeneratedValue
  |   public long getId() { return id;}
  |   public void setId(long id) { this.id = id; }

and person.xhtml having:
<h2>Edit #{person.name}</h2>
  | <h:form>
  | <input type="hidden" name="pid"
  |        value="#{person.id}"/>

and the ManagerAction class having:
@Stateful
  | @Name("manager")
  | public class ManagerAction implements Manager {
  | 
  |   @In (required=false) @Out (required=false)
  |   private Person person;
  | 
  |   // @RequestParameter
  |   Long pid;
  | 
  |   @DataModel
  |   private List <Person> fans;
  | 
  |   @DataModelSelection
  |   private Person selectedFan;
  | 
  |   public void setPid (Long pid) {
  |     this.pid = pid;
  |     
  |     if (pid != null) {
  |       person = (Person) em.find(Person.class, pid);
  |     } else {
  |       person = new Person ();
  |     }
  |   }
  |   
  |   public Long getPid () {
  |     return pid;
  |   }


Apologies for taking so long to get to the point but the issue I have is that I 
keep getting property X not found on type Y.  I had assumed that a Person 
instance would be maintained in the session state and injected/outjected as 
appropriate.

I had also assumed that the setPid method would be invoked via the edit link 
and thereby set person to the appropriate entity via the id, but this method 
isn't even called for me.  The fact that the RequestParameter annotation is 
commented out is a little disconcerting.

To make this work, up to a point, I have had to add @Scope(SESSION) to the 
entity and session beans but I still find that I am faced with a newly 
constructed Person instance rather than the one I thought I was operating on 
and that had been outjected into the shared context.

In desperation, I've also tried using the @DataModelSelection but without 
success - property not found again.

I suspect I'm missing something fundamental and have read about bijection and 
studied the example which look straightforward enough but something is missing 
and I can't figure out what it is!



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

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

Reply via email to