-
1. Re: Start a nested conversation
gavin.king Jun 21, 2007 10:57 AM (in response to g00se24)I have no idea what you're trying to do here. Please give much more information.
-
2. Re: Start a nested conversation
g00se24 Jun 22, 2007 3:15 AM (in response to g00se24)The long explanation is something like this:
Idea: Select and edit an entity bean, in a conversation
I have a h:dataTable with buttons which have a seam like action method (el enhancement). The backing bean is annotated to start a conversation if the method is called. The first conversation is started and you get redirected to the an "edit" page.
Here you can edit the attributes of the object. So I was able to implement the direct attributes. Now I tried to start a nested conversation to select the Master-Detail related entities.
But this on an ajax (a4j + richfaces) enabled site.
Do you need some code? -
3. Re: Start a nested conversation
g00se24 Jun 22, 2007 4:16 AM (in response to g00se24)Here is the code:
First seam bean
These bean start the outer conversation, when a user gets selected (call select(object)).
Now the user gets redirected to a page where he can see and edit the user.
(The select method is called via an s:link)@Name("searchuser") @Conversational(ifNotBegunOutcome="start") @Scope(ScopeType.CONVERSATION) public class UserControl extends Selection implements Serializable { @In private PreLogin loginData; private boolean edit = false; public void edit(boolean edit) { this.edit = edit; } public User getSelected() { User selected = ((User)super.getSelected()); if (selected != null) { selected.toString(); } return selected; } @Begin public void add() { edit(true); setSelected(new User()); } @Begin @End public void delete(User user) { if (user != null) { user.setStatus(StateEnum.DELETED); entityManager.merge(user); } } @Begin public void select(Object object) { super.select(object); } @End public void save() { entityManager.merge(getSelected()); } @End public void cancel() { setSelected(null); } public List<User> getResult() { return super.getResult(); } public String getQuery() { return Finder.searchUser(loginData.getUser().getClient().toString(), "surName", getSearch(), "surName"); } public boolean isEdit() { return edit; } } public abstract class Selection { @In protected EntityManager entityManager; @Logger protected Log log; /** * The text of an input field filled by the user. This field is used to * filter the db query. */ private String search = ""; /** * The last selected object. */ private Object selected; public String getSearch() { return search; } public void setSearch(String search) { this.search = search; } protected List getResult() { List query = entityManager.createQuery(getQuery()).getResultList(); return query; } public Object getSelected() { return selected; } public void setSelected(Object selected) { this.selected = selected; } public void select(Object object) { setSelected(object); } public abstract String getQuery(); }
If the user clicks now on an link like:<a4j:commandLink value="Edit" action="#{subchannels.select(item)}" oncomplete="javascript:Richfaces.showModalPanel('subchannel',{width:450, top:200})" reRender="subchannelsSelectable, subchannelsEdit"> <s:conversationId /> <s:conversationPropagation type="Begin"/> </a4j:commandLink>
or<a4j:commandLink value="Edit" action="#{subchannels.select(item)}" oncomplete="javascript:Richfaces.showModalPanel('subchannel',{width:450, top:200})" reRender="subchannelsSelectable, subchannelsEdit"> <s:conversationId /> <s:conversationPropagation type="nested"/> </a4j:commandLink>
The nested conversation should start, the @Begin method is called, but I can't see the conversation anywhere....
The second end up with a null pointer exception at java.lang.NullPointerException
at org.jboss.seam.core.Manager.handleConversationPropagation(Manager.jav
a:534)
If I use the s:link I would really start to miss my ajax.... The problem is which one is the correct link solution (I believe)?