-
1. Re: Recursion in EntityHomes
franciscoperedo Mar 14, 2008 2:22 AM (in response to franciscoperedo)Hi!
I am trying to understand the seam-generated applications.
I seems that they work like this:- The EntityList.xhtml page show all the instances of an entity, it allows to search a particular subset of the instaces of that entity, there is no conversation here.
- You can click a particular entity and
view/inspect
it, doing this will redirecto you the Entity.xhtml page, still no conversation. - From Entity.xhtm you may edit the current entity instance or you may add child Entity instances.
- If you choose to modify the entity you are redirected to EntityEdit.xhtml, now we have a long running conversation (why, if we were fine util now without a conversation we need one now?)
- If you choose add a chid entity, you also start a long running conversation... but I fail to see the point in doing it...
- If you choose add a chid entity, and the child entity is of the same type as the parent entity... then you will have problems, because... how can you differentiate between the EntityHome of the parent entity and the EntityHome of the child entity? They are, in fact, the exact same component!!! If I click to add the recursive child, I end up creating a relationship between the current entity instance and itself.
Now... I tought I could solve this problem by using nested conversations... but there is no conversation until after I click to add the child entity, therefore a nested conversation is not only not useful, it is plain wrong, because we don't even have a
top-level
conversation.Is the EntityHome/Entity.xml/EntityEdit.xml pattern as implemented in seam-gen usable for recursive relationships? I am really starting to think that the answer is no, because the EntityEdit.xml seams to be designed to always be called by Entity to edit the current instance, and never to create a new instance of the same type connected to the previously viewed instance...
Do I make any sense? Can anyone offer any hints at all?
Thanks,
Francisco -
2. Re: Recursion in EntityHomes
franciscoperedo Mar 14, 2008 2:48 AM (in response to franciscoperedo)Hi!
The problem seems to be that, when adding the chid entity instance over the recursive relationship, the
id
of the parenty entity isautomatically propagated
it doesn't matter if theAdd child
button has the parameter or not, it is propagated because it is in EntityEdit.page.xml... mmmm....What if I delete that line... well then the normal non-recursive Edit button will stop working...
It seems that the EditEntity.xhml can only be used in the context of modifying a new entity and not in the context of adding a recursive child... and the pageflow defined just doesn't seem to allow any other use...
The problem here seems to be that I have 3 alternative page flows..:
- From List all instances to Edit a new instance
- From List all instances to View an instance to Edit that instance
- From List all instances to View an instance to Edit a new child of that instance that is of the same type as the parent instance
IMO the problem is that 2 and 3 get mixed... I need to make the aplication
forget
that it was Viewing an Entity so that i can create a a new instance (as in 1) but at the same time it has to remember toconnect
that instance to the parent instance...Any hints at all?
Regards,
Francisco
-
3. Re: Recursion in EntityHomes
pmuir Mar 14, 2008 10:04 AM (in response to franciscoperedo)
Francisco Peredo wrote on Mar 14, 2008 02:22 AM:
Is the EntityHome/Entity.xml/EntityEdit.xml pattern as implemented in seam-gen usable for recursive relationships? I am really starting to think that the answer is no, because the EntityEdit.xml seams to be designed to always be called by Entity to edit the current instance, and never to create a new instance of the same type connected to the previously viewed instance...Not ootb. I would use an EntityHome to manage to the top level entity, and then write some extra code to manage the recursion.
-
4. Re: Recursion in EntityHomes
franciscoperedo Mar 14, 2008 4:06 PM (in response to franciscoperedo)Hi!
The thing is I don't quite get how the org.jboss.seam.framework.EntityHome receives the primary key through the query string.
The query string key looks like this: entityNamePrimaryKeyName but I do not see any:
@RequestParameter Long entityNamePrimaryKeyName;
declared in org.jboss.seam.framework.EntityHome (of course it would be impossible since EntityHome is generic base clase inside the seam jar)
I have been trying to understand how this works to change it and add recursive behavior but I don't get it.. If I go up in the inheritance hierarchy I can see that code to handle primary keys is added at the org.jboss.seam.framework.Home, but I don't know how the private Object id gets the value from the entityNamePrimaryKeyName request parameter.
It uses an interceptor of some kind? how does it work? how can it know wich query string parameter is the one that contains the primary key?
Thanks
Regards,
Francisco
-
5. Re: Recursion in EntityHomes
franciscoperedo Mar 14, 2008 5:15 PM (in response to franciscoperedo)Hi!
The Entity Home of, for example Users, with a primary key with name IdUser will look like this:
public void setUserIdUser(Long id) { setId(id); } public Long getUserIdUser() { return (Long) getId(); }
How does seam know it has to call this method? (It doesn't have a @RequestParameter anywhere!
Regards,
Francisco
-
6. Re: Recursion in EntityHomes
pmuir Mar 14, 2008 5:36 PM (in response to franciscoperedo)Page parameters.
-
7. Re: Recursion in EntityHomes
franciscoperedo Mar 14, 2008 7:49 PM (in response to franciscoperedo)Thanks, yes, you are right, the Page parameters, sorry for the silly question...
I got it to the point where it saves the recursive child and not a referece to itself, the problem now is that after saving the child, instead of going back to view the parent, it goes to view the recently added child...
-
8. Re: Recursion in EntityHomes
xourge May 26, 2008 4:16 AM (in response to franciscoperedo)hi, can you tell me how did you get it working using Page parameters?
thanx