function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
MakMak 

Error on using apex:pageMessages

I tried moving a page in a sandbox from dev enviornment. This page is still working correctly on dev.
But on trying to save the page on sandbox, I received the following error:
Expression Error: Named Object: core.apexpages.components.cdk.ApexComponentRefHandler not found.

Apparently, this is caused when you use <apex:pageMessages /> in your Visualforce page. I remove this one line and my page is saved without a problem.

I have no clue what the error means and how to avoid it. Could someone help me out of this?

Thanks

jonathanrico.jonathanrico.
Same problem here Mak. I don't know if it has always been this way but if I go to the Component Reference page when using the online editor and go to PageMessages Component I see no information about the component.

It's also happening only in my Sandbox env....

:smileyindifferent:


Message Edited by jonathan rico on 08-26-2008 07:19 AM
MichaelWitMichaelWit
This is a Salesforce bug which has suddenly appeared today.  Could someone out there with access to Premier Support please raise a case about it?
jonathanrico.jonathanrico.
I was having trouble with this since yesterday...
dchasmandchasman
We are already looking into the problem.
dchasmandchasman
We have found the cause of the apex:pageMessages issue and are working to get the issue cleared up asap.
jwetzlerjwetzler
Okay, can you try to load your page now?  Sorry if this caused you any trouble today.
jonathanrico.jonathanrico.
works fine now :smileyhappy:

thank you.
MakMak
Yup ...works now.
Thanks :robothappy:
Chris DChris D
Help. I am now having this exact problem in a sandbox org.
jwetzlerjwetzler
Should be fixed, please try again.
Chris DChris D
It now works again.
MichaelWitMichaelWit

It's not working at 07:00 GMT when running a VisualForce page on a Sandbox org on cs2.salesforce.com.

(The same page that failed last Monday, then worked again, then failed on Tuesday, with no changes.)

Chris DChris D
Broken again! Existing pages containing it give an internal server error. This is putting a thorn in our development process. I am also on a cs2 sandbox.


Message Edited by Chris D on 09-10-2008 08:13 AM
Chris DChris D
When including said tag in question the following error displays:
Error: java.lang.NullPointerException
Error: null

Is the salesforce sandbox intended to be the testing ground before pushing code to production? That is great for internal purposes, but to develop against is not acceptable as one would expect consistency.
jonathanrico.jonathanrico.
Agree with you Chris..

I ignore the possible causes of the problems, but this issue has been affecting a lot our development process.
MichaelWitMichaelWit
As of Thursday 11 September at 10:00 GMT the problem was fixed in the cs2 Sandbox I've been working on, but as of now (14:50 GMT on 13 September) it's back again.

What on earth is going on?
MichaelWitMichaelWit
07:30 GMT Monday, and all's well - it's working again!  Will things be stable from now on?
Chris DChris D
Broken again. Unacceptable. What is going on?
dchasmandchasman
The problem has to do with an issue in component registration that we have fixed in Winter '09 which is scheduled to be deployed in the next few weeks. Back porting the fix has been deemed too risky because it relies on numerous other changes that would not be acceptable candidates for a patch. To complicate things a bit more we are in release freeze for the current release and only critical problems with customer cases that can be safely addressed via an e-release are allowed and this situation fails on at least one criteria.

The workaround we have been applying requires a manual step post restarting an app server that has been difficult to insure will happen and we apologize for the frustration this is causing.

If you truly want to isolate yourself until this gets sorted out I am posting the source for apex:pageMessage and apex:pageMessages to allow you to create custom component versions of them in your own org.

Code pageMessage component:
<apex:component controller="PageMessageController">
    <apex:attribute name="title" type="String" description="The title text for the message."/>
    <apex:attribute name="severity" type="String" assignTo="{!conSeverity}" required="true" description="The severity of the message. Values supported are: 'confirm', 'info', 'warning', 'error'"/>
    <apex:attribute name="strength" type="Integer" assignTo="{!conStrength}" description="The strength of the message. This controls the visibility and size of the icon displayed next to the message.  Use 0 for no image, or 1-3 (highest strength, largest icon)."/>
    <apex:attribute name="summary" type="String" description="The summary message"/>
    <apex:attribute name="detail" type="String" description="The detailed description of the information."/>
    <apex:attribute name="escape" type="Boolean" assignTo="{!conEscape}" description="A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape=&quot;false&quot;, the character escape sequence displays as written.  &#13;&#10;&#13;&#10;Be aware that setting this value to &quot;false&quot; may be a security risk because it allows arbitrary content, including JavaScript, that could be used in a malicious manner."/>
    <div class="message {!styleClass}">
        <table class="messageTable" border="0" cellpadding="0" cellspacing="0" style="padding:0px;margin:0px;">
            <tr valign="top">
                <td>
                    <img src="/s.gif" alt="Error"  class="{!IF(strength > 0,'msgIcon','')}" title="Error"/>
                </td>
                <td class="messageCell">
                    <apex:outputPanel layout="block" styleClass="messageText">
                            <apex:outputPanel style="{!IF(OR(severity = 'ERROR', severity = 'FATAL'), 'color:#cc0000','')}">
                             <h4><apex:outputText value="{!title}" escape="{!conEscape}"/></h4>
       </apex:outputPanel>
                            <apex:outputText value="{!summary}" escape="{!conEscape}"/><br/>
                            <apex:outputText value="{!detail}" escape="{!conEscape}"/>
                    </apex:outputPanel>
                </td>
            </tr>
            <tr >
                <td></td>
                <td>
                    <apex:componentBody/>
                </td>
            </tr>
        </table>
    </div>
</apex:component>

 
Code:
public class PageMessageController {
    public Integer conStrength { get; set; }
    public String conSeverity  { get; set; }
    
    public Boolean getConEscape() {
     return escape != null ? escape : true;
    }

    public void setConEscape(Boolean escape) {
     this.escape = escape;
    }

    public String getStyleClass() {
        String styleClass = conSeverity.toLowerCase();

        /* there is no fatal style defined yet. for now this will be that of error */
        if(styleClass == ApexPages.Severity.FATAL.name().toLowerCase()) styleClass = ApexPages.Severity.ERROR.name().toLowerCase();

        if(conStrength == null || conStrength == 3) styleClass+= 'M2';
        else if(conStrength == 0) styleClass += 'M4';
        else if(conStrength == 1) styleClass += 'M4';
        else if(conStrength == 2) styleClass += 'M3';

        return styleClass;
    }
    
    private Boolean escape; 
}

 
Code pageMessages component:
<apex:component controller="PageMessagesComponentController">
    <apex:attribute name="showDetail" type="Boolean" description="A Boolean value that specifies whether to display the detail portion of the messages. If not specifed this value defaults to false."/>
    <apex:attribute name="escape" type="Boolean" assignTo="{!conEscape}" description="A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape=&quot;false&quot;, the character escape sequence displays as written.  &#13;&#10;&#13;&#10;Be aware that setting this value to &quot;false&quot; may be a security risk because it allows arbitrary content, including JavaScript, that could be used in a malicious manner."/>
        
    <apex:repeat value="{!severities}" var="s">
        <c:pagemessage title="{!s.label}" summary="{!IF(s.isSingle,s.summary,'')}" detail="{!IF(AND(s.isSingle,showDetail),s.message.detail,'')}" severity="{!s.severity}" strength="2" escape="{!conEscape}">
            <apex:outputPanel rendered="{!NOT(s.isSingle)}">
                <ul style="padding-left:10px;padding-top:0px;margin:0px">
                <apex:repeat value="{!s.messages}" var="msg">
                    <li style="padding-top:5px">
                        <apex:outputText value="{!msg.componentLabel}: " rendered="{!msg.componentLabel != ''}"/>
                        <apex:outputText value="{!msg.summary}" rendered="{!msg.summary != ''}"/>
                        <apex:outputPanel layout="block" rendered="{!AND(msg.detail != '',showDetail)}">{!msg.detail}</apex:outputPanel>
                    </li>
                </apex:repeat>
                </ul>
            </apex:outputPanel>
        </c:pageMessage>
    </apex:repeat>
</apex:component>

 
Code:
public class PageMessagesComponentController {
public List<PageMessagesComponentController.severityMessages> getSeverities() {
Map<String, List<ApexPages.Message>> severityMap = new Map<String, List<ApexPages.Message>>();
List<PageMessagesComponentController.severityMessages> severityMessagesList = new List<PageMessagesComponentController.severityMessages>();

for(ApexPages.Message m:ApexPages.getMessages()) {
if(severityMap.get(m.getseverity().name()) == null) severityMap.put(m.getseverity().name(),new List<ApexPages.Message>());
severityMap.get(m.getseverity().name()).add(m);
}

if(severityMap.get(ApexPages.Severity.FATAL.name()) != null) severityMessagesList.add(new PageMessagesComponentController.SeverityMessages(ApexPages.Severity.FATAL.name(),severityMap.get(ApexPages.Severity.FATAL.name())));
if(severityMap.get(ApexPages.Severity.ERROR.name()) != null) severityMessagesList.add(new PageMessagesComponentController.SeverityMessages(ApexPages.Severity.ERROR.name(),severityMap.get(ApexPages.Severity.ERROR.name())));
if(severityMap.get(ApexPages.Severity.WARNING.name()) != null) severityMessagesList.add(new PageMessagesComponentController.SeverityMessages(ApexPages.Severity.WARNING.name(),severityMap.get(ApexPages.Severity.WARNING.name())));
if(severityMap.get(ApexPages.Severity.INFO.name()) != null) severityMessagesList.add(new PageMessagesComponentController.SeverityMessages(ApexPages.Severity.INFO.name(),severityMap.get(ApexPages.Severity.INFO.name())));
if(severityMap.get(ApexPages.Severity.CONFIRM.name()) != null) severityMessagesList.add(new PageMessagesComponentController.SeverityMessages(ApexPages.Severity.CONFIRM.name(),severityMap.get(ApexPages.Severity.CONFIRM.name())));

return severityMessagesList;
}

public class severityMessages {

public Boolean isSingle {
get{
return messages.size() == 1;
}
set;
}

/* This is necessary because there seems to be no mechanism to concat in formulas within page markup.
Due to the structure of the multi-message case this is not necessary in that case.*/
public String summary {
get {
if(message != null && message.getcomponentLabel() == null) summary = message.getsummary();
else if(message != null && message.getcomponentLabel() != null) summary = message.getcomponentLabel() + ': ' + message.getsummary();

return summary;
}
set;
}
public ApexPages.Message message {
get {
if(messages.size() == 1) message = messages.get(0);
return message;
}
private set;
}
public String severity {get; private set;}
public List<ApexPages.Message> messages {get; private set;}
public String getLabel() {
if(messages != null && messages.size() == 1) return singleLabel;
else return pluralLabel;
}

public String singleLabel {
get{
return severity;
}

private set;
}

public String pluralLabel {
get{
return severity;
}

private set;
}

public SeverityMessages(String severity, List<ApexPages.Message> messages) {
this.severity = severity;
this.messages = messages;
}
}

public Boolean getConEscape() {
return escape != null ? escape : true;
}

public void setConEscape(Boolean escape) {
this.escape = escape;
}

private Boolean escape;
}


Message Edited by dchasman on 09-16-2008 01:51 AM
dchasmandchasman
I am also working on automating the current workaround that requires a manual initialization step that is not being performed reliably.