• utkarsh singh 53
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 3
    Questions
  • 0
    Replies
I have an input form in a child vf component whose fields are rendered from a field set.  
This child component is being called from a parent component where I want to validate on the parent controller whether the the required fields in child component's field set is filled or not before saving it.
So to do this I will need to access child component's data from a parent vf component's controller. But I am not sure how to access it.
BoatReiews component's doInit is not getting invoked. I have attached the screenshot of the error which I get when the component is called after submiting a review.

User-added image

Below is the code for BoatReview.cmp
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global"   controller="BoatReviews">
    <aura:handler name="doInit" value="{!this}" action="{!c.doInit}"/>
    <aura:attribute name="boat" type="Boat__c"/>
    <aura:attribute name="Id" type="Id" />
    <aura:attribute name="boatReviews" type="BoatReview__c[]" access="private"/>
    <ui:scrollerWrapper>
        <aura:if isTrue="{!v.boatReviews.length==0}">  
            <lightning:layoutItem class="slds-align_absolute-center" flexibility="auto" padding="around-small">   
                <ui:outputText value="No Reviews Available" />
            </lightning:layoutItem>
        </aura:if>
        <aura:if isTrue="{!v.boatReviews.length!=0}">
                    <div class="slds-feed">
            <ul class="slds-feed__list">
                <aura:iteration items="{!v.boatReviews}" var="boatReview">
                    <li class="slds-feed__item">
                        <div class="slds-media__body">
                       <div class="slds-grid slds-has-flexi-truncate">
                            <a href="javascript:void(0)" onclick="{!c.onUserInfoClick}"
          data-userid="{!boatReview.CreatedBy.Id}">
          {!boatReview.CreatedBy.Name}
      </a>
                        &nbsp; &mdash; &nbsp; {!boatReview.CreatedBy.CompanyName}
   </div>
                         <p><lightning:formattedDateTime value="{!boatReview.CreatedDate}" 
                                   year="numeric" month="short" day="numeric"  
                                   hour="2-digit" minute="2-digit" hour12="true"/></p>
                        </div>
                    </li>
                    <div class="slds-post__content slds-text-longform">
                        <p> {!boatReview.Name}</p>
                        <p>{!boatReview.Comment__c}</p>
                                </div>                           
                </aura:iteration>
            </ul>
        </div>
        </aura:if>
    </ui:scrollerWrapper>
</aura:component>

BoatReviewController.js
({
    doInit : function(component, event, helper) {
        //alert("BR controller init");
        component.set("v.Id",component.get("v.boat.Id"));
        console.log("BR controller init");
        helper.onInit(component,event,helper); 
    },
    onUserInfoClick : function(component, event, helper)
    {
        
    }
})
BoatReviewHelper.js
({
    onInit : function(component,event,helper)
    {
         console.log("BR helper init");

        var action =component.get("c.getAll");
        action.setParams(boatId, component.get("v.Id"));
               action.setCallback(this, function(response)
               {
                       var state = response.getState();
                    if(state="SUCCESS")
                       component.set("v.boatReview", response.getReturnValue());
               })
        $A.enqueueAction(action);
    }
})