14

Implement the Comparable interface: https://www.salesforce.com/us/developer/docs/apexcode/Content/apex_comparable.htm To do this you implement Comparable: public class QLWrap implements Comparable Then you need to implement a compareTo method: global Integer compareTo(Object compareTo) { //I don't know what criteria you want to sort on QLWrap ...


11

This works fine for me. Ran a couple tests and all of the below work. VF Page <apex:page controller="GenericTest"> {!test['name']} {!test1.obj['name']} <apex:repeat value="{!testList}" var="test2"> {!test2.obj['name']} </apex:repeat> <apex:pageBlock> <apex:pageBlockTable value="{!testList}" ...


7

The confusion is that your class is not really what is termed a wrapper in the Apex community as a wrapper usually decorates a single object instance not a collection. Best drop that suffix from your class. A wrapper that allows easy sorting (see Comparable) by the field you specify (assuming the field is never null) would look like this: public class ...


7

Looking at what Google has to say, Wrapper is an alternative name for both these patterns: Decorator Adapter So the examples that focus on adding a checkbox might be better labelled as Decorator classes not Wrapper classes to be more specific and so clearer. An example that say takes two different types of SObject and presents them in one table is acting ...


7

If I read this right, you want to use an inner class on aura:attribute tag. You cannot (rather should not) use an inner class as an aura attribute, instead you need to handle it differently. If that's what you are looking for, refer to the below excerpt from documentation: Custom classes used for component attributes shouldn’t be inner classes or use ...


7

Yes. You can use concat: var output = listA.concat(listB); Or you can flatten it: var output = [listA,listB].flat(); Arrays in JS are very robust. You should take time to study their many features on MDN.


6

The zero-argument constructor is the "default constructor", but you only get it "for free" if you don't include any other constructors. Once you do, the zero-argument constructor has to be explicitly defined in order to work. Extensions use the one-argument Apexpages.StandardController controller constructor, or the Apexpages.StandardSetController controller ...


6

You can create ContactWrapper class which contains standard Contact as a field and list of customers. apex: @RestResource(urlMapping='/Order/*') global with sharing class OrderWebServicesV2 { private class OrderWrapper { Account account; list<ContactWrapper> contacts; } private class ContactWrapper { Contact ...


6

It is possible to write a Comparable wrapper class that can work with various SObject types and fields: public class DateFieldComparable implements Comparable { private SObject sob; private SObjectField field; public DateFieldComparable(SObject sob, SObjectField field) { this.sob = sob; this.field = field; } public ...


6

Somewhere else in the local context, there is a variable declaration that's shadowing the class Models. Example: public class TestQ242685 { public class InnerClass { } public static void runTest() { List<InnerClass> SomeOtherClass = new List<InnerClass>(); SomeOtherClass.add(new InnerClass()); System.debug(...


6

The attributes in the custom class that you have created should have the AuraEnabled annotation set on them. Then those attributes will be accessible on the javascript side. public class MultiValueReturn { @AuraEnabled public Decimal val1; @AuraEnabled public String val2; }


6

Javascript is case SEnSiTivE. You have defined variable in apex as monthListBefore but in JS you are trying to access MonthListBefore, which does not exist. So, Try this.MonthList = data[0].monthListBefore;


5

All data transmitted with JavaScript Remoting is JSON. You need never encode nor decode it. Eg: public List<Contact> findContactsForAccount(Id accountId, String lastName) { return [ SELECT Id FROM Contact WHERE AccountId = :accountId AND LastName LIKE :('%' + filter + '%') ]; } What goes up the wire is an array of the ...


5

Instead of using List<SObject> you could use List<Object>. Then, in your SyncCodes method, you can use the instanceof operator to act accordingly, for example: for( Object obj : objs ) { if( obj instanceof SObject ) { // do one thing } else { // do another } }


5

Let me start by saying there probably is no true 'correct' way to solve this. I'm sure there are 10 ways that will get you the same result. This is just one of many possible ways to solve this problem. I used a wrapper class to hold each row of data you need. I constructed the column header data independently to try to make it a bit simpler. The key ...


5

The problem is that you try to create an instance of AddBasketGasQuoteFromMonitor with the line AddBasketGasQuoteFromMonitor controller = new AddBasketGasQuoteFromMonitor(); However, your class AddBasketGasQuoteFromMonitor only has a constructor that takes a ApexPages.StandardController as a parameter. So in your test, when you want to create an instance, ...


5

I see that the code where you find actual accounts is not returned in wrapper format public pagereference Search() { String finalSearchValue = '%' + fullname + '%'; Accounts = [Select Id, Name, Active__c FROM Account where Name like :finalSearchValue]; wraplist = new list<wrapData>(); for(...


5

You should create a 2 dimensional array or we can say List of List which looks like List<List<String>> twoDimArray and try to iterate it like: <apex:repeat value="{!twoDimArray}" var="dimension1"> <apex:pageBlockDataTable value="{!dimension1}" var="dimension2"> <apex:column value="{!dimension2}"/> <!-- etc --> ...


5

public class gAlertWrapper implements Comparable{ public Integer compareTo(Object compareTo) { gAlertWrapper gAlertWrapper = (gAlertWrapper) compareTo; if (gA.published__c == gAlertWrapper.gA.published__c) return 0; if (gA.published__c > gAlertWrapper.gA.published__c) return 1; return -1; } } Following is the correct syntax ...


5

In order for the VF page to access the wrapper class properties you need to define the getter and setters: public class wrapperContact { public Contact cont {get;set;} public Boolean selected {get;set;} } or use the defined getter methods: c.Contact.Name


5

You can declare a constant list of mappings to numbers based on these values, eg: public class Wrapper implements Comparable{ public const colorMap Map<String,Integer> = new Map<String,Integer> {'Green'=>0, 'Yellow'=> '1','Red'=> '2'} .... rest of your class Then in the comparable method, you use the map to get numeric values ...


5

Unless you're caching the result from the first request to the get; member on the controller every single time the VF page references the { get; member, it'll fire the query contained in the getter again. This can quickly hit a query limit. Better to either store the result or use a method of your own to do the work and store the result. My example does the ...


5

You need separate tables for each list. Something along the lines of: <apex:pageBlockTable value="{!mySearchWrapper.accounts}" var="account"> <!-- columns --> </apex:pageBlockTable> <apex:pageBlockTable value="{!mySearchWrapper.contacts}" var="contact"> <!-- columns --> </apex:pageBlockTable> If you really want ...


5

Your problem is this area here: <apex:inputCheckbox value="{!wrapList}" onchange="enableDisable(this);"/> (There's a few instances of this problem, so only one is illustrated here.) You're trying to bind the entire wrapList to a Boolean value. You probably meant to do something like this: <apex:inputCheckbox id="thermal" value="{!c.bcrObj....


5

Fixed using this approach. In Java script Callback, var actSave = component.get("c.saveDataDML"); actSave.setParams({ "listToSaveString": JSON.stringify(itemList) }); and in Apex Controller, Deserialized an casted as below. @AuraEnabled public static List<Wrapperclass> saveDataDML(String listToSaveString){ List<...


5

Use in the repeat caseInfo.CaseNumber Since caseInfo is akin to the loop variable in a for loop and each instance would be a wrapper record When using the repeats think of each one as a for loop. Maps are accessed using [keys] and values are accessed using dot notation. The var is the loop variable Working example: Controller public class ...


5

I believe not. Wrapper class is a custom table in my belief. Though checkbox is a great example of it. But above it, I have been using Wrapper Classes beyond it's scope. Suppose there is a Custom object you fetched using SOQL query, than you want to bind another field to it which is not statically stored in the DB but is dynamic in the code. As the ...


5

Question 1: Your creating child class with parent class instance.trying doing this, Create child class instance with parent class Name. Syntax: OuterClass.InnerClass innerObject = new OuterClass.InnerClass(); IITUpdateInvoice_EXT.wrapperItem wrap = new IITUpdateInvoice_EXT.wrapperItem(mile,check); Question 2 : In test Class call First ...


5

I guess you are confusing the standard practice with SOQL FOR Loop . SOQL For Loops are allowed, but standard practice is you do not write SOQL inside FOR loop. Like this: For(Contact c: contacts){ List<Account> accounts = [//SOME SOQL]; } This type of coding is prohibited in Salesforce. The simple reason is you can easily cross the governor ...


5

You seem to have a name shadowing here. This code is adding CheckItemClass objects in a List<CheckItemClass> which is most likely declared in your controller as: List<CheckItemClass> Models = new List<CheckItemClass>();` And from documentation: In particular it is legal for a variable, method, and a class within a class to have the ...


Only top voted, non community-wiki answers of a minimum length are eligible