2

I was planning to create an extensible component with pre-defined layout to let the abstract component as a template. So my extended component can focus on the content.

But I'm keep getting the error:

Access Check Failed! AttributeSet.get(): attribute 'currentUserName' of component 'markup://ui:outputText {1036:0}' is not visible to 'markup://aura:expression {1014:0}'.

myAbstractCmp.cmp:

<aura:component abstract="true" extensible="true" >
<aura:attribute name="currentUserName" type="String" access="global"/>
<aura:attribute name="customMarkups"   type="Aura.Component"  access="global" description=""/>

<div class="custom-container">
    <ui:outputText value="This is the content of abstract component."/>
    {!v.customMarkups}
</div>

{!v.body}

extendedCmp.cmp

<aura:component extends="c:myAbstractCmp" implements="flexipage:availableForAllPageTypes" >

<aura:attribute name="currentUserName" type="String" access="global" default="Test User"/>

<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>

<aura:set attribute="customMarkups">
    <ui:outputText value="{!'Child attribute set to the parent component: '+v.currentUserName}"/>
</aura:set>

<ui:outputText value="{!'Child attribute used in the child component: '+v.currentUserName}"/>

</aura:component>

extendedCmpController.js

({
    doInit : function(component, event, helper) {
        component.set("v.currentUserName", "Karen Stone");
    }
})

Checked the document and the other similar questions, but still not understand what's wrong in my code.

UPDATE: Why the "currentUserName" attribute I want to set to the Parent Component as the content of its layout is not visible. Why check the attribute on ui:outputText component rather than my extended component?

Tried to update the API version in the Bundle Version Setting to the latest: 43.0. And the UI error dialog only shows up when I enabled the Lightning Component Debug Mode.

Or if there have any other way for layout template for a component not for Lightning Page?

3
  • Your code works for me, try upgrading the component's API version to latest?
    – Raul
    Sep 30, 2018 at 11:44
  • Hi @Raul. I checked the API version, all set to 43.0. But it still exists. I expect that the Aura.Component[] attribute from the Parent Component can be set as the markups I want in the Child Component, like the "customMarkups", to make the parent component works as a layout template.
    – lee jimmy
    Oct 8, 2018 at 2:43
  • Hi Rual. I solved this by changing the type of attribute "customMarkups" in the abstract component. From Aura.Component to Aura.Component[]. Seems like the type should be an Array if I want to use it to hold a bunch of markups. So I guess the error says not visible is because the type not match. Thank you again.
    – lee jimmy
    Oct 8, 2018 at 3:19

1 Answer 1

1

I solve the issue by changing the type of the attribute from the abstract component that I want to hold the content Markups set by the child component. to The correct type should be an Array of Aura.Component rather than a single one. Hope this can help someone. For example: <aura:attribute name="customMarkups" type="Aura.Component" access="GLOBAL" description="Content Markups"/> to <aura:attribute name="customMarkups" type="Aura.Component[]" access="GLOBAL" description="Content Markups"/>

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .