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
Roshan TamrakarRoshan Tamrakar 

VF Page in Section

After a long search and help from Discussion Board, I was able to pass parameter from commandButton to my controller class. However, this lead to me another problem.

Below is my page and controller class.

Code:
<apex:page standardController="Account" extensions="AccountExtension" sidebar="false" showheader="false">
<apex:form >
  <apex:pageBlock id="out" rendered="False">
  </apex:pageBlock>
  <apex:pageBlock >
  {!Account.Name}
  <apex:pageBlockSection >
    <apex:pageblockTable value="{!Account.Contacts}" var="cnt">
      <apex:column value="{!cnt.Name}"/>
      <apex:column >
        <apex:commandButton value="{!cnt.Name}" action="{!dosomething}" rerender="out">
          <apex:param name="prmFunc" value="{!cnt.Name}"/>
        </apex:commandButton>
      </apex:column>
    </apex:pageblockTable>
  </apex:pageBlockSection>
  </apex:pageBlock>
</apex:form>
</apex:page>

public class AccountExtension{
    
    private final Account ac;
    Id acId;
    //Constructor
    public AccountExtension(ApexPages.StandardController stdController){
        this.ac = (Account)stdController.getRecord();       
        //Store Account's id
        acId = System.CurrentPageReference().getParameters().get('id');
    }  
    
    public PageReference dosomething(){
        String prmFunc = System.currentPageReference().getParameters().get('prmFunc');
        PageReference page = new PageReference('/500/e—retURL=/'+acId+'&cas15='+prmFunc);
        page.setRedirect(true);
        return page;
    }
}

Everything works find and I even receive the parameter from my controller class. The problem is:

The above page I have placed inside a section in the Account detail page.



When I click on the button, new Case window is opened within the section.

 

I want the case to open in the whole page not within the section.

If I remove my rerender attribute from the commandButton, it works but then I don't get the parameter value. It's very frustrating.

If I change above commandButton to commandLink, then it works without any rerender attribute.
But my requirement is to use commandButton.

Code submitted above is not dependent on any custom object, so it can be just copied and pasted for the test.

Please help.

David VPDavid VP
Hi,

I haven't looked into detail to your code but stumbled upon a similar problem today :
If you can live with a commandLink instead of a commandButton, you can use target="_top".

The commandLink passes parameters in the exact same way as the commandButton so that should still work.

Hope this helps,


David
dchasmandchasman
I would not use apex:commandButton or apex:commandLink to implement your solution.

Take a look at http://community.salesforce.com/sforce/board/message?board.id=Visualforce&message.id=2323#M2323

I am seeing lots of folks using commandButton/commandLink with an action as an extremely heavyweight mechanism to do what a simple link or button would do better, cheaper and faster. I see in your case you need a button instead of a link as you UI and that is simple enough using basic HTML (sorry we do not currently have apex:outputButton).

I'm working up the example specific to your situation now.