0

I have an output text field in visualforce page, which has a rendered condition. A few permission set does not have access to that object being checked in the rendered condition and we are getting this error:

The value 'null' is not valid for operator '>'. Error is in expression '{!cert.certiObj.Insured_Informations__r.size > 0}' in component in page dispositionpage`

Is there any work around to still render the page succecssfully to ignore the error?

<apex:outputText value="{!cert.certiObj.Insured_Informations__r[0].Insured_Info_Name__c}" rendered="{!cert.certiObj.Insured_Informations__r.size > 0}" id="prodName2"/>

How do I check if Cert.certiObj is null then don't check for null on child obj?

1 Answer 1

4

You can check if your collection is null before comparing its size. Note this error indicates cert.certiObj.Insured_Informations__r is null, not cert.certiObj.

<apex:outputText ...
    rendered="{!AND(cert.certiObj.Insured_Informations__r != null, cert.certiObj.Insured_Informations__r.size > 0)}" />

However, this approach is quite clunky, and it may be worth just caching the Boolean as a property:

public Boolean getHasInformation()
{
    return cert.certObj.Insured_Informations__r != null &&
        !cert.certObj.Insured_Informations__r.isEmpty();
}

Then in your markup simply:

<apex:outputText ...
    rendered="{!hasInformation}" />

You must log in to answer this question.

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