• aaishaa19
  • NEWBIE
  • 50 Points
  • Member since 2010

  • Chatter
    Feed
  • 2
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 5
    Replies

I have a VF page, with two page blocks in it Both blocks contain pageBlockButtons ,
 containing one button in each..
There are few field in each block which are populated on button click ...

The Problem is when I click on one button .. The action of the button invoked and populate and when I click
on 2nd nothing happen.. And vice versa..

At time only one button's action is invoked and other remain idle..


Please tell me where im going wrong.!!
Any kinda help will b appreciated


Regards;
Aisha

Hello..

 I'm trying to insert an entry in a custom object..


Code in apex is :

<apex:page controller="ProgramController">
    <apex:form >
        <apex:pageBlock title="Program Section">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" />
            </apex:pageBlockButtons>

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

 

Controller -- ProgramController

 

public with sharing class ProgramController
{
    public void save()
    {    
        try
        {
            Program__c tempProgram = new Program__c(Payment__c= false,
                    ParentProgram__c='testProg');
            insert tempProgram ;

}  
        catch(System.Exception e)
        {
            ApexPages.addMessages(e);
           //throw e;
            // return null;
        }

    }
}

 

It's working fine for me .. now im trying to add some other controls like selectlist etc and tryin to format page accordingly.

The new apex page is like

 

Apex:

<!-- <apex:page controller="ProgramController">
<apex:page standardcontroller="Program__c" extensions="ProgramController">
-->
<apex:page controller="ProgramController">

    <h2>Program</h2>

    <apex:form >
        <apex:pageBlock title="Program Section">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" />
                <apex:commandButton value="Save & New" action="{!save}" />
                <apex:commandButton value="Close" rerender="out" status="status" />
            </apex:pageBlockButtons>

            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >
                        <h1>Title:</h1>
                    </apex:outputLabel>
                    <apex:inputtext id="ProgramName" />
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                    <apex:outputLabel >
                        <h1>Program Type:</h1>
                    </apex:outputLabel>
                    <apex:selectList value="{!types}" size="1" id="ProgType">
                        <apex:selectOptions value="{!type}" />
                    </apex:selectList>


                </apex:pageBlockSectionItem>

            </apex:pageBlockSection>

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

 

and Controller is

 

ProgramController:

public with sharing class ProgramController
{
    Public Program__c auto{get; set;}
    String[] types= new String[]{};

    /*
    public ProgramController() {
    }

    public ProgramController(ApexPages.StandardController controller)
    {
    }

     public PageReference ProgramController()      
       {           
         return null;        
       }*/

    public List<SelectOption> getType()  
    {
        List<SelectOption> options = new List<SelectOption>();   
        options.add(new SelectOption('0.','Payment Program'));
        options.add(new SelectOption('1','Non-Payment Program'));
        return options;  
    }
    public String[] getTypes()
    {
        return types;
    }
    public void setTypes(String[] types)
    {
        this.types= types;        
    }

    public void save()
    {    
        try
        {
            Program__c tempProgram = new Program__c(Payment__c= false,
                    ParentProgram__c='testProg');
            insert tempProgram ;

    
        }  
        catch(System.Exception e)
        {
            ApexPages.addMessages(e);
            //throw e;
            // return null;
        }

    }
}

 

 

Now in this case, it's not allowing me to insert .. and i jus found that is because of the populating SelectLists and due to <apex:pageBlockSectionItem > tag in page ... if i exclude these two things .. all insertions are working fine. I don't have any idea where i'm going wrong..

 

Any kind of help will b appreciated..

Thnx!!

 

I have a VF page, with two page blocks in it Both blocks contain pageBlockButtons ,
 containing one button in each..
There are few field in each block which are populated on button click ...

The Problem is when I click on one button .. The action of the button invoked and populate and when I click
on 2nd nothing happen.. And vice versa..

At time only one button's action is invoked and other remain idle..


Please tell me where im going wrong.!!
Any kinda help will b appreciated


Regards;
Aisha

Hello..

 I'm trying to insert an entry in a custom object..


Code in apex is :

<apex:page controller="ProgramController">
    <apex:form >
        <apex:pageBlock title="Program Section">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" />
            </apex:pageBlockButtons>

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

 

Controller -- ProgramController

 

public with sharing class ProgramController
{
    public void save()
    {    
        try
        {
            Program__c tempProgram = new Program__c(Payment__c= false,
                    ParentProgram__c='testProg');
            insert tempProgram ;

}  
        catch(System.Exception e)
        {
            ApexPages.addMessages(e);
           //throw e;
            // return null;
        }

    }
}

 

It's working fine for me .. now im trying to add some other controls like selectlist etc and tryin to format page accordingly.

The new apex page is like

 

Apex:

<!-- <apex:page controller="ProgramController">
<apex:page standardcontroller="Program__c" extensions="ProgramController">
-->
<apex:page controller="ProgramController">

    <h2>Program</h2>

    <apex:form >
        <apex:pageBlock title="Program Section">

            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" />
                <apex:commandButton value="Save & New" action="{!save}" />
                <apex:commandButton value="Close" rerender="out" status="status" />
            </apex:pageBlockButtons>

            <apex:pageBlockSection title="My Content Section" columns="2">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel >
                        <h1>Title:</h1>
                    </apex:outputLabel>
                    <apex:inputtext id="ProgramName" />
                </apex:pageBlockSectionItem>

                <apex:pageBlockSectionItem >
                    <apex:outputLabel >
                        <h1>Program Type:</h1>
                    </apex:outputLabel>
                    <apex:selectList value="{!types}" size="1" id="ProgType">
                        <apex:selectOptions value="{!type}" />
                    </apex:selectList>


                </apex:pageBlockSectionItem>

            </apex:pageBlockSection>

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

 

and Controller is

 

ProgramController:

public with sharing class ProgramController
{
    Public Program__c auto{get; set;}
    String[] types= new String[]{};

    /*
    public ProgramController() {
    }

    public ProgramController(ApexPages.StandardController controller)
    {
    }

     public PageReference ProgramController()      
       {           
         return null;        
       }*/

    public List<SelectOption> getType()  
    {
        List<SelectOption> options = new List<SelectOption>();   
        options.add(new SelectOption('0.','Payment Program'));
        options.add(new SelectOption('1','Non-Payment Program'));
        return options;  
    }
    public String[] getTypes()
    {
        return types;
    }
    public void setTypes(String[] types)
    {
        this.types= types;        
    }

    public void save()
    {    
        try
        {
            Program__c tempProgram = new Program__c(Payment__c= false,
                    ParentProgram__c='testProg');
            insert tempProgram ;

    
        }  
        catch(System.Exception e)
        {
            ApexPages.addMessages(e);
            //throw e;
            // return null;
        }

    }
}

 

 

Now in this case, it's not allowing me to insert .. and i jus found that is because of the populating SelectLists and due to <apex:pageBlockSectionItem > tag in page ... if i exclude these two things .. all insertions are working fine. I don't have any idea where i'm going wrong..

 

Any kind of help will b appreciated..

Thnx!!