[jboss-user] [JBoss Seam] - Re: Complex Search Results - return object identifiers inste
jfrankman
do-not-reply at jboss.com
Fri Jun 22 10:22:22 EDT 2007
My entity bean has session scope:
@Table(name="FBCLIENT",schema="DB2ADMIN")
| @Name("client")
| @Scope(ScopeType.SESSION)
| public class ClientVO implements Serializable
| {
| private static final long serialVersionUID = 2285612284592204149L;
|
| private Long id;
| private String notes;
| private String clientType;
| private String memberNumber;
| private Set<ClientLocationVO> entityLocations = new HashSet<ClientLocationVO>();
| private Set<PolicyVO> policies = new HashSet<PolicyVO>();
| private String search;
| private DrivingDistance drivingDistance;
| private String homePhone;
| private String workPhone;
| private String cellPhone;
| private String pagerNo;
| private String email;
| private ClientVO parentClient;
| private List<ClientVO> clientMembers=new ArrayList<ClientVO>();
|
| /**
| * @return the childMembers
| */
|
|
| @OneToMany(mappedBy="parentClient",fetch=FetchType.LAZY)
| public List<ClientVO> getClientMembers() {
| return clientMembers;
| }
|
| /**
| * @return the parentClient
| */
|
| @ManyToOne()
| @JoinColumn (name="parentclientid" )
| public ClientVO getParentClient() {
| return parentClient;
| }
| ....
When I perform the search I do not use a conversation, just a stateless session bean:
@Stateless
| @Name("search")
| public class SearchAction implements Search
| {
| @In Identity identity;
|
| @In private SearchVO searchvo;
| @In(create=true) private ClientService clientService;
| @In(create=true) private PolicyService policyService;
|
|
| @In(required=false)
| private FBWorker worker;
|
| @Out(required=false) private PolicyVO policy;
| public String performNameSearch()
| {
|
| searchResults = policyService.findPolicyHoldersByNameIncludeSubclients(searchvo.getSearchString());
|
| searchvo.setSearchResults(searchResults);
| return "success";
| }
|
| ...
When the user clicks the row in the datatable I then try and load the entire object by calling the lookupClientFromSearch method on my ClientAction stateful bean. :
<h:commandLink value="#{searchResult.clientVO.fullName}" action="#{clientAction.lookupClientFromSearch}"/>
Inside the lookupclientFromSearch I am using a conversation:
@Stateful
| @Name("clientAction")
| public class ClientActionImpl implements ClientAction
| {
| @In(create=true) private ClientService clientService;
| @In(required=false) @Out(required=false) ClientVO client;
| @In @Out(required=false) PolicyVO policy;
| @In(required=false) ClientVO subClient;
| @In(required=false) MasterSearchResultVO searchResult;
|
| @Begin(join=true)
| public String lookupClientFromSearch() {
| client=clientService.findClientByIdFetchGraph(searchResult.getClientVO().getId());
|
| if (client instanceof PersonVO)
| {
| organizationFlag=false;
| personFlag=true;
| System.out.println("The Client is a PersonVO");
|
| policy.getPolicyHolder();
| }
| else if (client instanceof OrganizationVO)
| {
| organizationFlag=true;
| personFlag=false;
| System.out.println("The Client is a PersonVO");
| }
| else
| {
| System.out.println("The Client is a only a ClientVO");
| }
|
| return "success";
| }
| @End
| ....
|
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4056898#4056898
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4056898
More information about the jboss-user
mailing list