Yes you can leverage user defined List Views programatically via the StandardSetController. In two ways, one is utilising the one the platform creates for you or by creating an instance of this class yourself.
Take a look at these questions and answers for examples StandardSetController List Instatiation and setFilterId. Also this one around Custom Buttons that can sit on the standard List View UI and provide a check box UI for free, which is the most common way to use them Creating a custom list-view button that handles multi-record selection.
If you need more flexibility, as mentioned in one of the referenced questions above, you can choose to create your own instance, it's quite an advanced usage though, so consider the Custom Button route first. Here is a code example where you can set the List View (via setFilterId) and effectively reuse the criteria the user has setup using the standard List View UI. A great example of going native on the platform!
string SOQL = 'SELECT Id, Name, Phone FROM Account Order By Name DESC';
List<Account> accounts = Database.query(SOQL);
for(Account account : accounts)
System.debug(account.Name + ', Phone: ' + account.Phone);
ApexPages.StandardSetController ssc =
new ApexPages.StandardSetController(Database.getquerylocator(SOQL));
ssc.setPageSize(2000);
ssc.setFilterId('00BG000000702tj'); // 'Platinum and Gold SLA Customers'
ssc.setPageNumber(1);
for(Account account : (List<Account>) ssc.getRecords())
System.debug(account.Name + ', Phone: ' + account.Phone);
Note: You can enumerate the List View's names and Id's to present a choice to the user or find one you've packaged via getListViewOptions().
Hope this helps, give you some food for thought!
It isn't possible to pass parameters to a controller method binding in a Visualforce page. From Controller Methods:
Visualforce markup can use the following types of controller extension and custom controller methods:
You could rework typeToRelationships
so that the keys already contain concatenated relationshipType and contact.Id.
Alternatively, you could put the apex:dataList into an apex:component. The component can have multiple apex:attributes defined. This will allow you to pass multiple parameters in.
One small personal crusade. The following is perfectly valid. However, it does contain a large amount of redundancy.
rendered="{!IF(sortedByType==true, true, false)}"
Instead, consider:
rendered="{!sortedByType}"
There is no need to compare a boolean to another boolean or wrap it in an IF statement.
Best Answer
(1) While it is technically possible to do this, the problem is that unlike reports, you can't execute a list view with updated filter criteria without saving it first. Thus your updated filter criteria is picked up by anyone who accesses the list view after you. Worse, if there are a number of links/buttons etc that rewrite the criteria, you can get into the situation where users see different results every time they access a list view. I'd advise against this to be honest, and go for a reports based solution.
(2) No, as the enhanced list can't take nested
<apex:param/>
components.