• Keith987
  • NEWBIE
  • 50 Points
  • Member since 2011

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

I am getting a strange error message as above.

 

I have an interface {say A} which has one method. I have a class {say B} that implements the interface (the method). And I have another class/method that takes interface A as a parameter. And I call that method with an instance of the class B. All compiles ok. But I got the error when running it.

 

I do not see what can possibly be wrong with my code. If I do not implement the method in A, it fails to compile. If I remove 'implements A' from B, it fails to compile. Also I have another class {C} that implements the interface A, and is used in exact same way and it works fine.

 

Anyone has seen similar issues?

 

 

 

 

 

 

This old post Selenium Testing Best Practices describes the problem that the id values generated by the Force.com platform on default (layout-based) UI fields vary between orgs. So the normal practice of using field ids to match page elements to stop Selenium tests being fragile (when elements are added or removed) looks impractical unless you can guarantee to only ever need to test in one org.

 

Can anyone offer advice on how to work around this problem?

 

Thanks,

Keith

I have a side bar component written in Visualforce that is only relevant to one of my apps and would like its output to only be present when that app is selected. I can also imagine other use cases where knowing the currently selected app would be useful.

 

Anyone know if this information can be obtained in Apex code?

 

Thanks,

Keith

I have multiple versions of a managed package installed. Not setting the PackageVersionHeader in the calling Java code results in the fields added in later versions of the managed package not being returned by describeSObjects and causing errors in query calls even when the "Configure Enterprise Package Version Settings" have been set. My reading of the documentation suggested that making those settings would be enough.

 

The code does work if I set the version numbers in the PackageVersionHeader but that is not a particularly convenient solution.

 

Can anyone confirm this behavior or let me know what I'm missing here?

 

Thanks,

Keith

 

 

<apex:repeat value="{!sectionOrder}" var="order">
    <apex:outputPanel layout="none" rendered="{! order == 'Reference' }">
        <apex:pageBlock title="Reference">
            <apex:pageBlockButtons location="top">
                <apex:commandButton reRender="??? what goes here to get the EligibilityPageBlock re-rendered ???"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:outputPanel>
    <apex:outputPanel layout="none" rendered="{! order == 'Synopsis' }">
        <apex:pageBlock title="Synopsis">
        </apex:pageBlock>
    </apex:outputPanel>
    <apex:outputPanel layout="none" rendered="{! order == 'Eligibility' }" id="EligibilityOutputPanel>
        <apex:pageBlock title="Eligibility" id="EligibilityPageBlock">
        </apex:pageBlock>
    </apex:outputPanel>
    <!-- More similar panels -->
</apex:repeat>

The above illustrates how I am controlling the order that some apex:pageBlocks are output by having a sectionOrder list provided by the controller. Introducing this re-ordering has however broken some reRender logic that I had, perhaps because the full ids in the generated page now include the apex:repeat index of 0, 1, 2 etc.

 

I am unclear about how the id supplied in reRender is resolved back to the full id in the page. Any insight into whether there is a way to get partial page re-rendering to work in the above situation would be appreciated.

 

Thanks,

Keith

The code below is my first attempt at solving this problem based on inspecting the relevant objects via the developer console. But I have not found any documentation that confirms that this logic is appropriate. Please comment if you now of such documentation or have a cleaner or proven solution.

 

Thanks,

Keith

Force201

 

// Return payment id to set of approver ids
private Map<Id, Set<Id>> readApprovers(Set<Id> paymentIds) {
    
    // Get the latest ProcessInstance for each payment
    Map<Id, ProcessInstance> m = new Map<Id, ProcessInstance>();
    for (ProcessInstance pi : [
            select Id, TargetObjectId, (select ActorId from Steps where StepStatus not in ('Approved', 'Rejected'))
            from ProcessInstance
            where TargetObjectId in :paymentIds
            and IsDeleted != true
            and Status not in ('Approved', 'Rejected')
            order by CreatedDate desc
            ]) {
        if (m.get(pi.TargetObjectId) == null) {
            m.put(pi.TargetObjectId, pi);
        }      
    }
    
    // Ensure always at least an empty set not null
    Map<Id, Set<Id>> results = new Map<Id, Set<Id>>();
    for (Id paymentId : paymentIds) {
        results.put(paymentId, new Set<Id>());
    }
    
    // Find any actors who have not processed their step
    for (ProcessInstance pi : m.values()) {
        for (ProcessInstanceStep pis : pi.Steps) {
            if (pis.ActorId != null) {
                results.get(pi.TargetObjectId).add(pis.ActorId);
            }
        }
    }
    
    return results;
}

 

I have some Apex code that creates a Component.Apex.PageBlockSection containing many Component.Apex.InputField objects. This works fine when invoked from an apex:dynamicComponent tag in a Visualforce page.

 

But when I run the code in this test to ensure that there are not any exceptions and to add to the code coverage total I get the "An internal server error has occurred" error page:

 

@isTest
private class DetailsDynamicComponentFactoryTest {
    @isTest
    static void test() {
    	System.assertNotEquals(null, new DetailsDynamicComponentFactory(true, true, true, true, true).create('Details', true));
    }
}

 

Has anyone succeeded in running such code from a test?

 

Thanks,

Keith

A colleague wrote a working trigger today in which he included a method definition. Here is a contrived example that is similar to what he wrote:

trigger XXXX on Contact (after update) {

    String s = getString();
    System.debug('>>> string is ' + s);
    
    String getString() {
        System.debug('>>> getString called');
        return 'abcdef';
    }
}

 Does anyone have any insight into this capability? Is it accidental or by design? Is it documented anywhere?

 

Thanks,

Keith

I have some logic that relies on the Last Modified Date of an SObject and so in my tests need to create objects where these dates reliably differ. Given that AFAIK there is no sleep method available I am using the code below to idle away time but would be interested to know if anyone has found a better approach e.g. an API call that reliable takes many milliseconds to execute and so provides a better "delay per script statement" ratio?

 

Thanks,

Keith

 

private static void delayUntilTimeChanged() {

    Integer msPerS = 1000;
    Datetime start = Datetime.now();
    Datetime current = Datetime.now();

    // No sleep available so this ugliness
    Integer counter = 0;
    while ((current.getTime() / msPerS) == (start.getTime() / msPerS)) {
        
        // This code takes about 250ms or more on na3
        Long t1 = System.currentTimeMillis();
        String bigRandomString = '';
        for (Integer i = 0; i < 2000; i++) {
            bigRandomString += Crypto.getRandomLong();
        }
        for (Integer i = 0; i < 50; i++) {
            Blob cryptoKey = Crypto.generateAesKey(256);
            Blob data = Blob.valueOf(bigRandomString);
            Blob encryptedData = Crypto.encryptWithManagedIV('AES256', cryptoKey, data);
            Blob decryptedData = Crypto.decryptWithManagedIV('AES256', cryptoKey, encryptedData);
        }
        Long t2 = System.currentTimeMillis();

        System.debug('>>> delayUntilTimeChanged delayed for ' + (t2 - t1) + ' ms'
                + ', Count ' + counter
                + ', ScriptStatements ' + Limits.getScriptStatements() + ' of ' + Limits.getLimitScriptStatements()
                + ', CpuTime ' + Limits.getCpuTime() + ' of ' + Limits.getLimitCpuTime()
                );
        
        counter++;
        current = Datetime.now();
    }
}

 

I have a customer that wants a profile that only allows certain (less important) Contact fields to be edited such as phone numbers while important Contact fields like first and last name should not be editable. At first sight, enabling editing at the object level and then enabling editing at the field level looks like the way to go.

 

But when I look at the field-level security (FLS) settings the checkboxes for Contact.Name cannot be modified so the related Contact.FirstName and Contact.LastName fields are always editable when a Contact is displayed using the profile. (Name fields on other objects that are not auto-numbered appear to share this issue.)

 

If you can offer any insight into what I'm missing here please comment. Because otherwise the handling of the Name field seems like a major deficiency in the FLS design.

 

Thanks,

Keith

 

 

 

 

I have a controller and a set of default wizard pages that use that controller in a managed package. I have added a custom setting to the managed package to allow one of the default pages to be replaced. The intention is to allow a developer building on the managed package to replace that page in their org with a custom version but still use the controller in the managed package (that has global methods).

 

When I run using the default page (that is in the managed package) everything works suggesting that the profile including the Field Level Security (FLS) settings is correct.

 

But when I run using a copy of the default page only changed to add the managed package namespace prefixes (that is not in the managed package) while a non-SObject field is rendered all SObject fields (including fields on the User object) from SObjects returned by the controller are rendered.

 

Any insights into what is going on here or what I might be missing would be appreciated.

 

Keith

 

PS With further debugging, this is now looking like a wizard-specific problem. In a wizard, multiple pages share an instance of a controller so that view state is carried from one page to the next. But it appears that when the custom page opens it gets a new instance of the controller rather than the existing one and so various SObject references are null because the selections made in the earlier pages have been lost. Can anyone confirm this behaviour and offer and work-arounds?

I have a couple of wizards each with half a dozen or so pages in them. The "View State" that can be shown in "Development Mode" looks very useful.

 

But I have the problem that the "Development Mode" output only appears for the first two pages and is then lost. The URLs that appear for the first three pages are below and I note that it is when core.apexpages.devmode.url=1 is appended to the URL that the "Development Mode" page section no longer appears:

 

Hints on how to get the "Development Mode" output across all the wizard pages would be appreciated.

 

Thanks,

Keith

 

PS The problem occurs with both Chrome and Safari.

I have a production org with 85M bytes of "Feed Tracked Changes" data in it and I want to recover that space. (I assume the volume is large because I  have run a legacy data delete/import many times to work on a number of conversion bugs.)

 

I have not found any explanation of how to delete in these articles:
and this post on the subject remains unanswered:
Can anyone explain how to delete the "Feed Tracked Changes" data?
Keith

 

Threads like Package install fail: missing feature apex class discuss editions that do and do not allow Apex source code to run. (Apex code in a managed package is treated somewhat differently.)

 

Can anyone point me to a data sheet that describes this capability for "Force.com Embedded Edition" licenses?

 

Thanks,

Keith

Instead of being automatically authenticated and ending up at the https://help.salesforce.com/apex/hthome page, our trial org users are being taken to a login page when they click on the "Help & Training" link.

 

Is this by design, and when their licenses are converted from "Trial" to "Active" the link will start working as expected?

 

Thanks,

Keith

Documentation like Understanding Execution Governors and Limits says that a managed package has a set of governor limits that are separate from the governor limits applied to the non-packaged source code in an org. This is the behavior we see in developer edition orgs: numbers are reported for the managed package(cve namespace) and non-packaged source code (default namespace) separately and no limits are exceeded and our tests all pass.

 

But after an upgrade of an org that we setup for a customer starting from a Trialforce snapshot, the counting appears to be combined and reported only under the non-packaged source code (default namespace) so that limits are exceeded and some of our tests fail.

 

Can anyne offer any insight into this problem? Below are fragments of debug log output that illustrate the problem. (There is mention of the cve managed package in both logs, just not in this fragment for the problem org.)

 

Thanks,

Keith

 

 

From the working (developer edition org):

 

 

02:22:24.379|CUMULATIVE_LIMIT_USAGE
02:22:24.379|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 0 out of 100
Number of query rows: 0 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 5 out of 150
Number of DML rows: 5 out of 10000
Number of script statements: 189 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

02:22:24.379|LIMIT_USAGE_FOR_NS|cve|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 1 out of 150
Number of DML rows: 1 out of 10000
Number of script statements: 442 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

02:22:24.379|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
02:22:24.379|STATIC_VARIABLE_LIST|
BusinessLogicBase:MONTHS:126
PaymentSpecificationPopulatorTest:BASE:4
PaymentSpecificationPopulatorTest:LUMP_SUM:8
PaymentSpecificationPopulatorTest:MONTHLY:7
PaymentSpecificationPopulatorTest:SCALE:4
PaymentSpecificationPopulatorTest:TODAY:4

02:22:24.379|CUMULATIVE_LIMIT_USAGE_END

 

 

From the failing (customer org:

 

 

01:35:40.307|CUMULATIVE_LIMIT_USAGE
01:35:40.307|LIMIT_USAGE_FOR_NS|(default)|
Number of SOQL queries: 6 out of 100
Number of query rows: 6 out of 50000
Number of SOSL queries: 0 out of 20
Number of DML statements: 6 out of 150
Number of DML rows: 6 out of 10000
Number of script statements: 631 out of 200000
Maximum heap size: 0 out of 3000000
Number of callouts: 0 out of 10
Number of Email Invocations: 0 out of 10
Number of fields describes: 0 out of 100
Number of record type describes: 0 out of 100
Number of child relationships describes: 0 out of 100
Number of picklist describes: 0 out of 100
Number of future calls: 0 out of 10

01:35:40.307|TOTAL_EMAIL_RECIPIENTS_QUEUED|0
01:35:40.307|STATIC_VARIABLE_LIST|
BusinessLogicBase:MONTHS:130
PaymentSpecificationPopulatorTest:BASE:8
PaymentSpecificationPopulatorTest:LUMP_SUM:8
PaymentSpecificationPopulatorTest:MONTHLY:7
PaymentSpecificationPopulatorTest:SCALE:4
PaymentSpecificationPopulatorTest:TODAY:8

01:35:40.307|CUMULATIVE_LIMIT_USAGE_END

 

 

I have a controller - lets call it the PdfController with a PdfPage - that will create a PDF representation of an object. This controller accepts an id parameter to specify the object instance.

 

But I now have a requirement to create and attach the PDF at the time the object is created - lets call that controller the CreateController.

 

My first thought was to invoke an @future method at the end of the CreateController. (Lets ignore timing issues for now.) This would pass the object id in the PageReference parameters and then call Page.PdfPage.getContent() to get the PDF bytes and then attach them. But getContent() is documented to not work in @future methods. Presumably the issue is that the execution is asynchronous and so is essentially a separate session. There are classes like Http and HttpRequest available that could be used to create a new session and invoke on that but I have never found an example of how to establish a session to the HTML interface of Force.com from Apex and suspect that this would require a copy of the credentials even if it was possible (unless there is some session id trick possible).

 

If the Page.PdfPage.getContent() is directly invoked from the CreateController the object is not available because the transaction has not committed. And there is no explicit commit call available to force the commit beforehand.

 

So I don't think this requirement can be satisfied on Force.com but would be very happy to be corrected - please comment.

 

Thanks,

Keith

I have a side bar component written in Visualforce that is only relevant to one of my apps and would like its output to only be present when that app is selected. I can also imagine other use cases where knowing the currently selected app would be useful.

 

Anyone know if this information can be obtained in Apex code?

 

Thanks,

Keith

Hi,

 

When im deploying one premission set with one custom app premission it is not deploying throwing error as :

 


# Deploy Results:
   File Name:    permissionsets/SSR_Holdings_Permission_Set.permissionset
   Full Name:  SSR_Holdings_Permission_Set
   Action:  NO ACTION
   Result:  FAILED
   Problem: Unknown user permission: AllowDeleteDandBCompany

 

Plz Advice

I predominantly use system.debug to print out debug messages. I have noticed recently that if the LogLevel for apex code is set to debug, there are several messages printed in the log such as the following. These messages seems irrelevant and obscure the real messages.

08:47:01.221 (221465000)|ENTERING_MANAGED_PKG|
08:47:01.223 (223142000)|ENTERING_MANAGED_PKG|
08:47:01.223 (223247000)|ENTERING_MANAGED_PKG|
08:47:01.223 (223283000)|USER_DEBUG|[25]|ERROR|Entering Insert

 

I have resorted to using

System.debug(Logginglevel.ERROR, 'Message') and  setting the loglevel of ERROR to prevent these messages from showing. However, I was wondering if there was any other means to suppress these messages (without changing log level). Frankly these messages seem to be useless since they are not conveying anything at all.

  • May 29, 2012
  • Like
  • 0
<apex:repeat value="{!sectionOrder}" var="order">
    <apex:outputPanel layout="none" rendered="{! order == 'Reference' }">
        <apex:pageBlock title="Reference">
            <apex:pageBlockButtons location="top">
                <apex:commandButton reRender="??? what goes here to get the EligibilityPageBlock re-rendered ???"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:outputPanel>
    <apex:outputPanel layout="none" rendered="{! order == 'Synopsis' }">
        <apex:pageBlock title="Synopsis">
        </apex:pageBlock>
    </apex:outputPanel>
    <apex:outputPanel layout="none" rendered="{! order == 'Eligibility' }" id="EligibilityOutputPanel>
        <apex:pageBlock title="Eligibility" id="EligibilityPageBlock">
        </apex:pageBlock>
    </apex:outputPanel>
    <!-- More similar panels -->
</apex:repeat>

The above illustrates how I am controlling the order that some apex:pageBlocks are output by having a sectionOrder list provided by the controller. Introducing this re-ordering has however broken some reRender logic that I had, perhaps because the full ids in the generated page now include the apex:repeat index of 0, 1, 2 etc.

 

I am unclear about how the id supplied in reRender is resolved back to the full id in the page. Any insight into whether there is a way to get partial page re-rendering to work in the above situation would be appreciated.

 

Thanks,

Keith

I have some Apex code that creates a Component.Apex.PageBlockSection containing many Component.Apex.InputField objects. This works fine when invoked from an apex:dynamicComponent tag in a Visualforce page.

 

But when I run the code in this test to ensure that there are not any exceptions and to add to the code coverage total I get the "An internal server error has occurred" error page:

 

@isTest
private class DetailsDynamicComponentFactoryTest {
    @isTest
    static void test() {
    	System.assertNotEquals(null, new DetailsDynamicComponentFactory(true, true, true, true, true).create('Details', true));
    }
}

 

Has anyone succeeded in running such code from a test?

 

Thanks,

Keith

I've created this test controller to illustrate my problem

 

public class TestController {
	List<Object_A__c> Aobjects { get; set; }
	List<Object_B__c> Bobjects { get; set; }

	public TestController() {
		//assign values to the a and b lists
	}

	public PageReference pageAction() {
		Savepoint sp = Database.setSavepoint();
		try {
			//Assume this dml operation succeeds
			insert Aobjects;
			//assume this dml operation fails
			insert Bobjects;
		} catch(System.DmlException e) {
			Database.rollback(sp);
			ApexPages.addMessages(e);
		}
	}
}

 

When the pageAction is called and there is a rollback because of a problem with 'B objects', the list of 'A Objects' still have Id values.

 

This becomes a problem when the pageAction is called a second time, because the 'A objects' have Ids and an insert is performed, giving the error: Record ID: cannot specify Id in an insert call

 

What is the best way to solve this?

        Hi,I'd like to get the version number of a managed package, which installed in a salesforce org, from a Java application through Apex Web Service API, is there any workaround?


        In more detail:
        1. Create a managed package.
        2. Use the Install URL to install this managed package to another dev org.
        3. Get the version number of the managed package, which installed in the dev org, from a Java application through Apex Web Service API.

        I find in the force.com's schema, there is an object apexPackage, but the version number is the APIVersion of the salesforce, eg:19, 21...   but not the package's version number, like 1.2.4, 1.4.2 and so on.

        I also have sent a email to the salesforce support, this is the response, but not what i want:

        /*********************************
            I understand that you want to get the version number of a managed package installed in salesforce. I have located the following possible solution that may be able to guide you.

           Click Your Name | Setup | Create | Packages and click the name of a package to view its details, including any added components, whether it is a managed package, if the package has been uploaded, and so on.
The detail page has the following sections:

           * Package details
           * Package components
           * Remote access
           * Development organizations
           * Version history
       **********************************/

       Thanks for any respone!

Hi Friends,

I have created one approval process and in Final Approval Actions there are three email alerts.

How to control the order of execution.

I have tried by removed all the email alerts and add them in alphabetical order based on Email Alert Name but there is no use.

 

Please post any ideas.

 

Thanks,

Indy

 

 

  • February 03, 2011
  • Like
  • 0

I am getting a strange error message as above.

 

I have an interface {say A} which has one method. I have a class {say B} that implements the interface (the method). And I have another class/method that takes interface A as a parameter. And I call that method with an instance of the class B. All compiles ok. But I got the error when running it.

 

I do not see what can possibly be wrong with my code. If I do not implement the method in A, it fails to compile. If I remove 'implements A' from B, it fails to compile. Also I have another class {C} that implements the interface A, and is used in exact same way and it works fine.

 

Anyone has seen similar issues?

 

 

 

 

 

 

Hi

 

 Custom Setting List ,Name field if we enter more then 5 Double byte char then it gives error
Sample data
  関根 秀治

 

 Is there any restriction in Name field ? For Single bytes its accepting 38 Char.

 

 It seems 1 double bytes its calculating 9 char .So we can enter 4 Double bytes and 2 Char like this.

 

 

An internal server error has occurred
An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 1700040002-861 (91623632)

 

 

Thanks and Regards

Thanga

Hi, We have customised salesforce functionalities using VisualForce. I am experiencing poor Performance of these pages. The pages loads up quite slowly compared to standard salesforce pages.  What could be the reason for such slow responses? Any help in this regard will be highly appreciated . I am also looking for a ways to check the page-size when they load up on the client. What could be the easiest way to do so.

 

I would like to know if anyone else has faced similar issues.

 Thanks  Shabs Moiyed

 

First let me begin by stating that I am a beginner. Apex is the first language I have tried to learn, and I have only been trying for a few months.

I am trying to create a controller class for a page that allows the user to create records of packages that were sent via mail. When creating a new mail package the user will need to be able to select from the multiple contracts that could be included in the package. I want to override the save button so that when a new package is saved the files that are included in the package are automatically created in a Mailed Package File object. I know that my save button is working because it works if I do not select any files for the package. However, if I try to select one or more files I receive the error "Conversion Error Setting Values."  This confuses me because I thought I was working with IDs. I tried to convert the data type to string but received the same error. Any help would be much appreciated
Code:
public class Mailed_Package_Controller {
 
 public Mailed_Package_Controller(ApexPages.StandardController Controller){
  this.MP = (MailedPackage__c)controller.getRecord();
 }
  
 
 public MailedPackage__c MP;
 
 public List<ID> selectedFiles {get;set;}
 
 public List<SelectOption> getFileOptions(){
  List<SelectOption> Filefeed = new List<SelectOption>();
  File__c[] A = [select ID, Name from File__c Order By LastModifiedDate];
  for (File__c f : A){
   Filefeed.add(new SelectOption (f.ID, f.Name));
  }  
  return Filefeed;
  }
 
   
 /* next you need a save method that overrides the default save method
 it needs to create the Mailer Package
 retrieve the id of the mailer package 
 then iterate through the list of selected file IDs
 and for each file ID create a !!! mailed Package File record !!!
 where the package ID is that of the mailer package
 and the file ID is the current ID in the list of selected file IDs
 */
   
  
 public List<MailedPackageFile__c> MPFs = new List <MailedPackageFile__c>();
 
 public void newMPF(){
  MailedPackageFile__c MPF = new MailedPackageFile__c();
  for (ID c : selectedFiles){
   MPF.File__c = c;
   MPF.MailedPackage__c = this.MP.Id;
   MPFs.add(MPF);
  }
 }
   
 public PageReference save(){
  try { 
   insert this.MP;
  } catch (Exception e){}
   
  newMPF();
  insert MPFs;
  PageReference MPpage = new PageReference('/'+MP.ID);
  MPpage.setRedirect(true);
  return MPpage; 
    
 }
 
 
}

 

  • October 02, 2008
  • Like
  • 0
In http://wiki.apexdevnet.com/index.php/Tabbed_Accounts_in_30_seconds
I've done the same for my custom object and it works pretty good.
On mine I have defined  TAB-A, TAB-B, TAB-C
I have extension controller code getting called on one of my extra Tabs (TAB-B) and that works fine too.

However I want it to return the user exactly where they were (in TAB-B) but I cannot find what that tab reference/url is.
It appears to be a Frame with a hidden field (j_id0:CaseTabPanel=TAB-B)

Any ideas on how I'd re-render that back from my controller (via PageReference ?)

Thanks
Lal
Hi guys,

I'm experiencing some unexpected behavior when trying to use the apex:repeat function to render tabs....

Basically it seems that tabs cannot be created on demand?  My controller is definitely returning data... as the second page block in my sample will show... repeat works - just the tabs are not rendered..

I'm sure any of you guys can see where I was going with this - and I guess I can achieve a similar result by dropping down to boring old html - just trying to use the standard components (as per best practice)

Any assistance greatly appreciated - as the purist coder me is seriously disturbed at the moment...

here is my 'simplified' and easily testable page & controller

Code: VF PAGE
<apex:page controller="clsRecordType">
    <apex:pageBlock >
        <apex:tabPanel id="theTabPanel">
            <apex:tab label="Account Types"/>
            <apex:repeat value="{!RecordTypes}" var="types">
                <apex:tab label="{!types.Name}"/>     
            </apex:repeat>
        </apex:tabPanel>
    </apex:pageBlock>

    <apex:pageBlock >
        <apex:repeat value="{!RecordTypes}" var="types">
            {!types.Name}<br/>       
        </apex:repeat>
    </apex:pageBlock>
</apex:page>

and the controller

Code:
public class clsRecordType {

    list<RecordType> lrecordtypes;

    public list<RecordType> getRecordTypes() {
        if(lrecordtypes==null) lrecordtypes = [Select Name, Id, Description From RecordType  where SobjectType = 'Account' and IsActive=True];
        return lrecordtypes;
        }
   }

 
 

I'm having trouble setting the selectedTab attribute of a tabPanel dynamically.  It works fine if I set selectedTab to a string in the visualforce page, but if I try and use something set by the controller it doesn't work.  Am I missing something obvious or is there an issue with the tabPanel tag?  

Controller:

Code:
public class testTabController {
 String tabInFocus = System.currentPageReference().getParameters().get('tab');
 public String getTabInFocus() {
  return tabInFocus;
 }
 public void setTabInFocus( String s ) {
  this.tabInFocus = s;
 }
}

 Page:
Code:
<apex:page controller="testTabController" sidebar="false" showheader="true">

 <p>tabInFocus: &lt;{!TabInFocus}&gt;</p>
 <apex:tabPanel switchType="client" selectedTab="{!TabInFocus}" id="testTabs">
  
  <apex:tab label="Label 1" name="oneTab" id="tab1" >
   <p>This is number one</p>
  </apex:tab>
  
  <apex:tab label="Label 2" name="twoTab" id="tab2" >
   <p>This is number two</p>
  </apex:tab>
  
  <apex:tab label="Label 3" name="threeTab" id="tab3" >
   <p>This is number three</p>
  </apex:tab>
  
 </apex:tabPanel>

</apex:page>

URL:
Code:
/apex/test_tab?tab=twoTab

 


 
The tab is selected properly if I use a static string, e.g.:

Code:
<apex:tabPanel switchType="client" selectedTab="twoTab" id="testTabs">

 
Any ideas?