[jboss-user] [EJB 3.0 Users] - SessionBean and the case of RESTRICTIONS for entitquery
nmatrix9
do-not-reply at jboss.com
Mon Oct 26 00:50:07 EDT 2009
Hello EJB 3.0 Users
I've just noticed that creates class that extends EntityQuery, some generated classes do NOT have any restrictsion set in the RESTRICTIONS array. I tried to find out why but so far I have not found any useful information on this. Anyways I have a class called ExoshellUsersRolesList that extends EntityQuery (originally generated by Seam-Gen) to which it did not have it's RESTRICTIONS array set. So I decided I would manually set the array myself like so.
package com.domain.exoshellcms.session;
import com.domain.exoshellcms.entity.*;
import org.jboss.seam.ScopeType;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.annotations.Scope;
import org.jboss.seam.framework.EntityQuery;
import java.util.List;
import java.util.Arrays;
@Name("exoshellUserRolesList")
@Scope(ScopeType.SESSION)
public class ExoshellUserRolesList extends EntityQuery {
/* UNABLE TO GET RESTRICTIONS TO WORK WITHOUT POINTING TO NULL PARENT OBJECT I.E. exoshellUsers, exoshellRoles or exoshellModules */
private static final String[] RESTRICTIONS = {
"lower(users.username) like concat(lower(#{exoshellUserRolesList.exoshellUserRoles.exoshellUsers.username}),'%')",
"lower(exoshellUserRoles.exoshellRoles.roleName) like concat(lower(#{exoshellUserRolesList.exoshellUserRoles.exoshellRoles.roleName}),'%')",
"lower(exoshellUserRoles.exoshellModules.moduleName) like concat(lower(#{exoshellUserRolesList.exoshellUserRoles.exoshellModules.moduleName}),'%')"
};
private ExoshellUserRoles exoshellUserRoles = new ExoshellUserRoles();
private String queryString = new String("select exoshellUserRoles, users from ExoshellUserRoles exoshellUserRoles join fetch exoshellUserRoles.exoshellUsers users");
@Override
public String getEjbql() {
return queryString;
}
public ExoshellUserRoles getExoshellUserRoles() {
return exoshellUserRoles;
}
@Override
public List getRestrictions() {
return Arrays.asList(RESTRICTIONS);
}
@Override
public String getOrder() {
return new String("exoshellUserRoles.userRolesId asc");
}
}
I then created a corresponding interface form to search through a datable using the ExoshellUsersList like so:
<rich:simpleTogglePanel label="User Roles search parameters" switchType="ajax" opened="false" ignoreDupResponses="true" eventsQueue="userSearchQueue" requestDelay="2000" immediate="true" rendered="false">
<s:decorate template="/layout/display.xhtml">
<ui:define name="label">User Name</ui:define>
<h:inputText id="userRoleName" value="#{exoshellUserRolesList.exoshellUserRoles.exoshellUsers.username}">
<a:support event="onblur" reRender="panelusers,userRolesPaginator" ignoreDupResponses="true"/>
</h:inputText>
</s:decorate>
<s:decorate template="/layout/display.xhtml">
<ui:define name="label">Role Name</ui:define>
<h:inputText id="userRoleRolename" value="#{exoshellUserRolesList.exoshellUserRoles.exoshellRoles.roleName}">
<a:support event="onblur"/>
</h:inputText>
</s:decorate>
<s:decorate template="/layout/display.xhtml">
<ui:define name="label">Module</ui:define>
<h:inputText id="userRoleModule" value="#{exoshellUserRolesList.exoshellUserRoles.exoshellModules.moduleName}">
<a:support event="onblur"/>
</h:inputText>
</s:decorate>
</rich:simpleTogglePanel>
Unfortunately this was not enough as when I try to input text into one of the search fields (like User Name) upon ajax update I get the error:
Exception during request processing:
Caused by javax.servlet.ServletException with message: "/admin/ExoshellUserRolesEdit.xhtml @339,122 value="#{exoshellUserRolesList.exoshellUserRoles.exoshellUsers.username}": Target Unreachable, 'exoshellUsers' returned null on 'com.domain.exoshellcms.entity.ExoshellUserRoles'"
Any insight, documentation or solutions to the exception above would be greatly appreciated. I've include the relied upon EJB entities below after this post.
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4262077#4262077
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4262077
More information about the jboss-user
mailing list