• newVFdev
  • NEWBIE
  • 0 Points
  • Member since 2011

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

Hi,

I have an event standart edit page and event view page in VF. Nowe when I create a new event and try to redirect after save I use this method:

  public PageReference redirect()
    {
        String recordType = ApexPages.currentPage().getParameters().get('RecordType');
        String what_id = ApexPages.currentPage().getParameters().get('what_id');
        String who_id = ApexPages.currentPage().getParameters().get('who_id');
     String eventId=ApexPages.currentPage().getParameters().get('id');
   
     System.debug('event id>>>'+eventId);
     if (eventId==null)
     eventId='';
     else
     eventId = eventId.replace('newid', 'id');
     
        if(recordType==null)
            recordType=''; 
       
        if(what_id == null)
            what_id = '';
           
        if (who_id == null)
            who_id = '';
           String str;
    //Changed on Sept 20/2011 redirecting to the parent object

  
        if(ApexPages.currentPage().getParameters().get('what_id')==null&&ApexPages.currentPage().getParameters().get('who_id')==null)
        {
   
            str='/00U/e?retURL=%2Fhome%2Fhome.jsp&saveURL=/apex/eventview?'+eventId+'&cancelURL=%2Fhome%2Fhome.jsp&ent=Event&nooverride=1&RecordType='+recordType+'&00N20000001kXCH='+replaceStr(userData.Business_Group__c)+'&00N20000001kXCL='+replaceStr(userData.Business_Unit__c)+'&00N20000001kXCR='+replaceStr(userData.User_Subdivision__c)+'&00N20000001kXCQ='+replaceStr(userData.User_Division__c)+'&what_id='+ what_id+'&who_id='+ who_id;
            //str= str.replace('newid','id');
           
           
            // str='/00U/e?retURL='+ ApexPages.currentPage().getParameters().get('what_id')+'&cancelURL=%2Fhome%2Fhome.jsp&ent=Event&nooverride=1&RecordType='+recordType+'&00N20000001kXCH='+replaceStr(userData.Business_Group__c)+'&00N20000001kXCL='+replaceStr(userData.Business_Unit__c)+'&00N20000001kXCR='+replaceStr(userData.User_Subdivision__c)+'&00N20000001kXCQ='+replaceStr(userData.User_Division__c)+'&what_id='+ what_id+'&who_id='+ who_id;
        }

......

now when I save my event I get the following url

https://c.cs4.visual.force.com/apex/eventview?newid=00UP0000001gaxS

 

how come the key "newid " instead of Id how can I replace this world with "id"

I tried to use the replace string but irt doesn't work either.

Your help is very much appreciated!

newVFdev

Hi there,

I am trying to redirect one recordtype to visualforce and other recordtypes to standard page...

I modified my Apex:page haeder  like this:

 

<apex:page standardController="Opportunity"
    extensions="ActionEditController" id="page"
    action="{!if((Opportunity.Id=null),
                if(($CurrentPage.parameters.RecordType != '012200000002Hdg'),urlfor('/006/e',null,[RecordType=$CurrentPage.parameters.RecordType],true),'' ),
    if(($CurrentPage.parameters.RecordType != '012200000002Hdg'),urlfor('/006/e',null,[id=Opportunity.Id],true),URLFOR($Page.ActionEdit, Opportunity.id)))}">

 

 

 when I open an existing record type  it should redirect me to a visualforce page " ActionEdit" if the recordtype is  '012200000002Hdg' now when I open that record type, it  open a standard page '/006/e...'

what is wrong in  my logic?

 

I was trying to implement the same logic in controller so it should be easier. but I get the following error:

Invalid root component None found in view /apex/ActionEdit?id=006R0000006x4I7IAI

 

my controller code:

 

  public PageReference redirectToPage() {
         if(action.Id==null)
        {
            if(getIsARPRecordtype())
            {
                return Page.ActionEdit.setRedirect(true);
            }
            else
            {
                return new PageReference('/006/e?nooverride=1');
            }
        }
        else
        {
            if(getIsARPRecordtype())
            {
                PageReference editPage = new PageReference('/apex/ActionEdit');
                editPage.getParameters().put('id',action.Id);
                    return editPage;
            }
            else
            {
                return new PageReference('/006/e?id='+action.id+'nooverride=1');
            }
        }
        
    
    }

 

thank you for your help!

 

Hi,

I have an event standart edit page and event view page in VF. Nowe when I create a new event and try to redirect after save I use this method:

  public PageReference redirect()
    {
        String recordType = ApexPages.currentPage().getParameters().get('RecordType');
        String what_id = ApexPages.currentPage().getParameters().get('what_id');
        String who_id = ApexPages.currentPage().getParameters().get('who_id');
     String eventId=ApexPages.currentPage().getParameters().get('id');
   
     System.debug('event id>>>'+eventId);
     if (eventId==null)
     eventId='';
     else
     eventId = eventId.replace('newid', 'id');
     
        if(recordType==null)
            recordType=''; 
       
        if(what_id == null)
            what_id = '';
           
        if (who_id == null)
            who_id = '';
           String str;
    //Changed on Sept 20/2011 redirecting to the parent object

  
        if(ApexPages.currentPage().getParameters().get('what_id')==null&&ApexPages.currentPage().getParameters().get('who_id')==null)
        {
   
            str='/00U/e?retURL=%2Fhome%2Fhome.jsp&saveURL=/apex/eventview?'+eventId+'&cancelURL=%2Fhome%2Fhome.jsp&ent=Event&nooverride=1&RecordType='+recordType+'&00N20000001kXCH='+replaceStr(userData.Business_Group__c)+'&00N20000001kXCL='+replaceStr(userData.Business_Unit__c)+'&00N20000001kXCR='+replaceStr(userData.User_Subdivision__c)+'&00N20000001kXCQ='+replaceStr(userData.User_Division__c)+'&what_id='+ what_id+'&who_id='+ who_id;
            //str= str.replace('newid','id');
           
           
            // str='/00U/e?retURL='+ ApexPages.currentPage().getParameters().get('what_id')+'&cancelURL=%2Fhome%2Fhome.jsp&ent=Event&nooverride=1&RecordType='+recordType+'&00N20000001kXCH='+replaceStr(userData.Business_Group__c)+'&00N20000001kXCL='+replaceStr(userData.Business_Unit__c)+'&00N20000001kXCR='+replaceStr(userData.User_Subdivision__c)+'&00N20000001kXCQ='+replaceStr(userData.User_Division__c)+'&what_id='+ what_id+'&who_id='+ who_id;
        }

......

now when I save my event I get the following url

https://c.cs4.visual.force.com/apex/eventview?newid=00UP0000001gaxS

 

how come the key "newid " instead of Id how can I replace this world with "id"

I tried to use the replace string but irt doesn't work either.

Your help is very much appreciated!

newVFdev

Hi there,

I am trying to redirect one recordtype to visualforce and other recordtypes to standard page...

I modified my Apex:page haeder  like this:

 

<apex:page standardController="Opportunity"
    extensions="ActionEditController" id="page"
    action="{!if((Opportunity.Id=null),
                if(($CurrentPage.parameters.RecordType != '012200000002Hdg'),urlfor('/006/e',null,[RecordType=$CurrentPage.parameters.RecordType],true),'' ),
    if(($CurrentPage.parameters.RecordType != '012200000002Hdg'),urlfor('/006/e',null,[id=Opportunity.Id],true),URLFOR($Page.ActionEdit, Opportunity.id)))}">

 

 

 when I open an existing record type  it should redirect me to a visualforce page " ActionEdit" if the recordtype is  '012200000002Hdg' now when I open that record type, it  open a standard page '/006/e...'

what is wrong in  my logic?

 

I was trying to implement the same logic in controller so it should be easier. but I get the following error:

Invalid root component None found in view /apex/ActionEdit?id=006R0000006x4I7IAI

 

my controller code:

 

  public PageReference redirectToPage() {
         if(action.Id==null)
        {
            if(getIsARPRecordtype())
            {
                return Page.ActionEdit.setRedirect(true);
            }
            else
            {
                return new PageReference('/006/e?nooverride=1');
            }
        }
        else
        {
            if(getIsARPRecordtype())
            {
                PageReference editPage = new PageReference('/apex/ActionEdit');
                editPage.getParameters().put('id',action.Id);
                    return editPage;
            }
            else
            {
                return new PageReference('/006/e?id='+action.id+'nooverride=1');
            }
        }
        
    
    }

 

thank you for your help!

 

I am trying to use Visualforce page for one record type. I have overrrieden the standard page with a link in a visualforce pages and that works well.

 


I am having problems with the Save button. When I try to save it keeps refreshing the edit page:
in my Edit page:
<apex:page standardController="Opportunity"
extensions="ActionEditController" id="page" action="{!if($CurrentPage.parameters.RecordType != '012P00000004OyQ',urlfor('/006/e',null,[RecordType=$CurrentPage.parameters.RecordType],true),'')}">

The save button as follow:
<apex:commandButton onclick="PicklistsAndValidate();"
action="{!save}" value="Save" />


When I create a new record, I get the VF page, but when I click on save, nothing happens!

 

I would appreciate help on this!

  • May 25, 2011
  • Like
  • 0

I am working through some ViewState issues and I have a question.  I use the following paradigm regularly in my development and want to know how I am contributing to the ViewState.

 

I often keep data in the controller in a private list of a custom wrapper class.

 

private list<myClass> allMyClass = new list<myClass>();

 

I will often have several "get-only" properties that pull back subsets of list data.

 

public list<string> subset1MyClass	{
	get{
		list<string> tmpList = new list<string>();
		for (myClass m : allMyClass){
			if (m.property1 == true){
				tmpList.add(m);
			}
		}
		return tmpList;
		}
	} 
public list<string> subset2MyClass	{
	get{
		list<string> tmpList = new list<string>();
		for (myClass m : allMyClass){
			if (m.property2 == true){
				tmpList.add(m);
			}
		}
		return tmpList;
		}
	} 

 

 

It is these get-only properties that I use to make pageBlockTables and the like.  They are the public facing lists from my controller.

 

Since subset1MyClass and subset2MyClass are Getter methods, I cannot make them transient.

 

What I want to know is whether subset1MyClass and subset2MyClass contribute to View State.

  • April 07, 2010
  • Like
  • 0