So imagine a scenario that you have one entity lets say people. You will provide a table
of all people. You can edit people and add new people.
Now you want to use jPDL and natural conversations (mix jPDL and pages.xml because jPDL
does not offer you to specify conversation name).
(note: I used to use deprecated method annotation for begin(id="foo.id"))
You start a conversation whenever you click on a person from table or a new person button.
You also want to join conversations with the same id.
Scenerio 1: (problem join)
you will click on person and will start conversation. In pages.xml is defined
| <conversation name="personHome"
| parameter-name="personName"
| parameter-value="person-#{empty person.id ? 'new' :
person.username}"/>
|
| <page view-id="/private/search/people/personHomeView.xhtml"
| conversation="personHome"
| conversation-required="true"
| no-conversation-view-id="/private/home.xhtml"/>
|
so your natural conversation has id==person.id
Problem 1. raises when you want to join conversations with the same name (same person).
Because the behavior is: start conversation, redirect to the page personHomeView.xhtml and
name the conversation id==person.id as defined in pages.xml. The thing is that
<conversation name="personHome"
| parameter-name="id"
| parameter-value="#{empty person.id ? 'new' :
person.id}"/>
should have parameter join. You cannot use annotation (join) on your selection method in
session bean. Because at that time the new conversation has id=random and named id is made
later from pages.xml.
The main point is that I can use join at the time when I do not know which object is
selected! so conversation has id=random which is renamed later in pages.xml, but if such a
conversation id already exists it throws an error instead of joining.
Note: this does not help because you do not know person instance at the time (otherwise as
SeamBay)
<h:commandButton ..action="select(person)" >
| <s:conversationName value=".."/>
| ..
|
(SeamBay does not show this, it has passing id via get, but it seems like very
un-maintainable and hacked solution)
Scenerio 2: (problem conversation rename)
Problem 2: you want to create a new person and then redirect to person home (jPDL).
<page view-id="/private/search/people/personHomeEdit.xhtml"
| conversation="personHome"
| conversation-required="true"
| no-conversation-view-id="/private/home.xhtml"/>
So you click on the button and call method that creates new object Person and starts new
conversation. Then after method is done it redirects you from table to personHomeEdit and
conversation is named id=new(note conversation id definition). Ok you fill out the form
and saves the person. Then you are redirected to a page personHome. BUT now the Person
instance has id now!!! so definition of conversationName evaluates it as conversation
id=person.id and not id=new.
personHome now expects conversation name id=person.id but such a conversation does not
exist! so I am redirect to a default page.
(Now I can manually check it in my method and in case of join redirect, but it is hack too
and seam should have something better)
What about make an clear example in your documnetation pages doing exactly this: one
entity and two pages (Home and HomeEdit). You will use natural conversations (No hack as
in SeamBay or maybe I did not look at it carefully). You can edit table entry(redirect to
Home and then to HomeEdit and then HomeEdit) and create new (redirect to HomeEdit then to
Home)
Thanks for answer
Tomas ;D
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4125965#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...