• Radhashree Yarashi
  • NEWBIE
  • 5 Points
  • Member since 2015
  • system engineer
  • Infosys Limited


  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 1
    Likes Given
  • 0
    Questions
  • 1
    Replies
Hello All,

I have just tried my first lightning page, the page contains two text fields and one button. Once click on button account record should be create. After click on preview i can able to see the form but when i entered the data in the text box i am getting below error. Could you please help me on this.

User-added image

Please find the lightning code below:
 
<aura:component >
    <aura:attribute name="NewAccount" type="Account"/>
	<lightning:input label="AccountName" name="myname" required="true" value="{!v.NewAccount.Name}" />
    <lightning:input label="Fax" name="fax" required="true" value="{!v.NewAccount.fax}"/>
    <lightning:button variant="brand" label="Submit" onclick="{!c.createAccount}"/> 
</aura:component>


({
	myAction : function(component, event) {
	var newAcc = component.get("v.NewAccount");
    var action = component.get("c.createAccount");
    action.setParams({ 
        "acc": newAcc
    });	
      action.setCallback(this, function(a) {
           var state = a.getState();
            if (state === "SUCCESS") {
                var name = a.getReturnValue();
               alert("hello from here"+name);
            }
        });
    $A.enqueueAction(action)   
        
	}
})

Advance thanks,
VSK98​
  • February 27, 2018
  • Like
  • 0
Hi,

I'm trying to show or hide a PageBlock on click of a commandbutton.

here is what i'm trying to do:

Button Code:
Code:
<apex:commandButton action="{!processSelected}" value="Process Selected" reRender="pageBlock, pageBlockProcessed" status="AjaxStatus"></apex:commandButton>

 
My Page Code:
Code:
<apex:pageBlock title="Selected Records" id="pageBlockProcessed">
    <apex:pageMessages ></apex:pageMessages>
    <apex:pageBlockTable value="{!selectedContacts}" var="l" rendered="{!NOT(ISNULL(selectedContacts))}">
        <apex:column value="{!l.Name}"></apex:column>
        <apex:column value="{!l.Email}"></apex:column>
        <apex:column value="{!l.Phone}"></apex:column>
    </apex:pageBlockTable>
</apex:pageBlock>

 "selectedContacts" is populated with Selected Contacts on CommandButton click. But the Page Block (pageBlockProcessed) does not show or hide when i populate and hide data in "selectedContacts" :(.


My Full page layout is something like this:
Code:
<apex:page controller="Contacts">
<apex:sectionHeader title="Contact List"></apex:sectionHeader>
<apex:form >
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlock title="" id="pageBlockFilter">
... Some VF Code ...
<apex:commandButton action="{!processSelected}" value="Process Selected" reRender="pageBlock, pageBlockProcessed" status="AjaxStatus"></apex:commandButton>
</apex:pageBlock>
<br/>
<div style="width:100%;display:{!IF(ISNULL(selectedContacts),'block','none')}">
<apex:pageBlock title="Selected Records" id="pageBlockProcessed">
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockTable value="{!selectedContacts}" var="l" rendered="{!NOT(ISNULL(selectedContacts))}">
<apex:column value="{!l.Name}"></apex:column>
<apex:column value="{!l.Email}"></apex:column>
<apex:column value="{!l.Phone}"></apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</div>
<apex:pageBlock title="" id="pageBlock">
<apex:pageBlockTable value="{!contacts}" var="c" rendered="{!NOT(ISNULL(contacts))}" rows="{!pageSize}">
... Some VF Code ...
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

 
The code in RED above needs to Be Shown and Hidden on click of "Process Selected" button.

CAN ANYONE help me here ? ... plz ...

At this point the page BLOCK is displaying At All times, selectedContacts is able to only hide the pageBlockTable, as and when there is data in the list. But i want FULL page block to Show and Hide with presence of data in selectedContacts.

- Varun
  • November 21, 2008
  • Like
  • 1