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
White HatWhite Hat 

why there is an "unknown result" error even there is a controller on <apex:Page>

public class CALCI
{
    public Integer a { get; set; }
    public Integer b { get; set; }
    public Integer r { get; set; }
    public string o { get; set; }
    
     public pageReference subb()
    {
         r = a - b;
        o='substraction';
        return null;
    }
     public pageReference add()
    {
         r = a + b;
        o='addition';
        return null;
    }
     public pageReference mul()
    {
         r = a * b;
        o='multiplication';
        return null;
    }    
}

--------------------------------------------------------------------------------------------------
<apex:page controller="CALCI" >
    <apex:form>
        <apex:pageBlock title="CALCI">
            <apex:pageBlockSection columns="1" title="simple operations" collapsible="false">
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>Enter A</apex:outputLabel>
                    <apex:inputText value="{!a}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>Enter B</apex:outputLabel>
                    <apex:inputText value="{!b}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>you have performed {!o } of {!a} and {!b} and result is {!result}</apex:outputLabel>
                </apex:pageBlockSectionItem>               
            </apex:pageBlockSection>    
        </apex:pageBlock>
    </apex:form> 
</apex:page>
Best Answer chosen by White Hat
Ajay K DubediAjay K Dubedi
Hi White,

Use below code it works fine, you use {!result} instead of {!r} and it gives you an error
<apex:page controller="CALCI" >
    <apex:form>
        <apex:pageBlock title="CALCI">
            <apex:pageBlockSection columns="1" title="simple operations" collapsible="false">
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>Enter A</apex:outputLabel>
                    <apex:inputText value="{!a}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>Enter B</apex:outputLabel>
                    <apex:inputText value="{!b}"/>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem>
                    <apex:outputLabel>you have performed {!o } of {!a} and {!b} and result is {!r}</apex:outputLabel>
                </apex:pageBlockSectionItem>               
            </apex:pageBlockSection>    
        </apex:pageBlock>
    </apex:form> 
</apex:page>
 
I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com