List Shuttle Validation Error
thetikigod.tiki_god.mail.com Oct 29, 2008 3:47 PMHello everyone.
Using:
Seam 2.0.2, JBoss AS 4.3.2, MySQL
I am getting a validation error from my list shuttle. I have implemented a converter and have overrided the equals and hashCode on my entity. Here are some snippets from my code:
from console.xhtml:
<rich:modalPanel id="editUserRolePanel" width="300" height="100">
<f:facet name="header">
<h:outputText value="Add/Remove Roles" />
</f:facet>
<s:div id="userRolesToEdit">
<h:form>
<rich:listShuttle id="roleShuttle" sourceValue="#{usermanager.unassignedRoles}" targetValue="#{user.roles}" var="r" converter="roleconverter" fastOrderControlsVisible="false" orderControlsVisible="false">
<rich:column>
<h:outputText value="#{r.roleId}" />
</rich:column>
</rich:listShuttle>
<rich:spacer height="15" />
<center>
<h:commandButton value="Save" action="#{usermanager.edit}" oncomplete="Richfaces.hideModalPanel('editUserRolePanel'); return false" reRender="usersTable" />
<h:commandButton value="Cancel" action="#{usermanager.cancel}" oncomplete="Richfaces.hideModalPanel('editUserRolePanel'); return false" />
</center>
</h:form>
</s:div>
</rich:modalPanel>RoleConverter.class:
@Stateless
@Name( "roleconverter" )
@org.jboss.seam.annotations.faces.Converter
public class RoleConverter implements Converter {
@PersistenceContext
private EntityManager em;
public Object getAsObject( FacesContext context, UIComponent component, String value ) {
if (value != null) {
System.out.println( "RoleConverter: converting string " + value + " to Role.");
return (Role) em.find( Role.class, value );
}
return null;
}
public String getAsString( FacesContext context, UIComponent component, Object value ) {
if (value != null) {
System.out.println( "RoleConverter: converting role " + ((Role) value).getRoleId() + " to String.");
return ((Role) value).getRoleId();
}
return null;
}
}from UserManagerAction.java:
@Name( "usermanager" )
@Stateful
@Scope( ScopeType.CONVERSATION )
@SerializedConcurrentAccess
@Interceptors( SeamInterceptor.class )
public class UserManagerAction implements ManagerAction, Serializable {
@Logger
private Log log;
@PersistenceContext
private EntityManager em;
@In( create = true )
@Out( required = false )
@DataModelSelection
private User user;
@DataModel
private List<User> foundUsers;
@In( required = false )
@Out( required = false )
private List<Role> unassignedRoles;
...
@Begin
public String init() {
log.info( "Opening user: ", this.user.getUserId() );
unassignedRoles = em.createQuery( "select r from Role r" ).getResultList();
unassignedRoles.removeAll( this.user.getRoles() );
return null;
}
@End
public String edit() {
log.info( "Saving changes to user: ", this.user.getUserId() );
System.out.println( user.getRoles() );
this.em.merge( this.user );
this.find();
this.user = null;
return null;
}
...
// Appropriate getters and setters
}The shuttle gets the right values when it loads and the debug statements show the converter is working, however, when save is clicked, the lists are not updated and I get the following error and no exceptions at the console:
10:41:41,030 INFO [lifecycle] WARNING: FacesMessage(s) have been enqueued, but may not have been displayed.
sourceId=j_id54:roleShuttle[severity=(ERROR 2), summary=(j_id54:roleShuttle: Validation Error: Value admin is not valid), detail=(j_id54:roleShuttle: Validation Error: Value admin is not valid)]
I really could use your help on this one as I am new to Seam and only been working with it for 2-3 weeks. This error has baffled me for a few days now and online resources havent been much help.
Thanks