Can't get a conversational stateful bean to work
andrew.rw.robinson Jul 9, 2006 6:16 PMI have an administration bean that contains a list of users and then a dataTable that the user can select a user to edit or delete (or click an add button on the page to create a new user).
I wanted to start the conversation on add/edit. The problem I am having is that my methods are never called when the bean is in the conversation state.
Bean:
@Stateful
@Name("userAdmin")
@Interceptors(SeamInterceptor.class)
@Scope(ScopeType.CONVERSATION)
@TransactionAttribute(TransactionAttributeType.NOT_SUPPORTED)
@RolesAllowed(Roles.USER_ADMIN)
public class UserAdminAction
extends FacesBean
implements UserAdmin
{
@In(create=true)
private EntityManager entityManager;
private List<User> users;
@Out(required=false) @Valid
private User editingUser;
/**
* @return Returns the editingUser.
*/
public User getEditingUser()
{
return this.editingUser;
}
/**
* @see org.bethanyefree.beans.admin.UserAdmin#setEditingUser(org.bethanyefree.data.User)
*/
public void setEditingUser(User editingUser)
{
this.editingUser = editingUser;
}
@Begin(join=true, ifOutcome="edit.user")
public String editUser()
{
if (editingUser == null)
return null;
userPwordChanged = false;
initUserData();
return "edit.user";
}
@Begin(join=true)
@TransactionAttribute(TransactionAttributeType.REQUIRED)
public String onLoad()
{
if (load())
return null;
return "failed";
}
...
Pages.xhtml:
<pages>
<page view-id="/administration/users/index.xhtml" action="#{userAdmin.onLoad}" />
<page view-id="/administration/users/details.xhtml" action="#{userAdmin.checkEditing}" />
</pages>index.xhtml:
<t:dataTable value="#{userAdmin.users}"
var="_user">
...
<t:column>
<t:commandLink
action="#{userAdmin.editUser}"
styleClass="imageButton"
rendered="#{!_user.system}">
<b:imageButton url="edit" />
<seam:conversationPropagation type="join"/>
<t:updateActionListener property="#{userAdmin.editingUser}"
value="#{_user}"/>
</t:commandLink>
</t:column>
...
When I click the edit button nothing happens (setEditingUser and editUser methods are not called). If I change the bean's scope from CONVERSATION to SESSION everything works fine. I've tried just about everything I can think of:
* @Begin on the onLoad, begin not on the onload
* seam:link instead of commandLink
* seam:link instead of commandLink with propagate = begin and @DataModel on the users and @DataModelSelection on the editingUser
* Begin on the setEditingUser
And a bunch of other permutations involving the propagateConversation settings in both the seam link and a param to command link, using or not using begin, using updateActionListener vs. data model and data model selection, using the data model's name vs. bean.users method of referencing.
I have had no luck with any of these permutations. The only way I got it to work is using a SESSION bean (which is not what I am after).
I am obviously missing something, any ideas on what?
Thanks,
Andrew
Using Seam 1.0.1