newbie: conversation questions
mars1412 Feb 14, 2008 6:46 PMthe explanation here will be quite long, but I am sure, it took me much longer to write and that the questions are easy to answer.
I've already read loads of docs and studied the seam-gen generated examples, but
I'm quite stuck with that conversation thing right now
I tried to slightly adapt the seam-gen list/edit page stuff (talking of seam-gen 2.0.0.GA), in following way:
I do not want a separate page where the data is displayed and another page where the data is edited - I always want to go to the edit page.
let' start with the list.xhtml page:
I didn't change anything here - I think I understand this code, except for this:
<s:button view="/CategoryGroupEdit.xhtml" id="create" value="Create categoryGroup"> <f:param name="categoryGroupId"/> </s:button>
question 1)
what is the param for, if it does not have a value?
is it to reset the parameter value to null?
in the table I display the data and the user has a button to get to the edit page (the id is passed via a page parameter):
<s:button id="change" value="#{messages['object.change']}" view="/private/category/categoryGroup.xhtml"> <f:param name="categoryGroupId" value="#{categoryGroup.id}" /> </s:button>
now to the edit page:
backing bean is categoryGroupHome which extends Entity Home - some code:
@Factory("categoryGroup") public CategoryGroup initCategoryGroup() { return getInstance(); } public Long getCategoryGroupId() { return (Long)getId(); } public void setCategoryGroupId(Long id) { setId(id); }
the edit page has a page.xml file (from seam-gen):
<begin-conversation join="true"/> <param name="categoryGroupId" value="#{categoryGroupHome.categoryGroupId}"/> <navigation from-action="#{categoryGroupHome.persist}"> <end-conversation/> <redirect view-id="/private/category/categoryGroup.xhtml"/> </navigation> <navigation from-action="#{categoryGroupHome.update}"> <end-conversation/> <redirect view-id="/private/category/categoryGroup.xhtml"/> </navigation> <navigation from-action="#{categoryGroupHome.remove}"> <end-conversation/> <redirect view-id="/private/category/categoryGroupList.xhtml"/> </navigation>
<action execute="#{categoryGroupHome.wire}"/>
question 2) I deleted the code above: what is it good for to call the wire function, wich is empty?
<begin-conversation join="true"/>
this means: everytime I call this page, a new conversation is begun (if one exists, this one is used)
question 4) what happens, when I am on the page (conversation already exists) and I execute categoryGroupHome.persist?
I suppose:
after persist is called, the current conversation is ended
then the redirect is sent to the client, which will call this page again: thus a new conversation is created immediately
the edit page simply displays data from the categoryGroupHome object and has some buttons:
<h:commandButton id="save" value="#{messages['object.create']}" action="#{categoryGroupHome.persist}" rendered="#{!categoryGroupHome.managed}"/> ... <s:button propagation="end" id="done" value="#{messages['object.done']}" view="/private/category/categoryGroupList.xhtml"/>
no to the main thing that I don't understand:
When I remove the empty categoryGroupId parameter from the create button in the list page (see question 1),
then this happens:
I open the list page
debug page shows no conversations
I click create
- url: cid=56
- debug page: 1 conversation with id 58!
question 5) why is that no the same as in the url
enter some data and click 'create'
- I am redirected to the same page again
- url: cid=58 now
- debug page: 1 conversation with id 58
click 'done'
- url: ?conversationPropagation=end&cid=58
- debug page: no conversation
click 'create' in the list page again
- I see the data of the entity that I have created before
question 6)
how does the edit page remember
the id of the new entity?
- the conversation has been destroyed
- the url does not include any parameters
- the sourcecode does not include any hidden form fields with that Id
question 7)
has it maybe smth. todo with the s:button?
any comments are welcome
P.S.
- tx for reading all this boring newbie stuff
- did you notice that question 3 is missing :)
- how can I nest unordered lists in this forum?