This discussion is archived
1 Reply Latest reply: Feb 22, 2012 9:23 AM by Brent Harlow RSS

How to search on unselected shuttle and not just selected

Brent Harlow Newbie
Currently Being Moderated
Is there a way where I can use the filter by on a parent shuttle to restrict the records shown in the unselected shuttle as well as the selected ?

Will I be able to accomplish this by creating a custom class that extends JhsSearchBean and applying the same query conditions to the VO populating the unselected shuttle box ?

Cheers,
Brent
  • 1. Re: How to search on unselected shuttle and not just selected
    Brent Harlow Newbie
    Currently Being Moderated
    I've managed to get this working by creating my own JhsSearchBean and editing the executeAdvancedSearchBinding method. After the normal search has been done, before returning the result I added the following code (basically copied from the JhsApplicationModuleImpl.advancedSearch method which is being called to run the search on the selected component of the shuttle)

    (this code makes an assumption that only the quick search is being used (single attribute being searched on)
         // Peform search on unselected iterator as well. Get unselected ViewObject
         BindingContext bctx = BindingContext.getCurrent();
         BindingContainer bindings = bctx.getCurrentBindingsEntry();
         DCIteratorBinding unselectedIterBinding = (DCIteratorBinding)bindings.get("EmployeesToBeActivatedShuttleIterator");
         ViewObject unselectedVo = unselectedIterBinding.getViewObject();
    
         if (arguments == null || arguments.size() == 0) {
            // clear any previously used view criteria
            unselectedVo.applyViewCriteria(null);
            unselectedVo.clearCache();
         }
         else {
    
            // Get item being searched on (assumes a single (quick) search item)
            DCControlBinding binding = ((DCBindingContainer)bindings).findCtrlBinding(searchItem);
            JUCtrlValueBinding vb = (JUCtrlValueBinding)binding;
            AttributeDef def = vb.getAttributeDef(0);
          
            // Create View Criteria to contain search attribute and value
            ViewCriteria vc = unselectedVo.createViewCriteria();
            ViewCriteriaRow vcRow = vc.createViewCriteriaRow();
            vcRow.setAttribute(def.getName(), searchText);
            vc.addElement(vcRow);
            
            // Requery unselected View Object using search criteria
            unselectedVo.applyViewCriteria(vc);
            unselectedVo.clearCache();
            unselectedVo.executeQuery();
         }
    After setting the requery condition on both the parent shuttle group and the unselected domain, all seems to be working as expected :)

    Does this seem like an worthy solution ? Or perhaps there is better way ?

    Cheers,
    Brent

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points