7
votes
Does Wrapper Class serve one purpose only?
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 ...
7
votes
How to set inner class list as aura attribute?
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 ...
7
votes
Accepted
LWC JavaScript way to copy List [List A, List B] Values to a single List
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 ...
6
votes
Accepted
Sorting of two different records referencing their dates
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 ...
6
votes
Accepted
Adding a Wrapper Class to an External Class
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 ...
6
votes
Accepted
Issue with passing class data from apex to javascript in LWC
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 ...
6
votes
Accepted
Access the List<String> in wrapper class to LWC
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]....
5
votes
Accepted
How to send List<Wrapper class> from Lightning component to Apex Controller?
Fixed using this approach.
In Java script Callback,
var actSave = component.get("c.saveDataDML");
actSave.setParams({
"listToSaveString": JSON.stringify(itemList)
});
...
5
votes
Accepted
Invalid conversion from runtime type Boolean to List<>
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 ...
5
votes
Accepted
Render Two Lists From Dynamic SOSL?
You need separate tables for each list. Something along the lines of:
<apex:pageBlockTable value="{!mySearchWrapper.accounts}" var="account">
<!-- columns -->
</apex:pageBlockTable&...
5
votes
Accepted
Wrapper Class in a Map
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. ...
5
votes
Does Wrapper Class serve one purpose only?
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 ...
5
votes
Accepted
Not able to cover wrapper class in test class
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....
5
votes
SOQL Query Limits in Wrapper Class (using dlrs)
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){
...
5
votes
Accepted
CompareTo - Sort order by date in Wrapper class
Based on your updates, simply compare calculatedDate between the passed in value (which you named other) and the instance calling the method. I find the following pattern readable and easy to ...
5
votes
Adding a Wrapper Class to an External Class
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> ...
5
votes
Accepted
Custom Inline Editable Table in LWC
The detail parameter can contain complex data:
this.dispatchEvent(
new CustomEvent(
'update',
{ detail:
{
fieldName: this.fieldName,
value: this.value
}
}...
5
votes
Accepted
How to serialize a string into a Blob value without backslashes?
In the given scenario, serialization occurs twice in the last three lines, and it is a cause of an observed scenario.
A better way to approach this could be using of Map<String, Object> instead ...
5
votes
Accepted
Getting error : Nested object for polymorphic foreign key must have an attributes field before any other fields
The deserialization needs to know what concrete type to use and that is signalled by an attributes field:
"records":[{"attributes": {"type": "fund__c"}, "...
4
votes
Accepted
issue with wrapper variable
You have a public String property named w declared in the apex class which is not used in the class but conflicting with the apex:repeat loop variable which is also named w.
So either change the ...
4
votes
How can I have 100% code coverage in wrapper class + meaningful testing
Before working too hard on the tests take a second look at this code and improve it. Weak code with 100% test coverage is still weak code.
List <Account> acc = new List <Account>();
List &...
4
votes
Accepted
Invalid type for my controller
On line 192 in your class you are incorrectly referencing your custom object.
for (Business_Card_Request_Price_c i : tempList) {
tmpWrp.add(new BCRWrapper(i));
}
For custom objects, the API must ...
4
votes
Accepted
Invalid Type for Comparable Implementation
CaseInfo is in the viewAllCaseCommentsActivitiesController class, so you need to use the fully-qualified name:
List<viewAllCaseCommentsActivitiesController.CaseInfo> caseList = new List<...
4
votes
Accepted
Adding to sub list/array within apex wrapper class
You can create new instance of LineItem first like below since LineItem is a child class of Invoice so you have to use Invoice.LineItem to initialize the class
Invoice.LineItem lineItem1 = new ...
4
votes
Accepted
Where/How can I store a variable and access while I build my wrapper? It's either null in wrapper itself or the scope isn't visible at top level
However it's as if this is re-created everytime I add to my wrapOppList.
That's exactly what's happening.
When you create a wrapper, you also create instance variables for all the variables you ...
4
votes
Accepted
Wrapper class in Http getmethod
Global methods must return global data types. You need to declare your class as global in order to use it as a return value.
As a side note, there's no point to your try-catch block here, because ...
4
votes
SOQL Query Limits in Wrapper Class (using dlrs)
This is a good pattern to use as the query is executed once only and then the results are iterated over:
for (OrderItem o: [select ... from ... where ...]) {
...
}
This query inside a loop is ...
4
votes
Accepted
How can I dynamically add input fields in visual force on a button click?
This is a very common requirement. First add a Add row button with ypur table
<apex:commandButton value="Add More" action="{!addNewRow}" rerender="frm" Status="status" immediate="true" />
and ...
4
votes
Accepted
Error: Invalid Type
ApplicationList is an inner class of JSONWrapper. References to that class outside of the JSONWrapper class itself, where it's in scope, must qualify the name with its outer class: JSONWrapper....
4
votes
Accepted
Can't find wrapper class definition
WrapperJobs is not a standard object. Its location can only be divined by inspection of your codebase.
The easiest way to do this will be to use Visual Studio Code or another IDE to retrieve all Apex ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
wrapper-class × 472apex × 303
visualforce × 157
lightning-web-components × 43
json × 42
lightning-aura-components × 29
unit-test × 29
class × 29
controller × 21
soql × 18
map × 18
list × 17
lightning × 16
javascript × 16
rest-api × 14
code-coverage × 14
lightning-datatable × 13
pageblocktable × 13
comparable × 11
sort × 9
deserialize × 8
inputcheckboxes × 8
trigger × 7
repeat × 7
inner-class × 7