[jboss-user] [JBoss Seam] - EntityHome and EntityQuery difference/problem

dnikolov do-not-reply at jboss.com
Wed Oct 10 18:11:04 EDT 2007


Note that this topic isn't about the difference between EntityHome and EntityQuery in general, but about the different behavior I get when I put a certain bit of functionality in classes extending these two.

So, my setup:

I followed ch 1 of the seam tutorial and put in a @DataModel and a @DataModelSelection on a data table so I can detect which row is selected. 

I set up the table so that if the current row is selected inputText elements are shown so a user can edit the information in the row. Otherwise outputText elements are rendered. 

On each row I also have an edit commandLink that is wired to a method that does something like this:


  | public String edit() {
  | 	this.deselectAll();
  | 	if(!this.selectionItem.getSelected()) {
  | 		this.selectionItem.setSelected(true);
  | 	}
  | 	return null;
  | }
  | 

I also have a save button on each row that does something like:

  | public String save() {
  | 	EntityObj obj = this.selectionItem.getEntityObj();
  | 	EntityManager em = this.getEntityManager();
  | 	em.persist(obj);
  | 	return null;
  | }
  | 

This seems to work fine in a class extending EntityHome (provided that in the save function I set the current instance to obj and then do persist on the current instance), but it doesn't work in the class extending entity query.

Tracing through this shows that after the user edits the input boxes and the save function is called, the EntityObj gotten from this.selectionItem.getEntityObj() has the values that were there before the user edit. 

selectionItem is the @DataItemSelection of course.

So.. any ideas why this works in one class and not in another? I am using the pages generated by seamgen to test this: I use a ___Edit.xhtml page with the ___Home.java, and a ___List.xhtml with the ___List.java.

Any feedback is greatly appreciated.

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

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



More information about the jboss-user mailing list