You need to sign in to do that
Don't have an account?
Matthew Harris 40
Uknown Property Errors
Hello!
I am making contact search page where the Results and Errors pageblocks render based on the value of their corresponding booleans:
<apex:pageBlock title="Results" rendered="{!ResultsPresent}">
or this
<apex:pageBlock title="Errors" id="ErrorSection" rendered="{!ErrorsPresent}">
I keep getting "Unknown Property" errors.
Here are the pageblocks in question:
Here is my Controller
In a similar vein, I'm trying to also make an outputtext box that displays the number of results based the value of MatchingContacts but when I do that, I ALSO get an unknown property error.
What am I missing here?
I am making contact search page where the Results and Errors pageblocks render based on the value of their corresponding booleans:
- public boolean ResultsPresent
- public boolean ErrorsPresent
<apex:pageBlock title="Results" rendered="{!ResultsPresent}">
or this
<apex:pageBlock title="Errors" id="ErrorSection" rendered="{!ErrorsPresent}">
I keep getting "Unknown Property" errors.
Here are the pageblocks in question:
<!-- Results Display --> <apex:pageBlock title="Results" rendered="{!ResultsPresent}"> <apex:outputText value="There are currently '' results found." /> <apex:pageBlockSection > <apex:pageBlockTable value="{!contacts}" var="c" id="contact-table"> <apex:column > <apex:facet name="header">Name</apex:facet> {!c.Name} </apex:column> <apex:column > <apex:facet name="header">Phone Number</apex:facet> {!c.Phone} </apex:column> <apex:column > <apex:facet name="header">Email</apex:facet> {!c.Email} </apex:column> </apex:pageBlockTable> </apex:pageBlockSection> </apex:pageBlock> <!-- Error Display --> <apex:pageBlock title="Errors" id="ErrorSection" rendered="{!ErrorsPresent}"> <apex:pageMessages id="ErrorsListing"> </apex:pageMessages> </apex:pageBlock>
Here is my Controller
public with sharing class Ctrl_ContactSearch { public List<Contact> contacts { get; set; } public String name { get; set; } public String phone { get; set; } public String email { get; set; } public integer MatchingContacts = 0; public boolean ResultsPresent = false; public boolean ErrorsPresent = false; public boolean Error_NoResults = false; public boolean Error_FieldsEmpty = false; public boolean Error_NameSyntax = false; public boolean Error_PhoneSyntax = false; public boolean Error_EmailSyntax = false; /* Name Input Validation Regex*/ public static Boolean ValidationName (String name) { Boolean NameIsValid = false; String nameRegex = '[a-zA-Z]*[\\s]{1}[a-zA-Z].*'; Pattern PatternName = Pattern.compile(nameRegex); Matcher nameMatcher = PatternName.matcher(name); if (nameMatcher.matches()) { NameIsValid = true; } return NameIsValid; } /* Phone Input Validation Regex*/ public static Boolean ValidationPhone (String phone) { Boolean PhoneIsValid = false; String phoneRegex = '^([0-9\\(\\)\\/\\+ \\-]*)$'; Pattern PatternPhone = Pattern.compile(phoneRegex); Matcher phoneMatcher = PatternPhone.matcher(phone); if (phoneMatcher.matches()) { PhoneIsValid = true; } return PhoneIsValid; } /* Email Input Validation Regex*/ public static Boolean ValidationEmail (String email) { Boolean EmailIsValid = false; String emailRegex = '^[a-zA-Z0-9._|\\\\%#~`=?&/$^*!}{+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,4}$'; Pattern PatternEmail = Pattern.compile(emailRegex); Matcher emailMatcher = PatternEmail.matcher(email); if (emailMatcher.matches()) { EmailIsValid = true; } return EmailIsValid; } /* Runs when "Clear Fields" button is pressed*/ public void ClearFields() { name = ''; phone = ''; email = ''; } /* Runs when "Search Contacts" button is pressed*/ public PageReference searchContacts() { /* Checks if input fields are empty*/ if (name == '' && phone == '' && email == '') { Error_FieldsEmpty = true; ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Your fields are blank. Please enter your information in the remaining fields to proceed')); } else { /* Checks Input Validation Results*/ if (ValidationName(name) == false) { Error_NameSyntax = true; ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Inproper name format. Please enter name in following format : Firstname Lastname.')); } if (ValidationPhone(phone) == false) { Error_PhoneSyntax = true; ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Inproper phone number format. Please enter number in following format : XXX-XXX-XXXX.')); } if (ValidationEmail(email) == false) { Error_EmailSyntax = true; ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'Inproper email format. Please enter email in following format : XXX@emailprovider.com')); } /* Runs if all Validation results are 'true'*/ if (ValidationName(name) == true && ValidationPhone(phone) == true && ValidationEmail(email) == true) { ResultsPresent = true; contacts = [select Name, Phone, Email from Contact where Name = :name or Phone = :phone or email = :email]; MatchingContacts = contacts.size(); /* Checks if/how many matches were found from the search*/ if(MatchingContacts != 0) { return null; } else { Error_NoResults = true; ApexPages.addmessage(new ApexPages.message(ApexPages.severity.ERROR,'No matching Contacts were found.')); } } } /* Displays "Error" field if any errors are found*/ if (Error_NoResults == true || Error_FieldsEmpty == true || Error_NameSyntax == true || Error_PhoneSyntax == true || Error_EmailSyntax == true) { ErrorsPresent = true; ApexPages.addmessage(new ApexPages.message(ApexPages.severity.WARNING,'There are errors present. Please read and follow instructions accordingly.')); } return null; } }
In a similar vein, I'm trying to also make an outputtext box that displays the number of results based the value of MatchingContacts but when I do that, I ALSO get an unknown property error.
What am I missing here?
Hi Matthew,
To be able to use these variables on visualforce page, you need to make them public as well as getters and setters.
Once you make the above change to your variable definition, you'll not get the unknown property.
Hope this helps.
Best,
Vishal
All Answers
Hi Matthew,
To be able to use these variables on visualforce page, you need to make them public as well as getters and setters.
Once you make the above change to your variable definition, you'll not get the unknown property.
Hope this helps.
Best,
Vishal