2

I am trying to filter the result of a Wrapper class. For example, I have a list that populates a table with 3 rows but I would like to display the same table filtered based on Name which it should only display 1 row. I can't display these value in the page. I will appreciate any help!

Error: Unknown property 'String.Name' in Visualforce page while saving

Controller:

 filterResult = new List<String>(); 
  for(MyWrapper s : wrappedObjects){                                            
    if(s.Cont.Name == 'Cart-1')
     {
       filterResult.add(String.valueof(s));
       System.debug(filterResult);                            
     }                                               
  } 

System.debug:

 USER_DEBUG [185]|DEBUG|(Container__c:{Id=a1Rf0000000n20eEAA, Name=cart1 - A1})

Page:

 <apex:repeat value="{!filterResult}" var="c" > 
     Container Id:       
     <apex:outputText value="{!c.Id}" /> 
     Container:       
     <apex:outputText value="{!c.Name}" />        
  </apex:repeat>
2

Instead of having filterResult as List<String> you can have it as List<MyWrapper>.

filterResult = new List<MyWrapper>();
for(MyWrapper s : wrappedObjects){                      
    if(s.Cont.Name == 'Cart-1')
    {
        filterResult.add(s);
        System.debug(filterResult);
    }                                               
}

Hope it helps.

  • Vigneshwaran G, thank you so much! that made it :) have a great weekend! – Carlos Sep 4 '15 at 18:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.