0

I've spent countless hours trying to debug why the apex:message below is not showing on the page after the button is clicked. Any ideas what am I doing wrong?

Visualforce

<apex:form id="searchForm">
<apex:outputPanel id="notificationWrapper">
<apex:messages id="notificationPanel" styleClass="slds-notify slds-notify--alert slds-theme--error slds-theme--alert-texture"  />
</apex:outputPanel>
</apex:form>
--------------------------
<apex:actionRegion >
<apex:commandLink action="{!deleteDocument}" rendered="
{!IF(currentUserProfile == 'System Administrator',true,false)}" 
reRender="notificationWrapper" status="spinnerStatus">
</apex:actionRegion>

Apex

public PageReference deleteDocument() {
    ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Test'));
    return null; 
}

1 Answer 1

1

Without having your full code, it was difficult to make sure that I'm pinpointing your exact issue. That being said, the following code worked for me:

Page:

<apex:page controller="seController">
  <apex:form id="searchForm">
    <apex:outputPanel id="notificationWrapper">
      <apex:messages id="notificationPanel" styleClass="slds-notify slds-notify--alert slds-theme--error slds-theme--alert-texture"  />
    </apex:outputPanel>
    <apex:actionRegion >
      <apex:commandLink action="{!deleteDocument}" reRender="notificationWrapper" status="spinnerStatus" value="delete"/>
    </apex:actionRegion>
  </apex:form>
</apex:page>

Controller:

public class seController {
  public PageReference deleteDocument() {
    ApexPages.addmessage(new ApexPages.Message(ApexPages.Severity.INFO, 'Test'));
    return null; 
  }
}

Here are some of the possible problems, based on what I had to change:

  1. The apex:commandLink did not have a closing tag.
  2. The apex:actionRegion should be located within an apex:form tag.
  3. The apex:commandLink did not have a value attribute, meaning I don't know what you were actually clicking on to fire the controller method.

If none of these help, please post the full page and controller code.

1
  • Neither of these was the issue. The most weird thing is that it was fixed by itself. I haven't done any changes and the apex:messages started rendering properly. May 15, 2017 at 19:58

You must log in to answer this question.

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