• Naresh Kumar Mohan Thirukkovaluru
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 13
    Questions
  • 12
    Replies
<apex:page controller="calc" >
  <apex:form >
  <apex:pageBlock >
  <apex:inputText maxlength="10" value="{!result}" size="12"/>
  <apex:panelGrid title="Calculator" cellpadding="2" columns="4" border="5" bgcolor="gold">
  <apex:commandButton value="9" action="{!nine}" />
  <apex:commandButton value="8" action="{!eight}"/>
  <apex:commandButton value="7" action="{!seven}"/>
  <apex:commandButton value="/" action="{!divide}"/>
  <apex:commandButton value="6" action="{!six}"/>
  <apex:commandButton value="5" action="{!five}"/>
  <apex:commandButton value="4" action="{!four}"/>
  <apex:commandButton value="*" action="{!multiply}"/>
   <apex:commandButton value="3" action="{!three}"/>
   <apex:commandButton value="2" action="{!two}"/>
   <apex:commandButton value="1" action="{!one}"/>
   <apex:commandButton value="+" action="{!add}"/>
   <apex:commandButton value="0" action="{!zero}"/>
   <apex:commandButton value="."/>
   <apex:commandButton value="-" action="{!minus}"/>
   <apex:commandButton value="=" action="{!equal}"/>
  </apex:panelGrid>
</apex:pageBlock>
</apex:form> 
</apex:page>






public with sharing class calc {

    public PageReference equal() {
            result=string.valueOf(num);
            return null;


    }


    public String result { get; set; }

    integer num=0;
   

    public PageReference minus() {
            num-=integer.valueOf(result);      
            result=null;
            return null;

    }


    public PageReference zero() {
            if(integer.valueOf(result)==num){
            result = '0';
            return null;
            }
        else{
            result+= '0';
            return null;
            }

    }


    public PageReference add() {
       
       num+=integer.valueOf(result);
            result=null;
            return null;

    }


    public PageReference one() {
            if(integer.valueOf(result)==num){
            result = '1';
            return null;
            }
        else{
            result+='1';
            return null;
            }

    }


    public PageReference two() {
        if(integer.valueOf(result)==num){
            result = '2';
            return null;
            }
        else{
            result+='2';
            return null;
            }
    }


    public PageReference three() {
         if(integer.valueOf(result)==num){
            result = '3';
            return null;
            }
        else{
            result+='3';
            return null;
            }
    }


    public PageReference multiply() {
           num=num*integer.valueOf(result);
            result=null;
            return null;

    }


    public PageReference four() {
         if(integer.valueOf(result)==num){
            result = '4';
            return null;
            }
        else{
            result+='4';
            return null;
            }
    }


    public PageReference five() {
         if(integer.valueOf(result)==num){
            result = '5';
            return null;
            }
        else{
            result+='5';
            return null;
            }
    }


    public PageReference six() {
         if(integer.valueOf(result)==num){
            result = '6';
            return null;
            }
        else{
            result+='6';
            return null;
            }
    }


    public PageReference divide() {
           num=num/integer.valueOf(result);
            result=null;
            return null;

    }


    public PageReference seven() {
        if(integer.valueOf(result)==num){
            result = '7';
            return null;
            }
        else{
            result+='7';
            return null;
            }
    }


    public PageReference eight() {
         if(integer.valueOf(result)==num){
            result = '8';
            return null;
            }
        else{
            result+='8';
            return null;
            }
    }


    public PageReference nine() {
         if(integer.valueOf(result)==num){
            result = '9';
            return null;
            }
        else{
            result+='9';
            return null;
            }
    }

}
VF
<apex:page controller="extnaddclas" extensions="add">
  <apex:form >
   <apex:pageBlock >
    <apex:pageBlockSection >
     Enter 1st value <apex:inputText value="{!one}"/>
     Enter 2nd value <apex:inputText value="{!two}"/>
     Enter 3rd value <apex:inputText value="{!three}"/>
     Result &nbsp;&nbsp; = <apex:outputText value="{!res}"/>
    </apex:pageBlockSection>
    <apex:commandButton value="ADD" action="{!add}"/>
   </apex:pageBlock>
  </apex:form>
</apex:page>

Controllr
public with sharing class extnaddclas {

    public String res { get; set; }

    public String three { get; set; }

    public String two { get; set; }

    public String one { get; set; }

    public PageReference add() {
       
        return null;
    }

}


Extnsn

public with sharing class add {

    public add(extnaddclas controller) {   

    }
   
    public PageReference add(){
   
        Integer r = Integer.valueOf('res');
        Integer o = Integer.valueOf('one');
        Integer t = Integer.valueOf('two');
        Integer th = Integer.valueOf('three');
        r = o+t+th;
        //extnaddclas.res = string.valueOf(r);
    return null;
   
    }

}



its givng system type exception error invalid res.............plz correct ver i m gng wrong............

plz its urgent
public with sharing class sample {

    public List<selectoption> getCities() {
   
  
        List<selectoption> op1= new List<selectoption> ();
        if(state == 'AP')
        {
        List<dependncs__c> rt = [select city__c from dependncs__c];
         string nb;
         for(dependncs__c c : rt)
         nb=c.city__c;
        op1.add(new selectoption(nb,nb));
        }
       else if(state == 'TN')
       {
        //op1.add(new selectoption('CHEN','CHENNAI'));
       }
       else
        {
            //op1.add(new SelectOption('None','--- None ---'));
        }     

        return op1;
    }


    public String city { get; set; }

    public  List<selectoption> getStates() {
       List<dependncs__c> rt = [select state__c from dependncs__c];
       List<selectoption> op= new  List<selectoption> ();
       string na;
       for(dependncs__c b:rt){
       na=b.state__c;
       op.add(new selectoption(na,na));
       }
       
        
        return op;
    }


    public String state { get; set; }
}





VF
<apex:page controller="sample">
  <apex:form >
   
    <apex:pageBlock >
        <apex:pageBlockSection columns="2">
            <apex:pageblockSectionItem >
                <apex:outputLabel value="State"/>
            </apex:pageblockSectionItem>       
            <apex:pageblockSectionItem >               
                <apex:selectList size="1" value="{!state}">
                    <apex:selectOptions value="{!states}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>               
            </apex:pageblockSectionItem>
            <apex:pageblockSectionItem >
                <apex:outputLabel value="City"/>
            </apex:pageblockSectionItem>           
            <apex:pageblockSectionItem >
                <apex:selectList size="1" value="{!city}" id="a">
                    <apex:selectOptions value="{!cities}"/>
                </apex:selectList>
            </apex:pageblockSectionItem>           
        </apex:pageBlockSection>       
    </apex:pageBlock>

    </apex:form>
</apex:page>




<apex:page controller="calc" >
  <apex:form >
  <apex:pageBlock >
  <table border="1">
   <apex:inputText size="11"/>
   <tr><td><apex:commandButton value="9" /></td><td><apex:commandButton value="8"/></td><td><apex:commandButton value="7"/></td><td><apex:commandButton value="/"/></td></tr>
   <tr><td><apex:commandButton value="6"/></td><td><apex:commandButton value="5"/></td><td><apex:commandButton value="4"/></td><td><apex:commandButton value="*"/></td></tr>
   <tr><td><apex:commandButton value="3"/></td><td><apex:commandButton value="2"/></td><td><apex:commandButton value="1"/></td><td><apex:commandButton value="+"/></td></tr>
   <tr><td><apex:commandButton value="0"/></td><td><apex:commandButton value="."/></td><td><apex:commandButton value="-"/></td><td><apex:commandButton value="%"/></td></tr>
</table>
</apex:pageBlock>
</apex:form> 
</apex:page>
<apex:page >
    <apex:form >
        <apex:pageBlock tabStyle="Doctor__c" title="YAHOO! M@iL" >
            <apex:pageBlockSection TItle="Sign In" >
                <apex:pageBlockSectionItem > Username<apex:inputText />
                    </apex:pageBlockSectionItem><br/>
                <apex:pageBlockSectionItem > Password<apex:inputSecret />
            </apex:pageBlockSectionItem><br/>
        <apex:pageBlockSectionItem > <apex:inputCheckbox /> Keep me logged in.
    </apex:pageBlockSectionItem>
</apex:pageBlockSection>
      <apex:commandButton value="SignIn"/><br/><br/>
          <apex:commandLink value="Forgot Passowrd"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public with sharing class bookclass {
    
     public bookclass(){
     name1=' ';
     price1=null;
     author1=' ';
     edition1=null;
     }
    
     public String name1 { get; set; }
    
     public decimal price1 { get; set; }
    
     public String author1 { get; set; }
    
     public decimal edition1 { get; set; }
    

    public PageReference save() {
    book__c bk = new book__c();
    bk.name=name1;
    bk.bookprice__C=price1;
    bk.author__C=author1;
    bk.edition__C=edition1;
    insert bk;
   
        return null;
    }


    public PageReference saveandnew() {
        return null;
    }

     public PageReference cancel() {
        return null;
    }

}
VF
<apex:page controller="extnaddclas" extensions="add">
  <apex:form >
   <apex:pageBlock >
    <apex:pageBlockSection >
     Enter 1st value <apex:inputText value="{!one}"/>
     Enter 2nd value <apex:inputText value="{!two}"/>
     Enter 3rd value <apex:inputText value="{!three}"/>
     Result &nbsp;&nbsp; = <apex:outputText value="{!res}"/>
    </apex:pageBlockSection>
    <apex:commandButton value="ADD" action="{!add}"/>
   </apex:pageBlock>
  </apex:form>
</apex:page>

Controllr
public with sharing class extnaddclas {

    public String res { get; set; }

    public String three { get; set; }

    public String two { get; set; }

    public String one { get; set; }

    public PageReference add() {
       
        return null;
    }

}


Extnsn

public with sharing class add {

    public add(extnaddclas controller) {   

    }
   
    public PageReference add(){
   
        Integer r = Integer.valueOf('res');
        Integer o = Integer.valueOf('one');
        Integer t = Integer.valueOf('two');
        Integer th = Integer.valueOf('three');
        r = o+t+th;
        //extnaddclas.res = string.valueOf(r);
    return null;
   
    }

}



its givng system type exception error invalid res.............plz correct ver i m gng wrong............

plz its urgent
public with sharing class sample {

    public List<selectoption> getCities() {
   
  
        List<selectoption> op1= new List<selectoption> ();
        if(state == 'AP')
        {
        List<dependncs__c> rt = [select city__c from dependncs__c];
         string nb;
         for(dependncs__c c : rt)
         nb=c.city__c;
        op1.add(new selectoption(nb,nb));
        }
       else if(state == 'TN')
       {
        //op1.add(new selectoption('CHEN','CHENNAI'));
       }
       else
        {
            //op1.add(new SelectOption('None','--- None ---'));
        }     

        return op1;
    }


    public String city { get; set; }

    public  List<selectoption> getStates() {
       List<dependncs__c> rt = [select state__c from dependncs__c];
       List<selectoption> op= new  List<selectoption> ();
       string na;
       for(dependncs__c b:rt){
       na=b.state__c;
       op.add(new selectoption(na,na));
       }
       
        
        return op;
    }


    public String state { get; set; }
}





VF
<apex:page controller="sample">
  <apex:form >
   
    <apex:pageBlock >
        <apex:pageBlockSection columns="2">
            <apex:pageblockSectionItem >
                <apex:outputLabel value="State"/>
            </apex:pageblockSectionItem>       
            <apex:pageblockSectionItem >               
                <apex:selectList size="1" value="{!state}">
                    <apex:selectOptions value="{!states}"/>
                    <apex:actionSupport event="onchange" reRender="a"/>
                </apex:selectList>               
            </apex:pageblockSectionItem>
            <apex:pageblockSectionItem >
                <apex:outputLabel value="City"/>
            </apex:pageblockSectionItem>           
            <apex:pageblockSectionItem >
                <apex:selectList size="1" value="{!city}" id="a">
                    <apex:selectOptions value="{!cities}"/>
                </apex:selectList>
            </apex:pageblockSectionItem>           
        </apex:pageBlockSection>       
    </apex:pageBlock>

    </apex:form>
</apex:page>




<apex:page >
    <apex:form >
        <apex:pageBlock tabStyle="Doctor__c" title="YAHOO! M@iL" >
            <apex:pageBlockSection TItle="Sign In" >
                <apex:pageBlockSectionItem > Username<apex:inputText />
                    </apex:pageBlockSectionItem><br/>
                <apex:pageBlockSectionItem > Password<apex:inputSecret />
            </apex:pageBlockSectionItem><br/>
        <apex:pageBlockSectionItem > <apex:inputCheckbox /> Keep me logged in.
    </apex:pageBlockSectionItem>
</apex:pageBlockSection>
      <apex:commandButton value="SignIn"/><br/><br/>
          <apex:commandLink value="Forgot Passowrd"/>
        </apex:pageBlock>
    </apex:form>
</apex:page>
public with sharing class bookclass {
    
     public bookclass(){
     name1=' ';
     price1=null;
     author1=' ';
     edition1=null;
     }
    
     public String name1 { get; set; }
    
     public decimal price1 { get; set; }
    
     public String author1 { get; set; }
    
     public decimal edition1 { get; set; }
    

    public PageReference save() {
    book__c bk = new book__c();
    bk.name=name1;
    bk.bookprice__C=price1;
    bk.author__C=author1;
    bk.edition__C=edition1;
    insert bk;
   
        return null;
    }


    public PageReference saveandnew() {
        return null;
    }

     public PageReference cancel() {
        return null;
    }

}