You need to sign in to do that
Don't have an account?
Jassi Johal 7
Lightning Component Framework Specialist superbadge step 2
can anyone help me solving the Second step for Lightning Component Framework Specialist super badge.. I struck in that badge.
Which error are you getting can you post here?
Regards,
Amit
We couldn't find the BoatSearch component. Make sure you've created the component and that it's named correctly.
this is code for BoatSearchForm
controller
I am unable to find the issue in by code to crack the step2. My code is working abslutly fine without any error but when i submit the challenge it keep on showing error message as '
Challenge Not yet complete... here's what's wrong:
The Friends with Boats Lightning app should have a similar look and feel to the Lightning app page. Make sure it uses lightning:layout and that Lightning Design System styles are available to components in the app.'
Here is my code so far:
FriendswithBoats.app
<aura:application extends="force:slds" >
<lightning:layout >
<div class="slds-grid slds-gutters">
<div class="slds-col slds-size_2-of-3">
<c.BoatSearch/>
</div>
<div class="slds-col slds-size_1-of-3">
<span>2</span>
</div>
</div>
</lightning:layout>
</aura:application>
I am getting error "Failed to save BoatSearchForm.cmp: Invalid definition for null:BoatSearchForm: null: Source" for BoatSearchForm.comp
Any help?
Please see code below
<aura:component controller="BoatSearchForm" implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="searchOptions" type='String[]' default='All'/>
<aura:attribute name='searchOptionToIdMap' type='Map' default="{All:''}" />
<aura:attribute name='showNewButton' type='Boolean' default='false'/>
<lightning:layout horizontalAlign="center" >
<lightning:layoutItem class="slds-grid_vertical-align-center" >
<lightning:select aura:id='typeSelect' label='Please select' name='selectItem' >
<aura:iteration items='{!v.searchOptions}' var='option'>
<option value='{!option}' text='{!option}'></option>
</aura:iteration>
</lightning:select>
</lightning:layoutItem>
<lightning:layoutItem class="slds-grid_vertical-align-center" >
<lightning:button label="Search" variant="brand" onclick='{!c.onFormSubmit}' />
<aura:if isTrue='{!v.showNewButton}'>
<lightning:button variant='neutral' label='New' onclick='{!c.createBoat}'/>
</aura:if>
</lightning:layoutItem>
</lightning:layout>
</aura:component>
Hi
I am stuck at Step 2. Getting following error :-
Following are my components :-
BoatSearchForm.cmp
<aura:component description="BoatSearchForm"
controller="BoatSearchFormController"
implements="flexipage:availableForAllPageTypes">
<aura:registerEvent name="launchNewBoatForm" type="c:launchNewBoatForm"/>
<!-- Handle component init in a client-side controller -->
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:handler name="launchNewBoatForm" event="c:launchNewBoatForm" action="{!c.handleNewBoatForm}"/>
<!-- dynamically load the BoatTypes -->
<aura:attribute name="BoatTypes" type="BoatType__c[]" />
<aura:attribute name="selectedType" type="String" default="foo"/>
<aura:attribute name="renderNew" type="Boolean" default="true"/>
<article class="slds-card slds-m-bottom_large">
<div class="slds-media__body">
<div >
<lightning:layout horizontalAlign="center" verticalAlign="center">
<lightning:layoutItem padding="horizontal-medium" >
<lightning:select aura:id="boatTypes" label="Please select" name="selectType"
onchange="{!c.handleChange}">
<option value="">All Types</option>
<aura:iteration items="{!v.BoatTypes}" var="boatType">
<option value="{!boatType.Id}" text="{!boatType.Name}"/>
</aura:iteration>
</lightning:select>
</lightning:layoutItem>
<lightning:layoutItem >
<div class="slds-button-group" role="group">
<lightning:button class="slds-button" variant="brand" label="Search" onclick="{!c.search}"/>
<aura:if isTrue="{!v.renderNew}">
<lightning:button class="slds-button" variant="neutral" label="New" onclick="{!c.newBoat}"/>
</aura:if>
</div>
</lightning:layoutItem>
</lightning:layout>
</div>
</div>
</article>
</aura:component>
BoatSearchFormController.js
({
doInit : function(component, event, helper){
helper.loadBoatTypes(component);
var createNewBoat = $A.get("e.force:createRecord");
if (createNewBoat) {
component.set("v.renderNew", true);
}else{
component.set("v.renderNew", false);
}
},
handleChange : function(component, event, helper){
console.log(component.find("boatTypes").get("v.value"));
component.set("v.selectedType", component.find("boatTypes").get("v.value"));
},
search : function(component, event, helper){
var selectedType = component.get("v.selectedType");
console.log("Search button pressed " + selectedType);
},
newBoat : function(component, event, helper){
var boatTypeId = component.get("v.selectedType");
console.log("New button pressed " + boatTypeId);
var requestNewBoat = component.getEvent("launchNewBoatForm");
if(requestNewBoat){
requestNewBoat.setParams({"boatTypeId": boatTypeId});
requestNewBoat.fire();
}else{
console.log("Action not supported");
}
},
handleNewBoatForm: function(component, event, helper){
console.log("handleNewBoatForm handler called.")
var boatTypeId = component.get("v.selectedType");
console.log(boatTypeId);
var createNewBoat = $A.get("e.force:createRecord");
if (createNewBoat) {
createNewBoat.setParams({"entityApiName": "Boat__c"});
if(! boatTypeId==""){
createNewBoat.setParams({"defaultFieldValues": {'BoatType__c': boatTypeId}})
};
createNewBoat.fire();
}else{
console.log("Action not supported");
}
},
//more handlers here
})
BoatSearchResults.cmp
<aura:component >
<article class="slds-card slds-m-bottom_large">
<div class="slds-media__body">
<div >
<lightning:layout horizontalAlign="center" verticalAlign="center">
<lightning:layoutItem padding="horizontal-medium" >
Test test
</lightning:layoutItem>
</lightning:layout>
</div>
</div>
</article>
</aura:component>
BoatSearch.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<lightning:card title="Find a Boat" class="slds-m-top_10px">
<c.BoatSearchForm/>
</lightning:card>
<lightning:card title="Matching Boats">
<c.BoatSearchResults/>
</lightning:card>
</aura:component>
FriendswithBoat.app
<aura:application extends="force:slds" >
<lightning:layout >
<div class="slds-grid slds-gutters">
<div class="slds-col slds-size_2-of-3">
<c.BoatSearch/>
</div>
<div class="slds-col slds-size_1-of-3">
<span></span>
</div>
</div>
</lightning:layout>
</aura:application>
BoatSearchFormController.apxc
public with sharing class BoatSearchFormController
{
@AuraEnabled
public static List<BoatType__c> getBoatTypes()
{
return [SELECT Id, Name from BoatType__c ORDER BY Name];
}
}
I am getting the same error. Were you able to get the fix of it?
Thanks,
Manish
You are getting this error message because of just one small mistake that you have made while instantiating components i.e you have used dot instead of the colon at 3 places. So just replace your code with below code and it will work:-
BoatSearch.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
<lightning:card title="Find a Boat" class="slds-m-top_10px">
<c:BoatSearchForm/>
</lightning:card>
<lightning:card title="Matching Boats">
<c:BoatSearchResults/>
</lightning:card>
</aura:component>
FriendswithBoat.app
<aura:application extends="force:slds" >
<lightning:layout >
<div class="slds-grid slds-gutters">
<div class="slds-col slds-size_2-of-3">
<c:BoatSearch/>
</div>
<div class="slds-col slds-size_1-of-3">
<span></span>
</div>
</div>
</lightning:layout>
</aura:application>
Thanks!
Sanchit Mittal
(Salesforce Developer at Paytm)
<aura:application extends="force:slds">
<lightning:layout>
<c:BoatSearch />
</lightning:layout>
</aura:application>
1. From Setup, enter App Builder in the Quick Find box, then select Lightning App Builder
2. Click New
3. Select App Page and start stepping through the wizard
4. Name your page
5. Select Main Region and Right Sidebar Layout
6. Put the BoatSearch component in the main region
7. Activate the page as a new tab in Lightning Experience and the Salesforce App
Check the challenge again and it will works.
BoatSerachFormController.js
<aura:component controller="BoatSearchFormController">
<aura:attribute name="BoatTypes" type="BoatType__c[]" />
<aura:attribute name="selectedType" type="String"/>
<aura:attribute name="renderNew" type="Boolean"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<article class="slds-card slds-m-bottom_large">
<div class="slds-media__body">
<div>
<lightning:layout horizontalAlign="center" verticalAlign="end">
<lightning:layoutItem padding="horizontal-small" >
<lightning:select aura:id="boatTypes" label="" name="selectType" onchange="{!c.handleChange}">
<option value="">All Types</option>
<aura:iteration items="{!v.BoatTypes}" var="boatType">
<option value="{!boatType.Id}" text="{!boatType.Name}"/>
</aura:iteration>
</lightning:select>
</lightning:layoutItem>
<lightning:layoutItem padding="horizontal-small">
<div class="slds-button-group" role="group">
<lightning:button class="slds-button" variant="brand" label="Search" onclick="{!c.onFormSubmit}"/>
<aura:if isTrue="{!v.renderNew}">
<lightning:button class="slds-button" variant="neutral" label="New" onclick="{!c.newBoat}"/>
</aura:if>
</div>
</lightning:layoutItem>
</lightning:layout>
</div>
</div>
</article>
</aura:component>
.........................................................................................................................................
BoatSearchFormHelper.js
({
LoadBoatTypes : function(component,event) {
var action=component.get("c.getBoatType");
action.setCallback(this,function(response) {
var state= response.getState();
if(state==='SUCCESS'){
component.set("v.BoatTypes",response.getReturnValue());
}
else {
console.log("Failed with state: " + state);
}
});
$A.enqueueAction(action);
},
})
......................................................................................................................................
BoatSearch.cmp
<aura:component implements="flexipage:availableForAllPageTypes,force:appHostable">
<lightning:card title="Find a Boat" class="slds-m-bottom_10px">
<c:BoatSearchForm aura:id="BoatSearchForm"/>
</lightning:card>
<lightning:card title="Matching Boats">
<c:BoatSearchResults aura:id="BoatSearchResults"/>
</lightning:card>
</aura:component>
................................................................................................................................
BoatSerach.css
.THIS.FindBoat {
margin-bottom:10px
}
......................................................................................................................
BoatSearchResults.cmp
<aura:component >
<article class="slds-card slds-m-bottom_large">
<div class="slds-media__body">
<div >
<lightning:layout horizontalAlign="center" verticalAlign="center">
<lightning:layoutItem padding="horizontal-medium" >
Test test
</lightning:layoutItem>
</lightning:layout>
</div>
</div>
</article>
</aura:component>
................................................................................................................
BoatSearchForm.cmp
<aura:component controller="BoatSearchFormController">
<aura:attribute name="BoatTypes" type="BoatType__c[]" />
<aura:attribute name="selectedType" type="String"/>
<aura:attribute name="renderNew" type="Boolean"/>
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<article class="slds-card slds-m-bottom_large">
<div class="slds-media__body">
<div>
<lightning:layout horizontalAlign="center" verticalAlign="end">
<lightning:layoutItem padding="horizontal-small" >
<lightning:select aura:id="boatTypes" label="" name="selectType" onchange="{!c.handleChange}">
<option value="">All Types</option>
<aura:iteration items="{!v.BoatTypes}" var="boatType">
<option value="{!boatType.Id}" text="{!boatType.Name}"/>
</aura:iteration>
</lightning:select>
</lightning:layoutItem>
<lightning:layoutItem padding="horizontal-small">
<div class="slds-button-group" role="group">
<lightning:button class="slds-button" variant="brand" label="Search" onclick="{!c.onFormSubmit}"/>
<aura:if isTrue="{!v.renderNew}">
<lightning:button class="slds-button" variant="neutral" label="New" onclick="{!c.newBoat}"/>
</aura:if>
</div>
</lightning:layoutItem>
</lightning:layout>
</div>
</div>
</article>
</aura:component>
.........................................................................................................................
BoatSearchFormController.apxc
public class BoatSearchFormController {
@AuraEnabled
public static list<BoatType__c> getBoatTypes(){
return [SELECT Id, Name from BoatType__c];
}
}
............................................................................
FriendswithBoats.app
<aura:application extends="force:slds">
<lightning:layout class="slds-grid slds-wrap">
<lightning:layoutItem flexibility="auto" class="slds-col slds-size_2-of-3">
</lightning:layoutItem>
<lightning:layoutItem flexibility="auto" class="slds-col slds-size_1-of-3">
</lightning:layoutItem>
</lightning:layout>
</aura:application>