1

a FIELD_INTEGRITY_EXCEPTION is raised when i try to save my lightning component. I found the cause but not the solution.

In the following code, look at the aura:handler:

.cmp

<div id="list" class="row">
    <div class="container">
        <!--<div class="inner">-->
            <aura:iteration items="{!v.products}" var="prod">
                <aura:handler name="init" action="{!c.doAction}" value="{!this}"/>
                <div class="info">
                    <p>Nom: <ui:outputText value="{!prod.Name}"/></p>
                    <p>Liké par: <ui:outputText value="{!prod.wishedBy__c}"/></p>
                    <p>Prix: <ui:outputCurrency value="{!prod.Prix__c}"/></p>
                </div>
                <div id="side"></div>
            </aura:iteration>
         <!--</div>-->
    </div>
</div>

the aura:handler do this error. When i place it outside the div class="row", before or after, it works. console.log from doAction are displayed in the console browser.

I need to call this method into the iteration to get value from my table.

The full error message :

FIELD_INTEGRITY_EXCEPTION

Failed to save undefined:markup://c:pageGraph:19,87: Invalid attribute "name": Source

the code next to the error and the apex class works fine, contents like <p>Nom: <ui:outputText value="{!prod.Name}"/></p> and the others are displayed when i remove aura:handler from the div

How to fix it ?

  • Not sure what you are trying to achieve but indeed declare you're handlers outside any html elements/ other components. The init handler is calling your action when you're component is first initialized. Typically you want to perform some actions that set an initial state of your component. You might need to use soemthing else for what you are trying to do. Can you give an explanation of what you want to achieve? – Lieven Juwet Dec 8 '16 at 10:48
  • You can call methods yes, what you are trying here is to register a new handler. Handlers will handle specific events inside the component. If you want to call a controller method you need to wire it to a html/lightning event. For example an onclick event. – Lieven Juwet Dec 8 '16 at 10:54
  • 'products' contain values from my table. I try to make something like bar chart with those values. In my mind, i iterate on v.product, send values to doAction, getElemById on 'div class="side" to set a width define by values in 'products' – Tellimi Dec 8 '16 at 11:02
  • In that case I think you will need to create a separate component for the bar. I'll try to provide you a small example as an answer. – Lieven Juwet Dec 8 '16 at 11:06
0

For what you are trying to achieve you will likely need another component to represent your bar. Pass the product you are looping over in the iteration to the new component.

<div id="list" class="row">
    <div class="container">
        <!--<div class="inner">-->
            <aura:iteration items="{!v.products}" var="prod">
                <aura:handler name="init" action="{!c.doAction}" value="{!this}"/>
                <div class="info">
                    <p>Nom: <ui:outputText value="{!prod.Name}"/></p>
                    <p>Liké par: <ui:outputText value="{!prod.wishedBy__c}"/></p>
                    <p>Prix: <ui:outputCurrency value="{!prod.Prix__c}"/></p>
                </div>

                <c:BarComponent product={!prod} />
            </aura:iteration>
         <!--</div>-->
    </div>
</div>

Your bar component can then look something like this:

<aura:handler name="init" value="{!this}" action="{!c.doAction}"/>
<aura:attribute name="product" type="Object"/>

<div class="side"></div>

Write your doAction logic in your new component to deside the width of your div. So what you are doing is create a new component for each product in your iteration and perform some JS logic upon init of that component.

Hope this example helps you on you're way.

  • I now encounter another problem in my javascript but you solved this issue ! Thanks a lot ! – Tellimi Dec 8 '16 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.