function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Daniel Glaser 12Daniel Glaser 12 

TrailHead -Error The 'PhoneNumberEvent' event is not of type 'APPLICATION'.

I am doing the Handling Events with Client-Side controllers for the Lightning components study. I created the following:
the javascript modules : PhoneNumberInput and PhoneNumberOutput
The phone number input file contains
<aura:component >
    <aura:registerEvent name="PhoneNumEvent" type="c:PhoneNumEvent"/>
    <ui:inputPhone aura:id="phone" label="phone" />
    <ui:button label="Show Phone" press="{!c.postphone}" />
</aura:component>

The event fle PhoneNumberEvent.evt  - I believe that this is the file name I was supposed to use.
and the application file PhoneNumber.app  - Not sure what file name to use.
 
Everything runs fine, the problem is when I check the results I get the error:
Challenge not yet complete... here's what's wrong:
The 'PhoneNumberEvent' event is not of type 'APPLICATION'.


 
Daniel Glaser 12Daniel Glaser 12
I put the wrong code above. I was messing around with file names the PhoneNumberInput  file contains
<aura:registerEvent name="PhoneNumberEvent" type="c:PhoneNumberEvent"/>
NOT
<aura:registerEvent name="PhoneNumEvent" type="c:PhoneNumEvent"/>
 
Sakthivel ThandavarayanSakthivel Thandavarayan
Daniel,

Are you able to complete the challenge ? 
Daniel Glaser 12Daniel Glaser 12
I was not able to complete the challenge. I have tried several different changes but none worked. My code performs perfectly.
I recreated the code as follows:
The new event file is named PhoneNumEvent.evt

PhoneNumberInputController.js
-------------------------------------------
postphone : function(component, event, helper) {
        var PhoneNumEvent = component.getEvent("PhoneNumEvent");
        var phone = component.find("phone").get("v.value");
        
        PhoneNumEvent.setParams({
            "phone": phone
        });
        PhoneNumEvent.fire();
    }

---------------------------------------
PhoneNumberInput.cmp
---------------------------------------
   <aura:registerEvent name="PhoneNumEvent" type="c:PhoneNumEvent"/>
    
    <ui:inputPhone aura:id="phone" label="phone" />
    <ui:button label="Show Phone" press="{!c.postphone}" />

--------------------------------------
PhoneNumberOutput.cmp
---------------------------------------
<aura:component >
    <aura:attribute name="number" type="String" default="No Phone Number"/>
    <c:PhoneNumberInput PhoneNumEvent="{!c.phonenum}"/>
    <ui:outputText aura:id="phone" value="{!v.number}"/>
</aura:component>

----------------------------------------------------
PhoneNumberOutputController.js
----------------------------------------------------
({
    phonenum : function(component, event, helper) {
        
        var phone = event.getParam("phone");
        component.set("v.number", phone);
    }

})

This is all being started by an app:
PhoneNumber.app
--------------------------------------
<aura:application >
    <c:PhoneNumberOutput />
</aura:application>


and Now I am getting this error:
The 'PhoneNumberOutput' component is not using a handler component

 
Sakthivel ThandavarayanSakthivel Thandavarayan
Daniel,

From the error you can conclude that event handler not added to the output component "PhoneNumberOutput.cmp"

Add the <aura:handler> tag to PhoneNumberOutput component and try again. 
Daniel Glaser 5Daniel Glaser 5
Thank you, that was an oversight on my part. That was the answer to the problem. All works now.
Ghanshyam Yadav01Ghanshyam Yadav01
Hey Daniel,getting the error when m saving PhoneNumberInputController.js

error
Failed to save undefined: : org.auraframework.util.json.JsonStreamReader$JsonStreamParseException: Invalid literal value [1, 1]: 'postphone': Source
Nilesh DetheNilesh Dethe
Hey Ghanshyam, 
I am also getting the same error while trying to implement the Trailhead sample code from the module "Using Standard and Force.com Components".

Here is the Component code -
<aura:component>
<ui:inputText label="Name" aura:id="name" placeholder="First, Last"/>
<ui:outputText aura:id="nameOutput" value=" "/>
<ui:button aura:id="outputButton" label="Submit" press="{!c.getInput}"/>
</aura:component>
and Component Client Controller code -
getInput : function(component, event) {
      var objName = component.find("name");
      var fullName = obj.get("v.value");
      var outName = component.find("nameOutput");
      outName.set("v.value", fullName);
    }

Here is the error: 
ERROR: : org.auraframework.util.json.JsonStreamReader$JsonStreamParseException: Invalid literal value [1, 1]: 'getInput': Source

Did you get any solution for your error?

Thanks,
Nilesh Dethe
Jarosław ŁanieckiJarosław Łaniecki
HI try this:
https://developer.salesforce.com/forums/?id=906F0000000BH44IAG
Jarosław ŁanieckiJarosław Łaniecki
@ [Nilesh Dethe] Nilesh Dethe
 
getInput : function(component, event, helper) {
      var objName = component.find("name");
      var fullName = objName.get("v.value");
      var outName = component.find("nameOutput");
      outName.set("v.value", fullName);
    }