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
Walter@AdicioWalter@Adicio 

Can I navigate user to named anchor across different pages?

I dont know if there is a better way to do what I want but this is what I am doing.

 

I have a page with a dataTable. there is a link for each record to open that record in a "thickbox" popup. so far i can only get the changes made to the record in the "thickbox" to pass back to the original page by making a second page to use the same controller as the first page and i load the second page into an iFrame in the "thickbox" with the information for the record i want to change. when you save it just returns you to the first page. this works fine.

 

What i want to do is after the user clicks save in the "thickbox" i want the opener page to navigate back to the specific record in the dataTable that i edited. a named anchor like behavior.

 

This is how i wrote it and why i am having a problem doing this. also please let me know if this is just a pure javascript issue and if i should post somewhere else. im reading in several places where it looks like i might be able to do this with javascript but i am posting here to make sure there isnt a completely different approach to my apex which can get this done before i start working on the javascript to do it.

 

ive taken out as much as i can to only show the fuctionality, removing styles and other visual details.

 

the datatable and edit link looks like this...

 

<apex:dataTable value="{!editlineItems}" var="item">

<apex:column>
{!item.prod.name}
</apex:column>

<apex:column>
<apex:commandLink target="theiframe2" onclick="openOnload()"						value="Edit" action="{!editProductDescription}">
<apex:param name="pdesc" value="{!item.index}" />						
</apex:commandLink>
</apex:column>

</apex:dataTable>

 

 

the thickbox looks like this...

 

<div id="open-onload" style="display:none;position:absolute;top:0px;left:0px;">
	<div style="border: solid 1px white">
		<div style="border: solid 1px #62aac1">
			<div id="document-ta">
				<apex:iframe src="#" id="theiframe2" height="590px" width="100%" />
			</div>
		</div>
	</div>
</div>

 

 here is how the thickbox is opened...

 

    function openOnload()
    {
      	var document_ta = document.getElementById('document-ta').innerHTML;

        var t = null;
        var a = '#TB_inline?height=600&width=600&inlineId=open-onload&modal=true'; 
        var g = false;
        
        tb_show(t, a, g);
    }  

 

here is how i load the second page into the iFrame in the thickbox...

 

 

public pageReference edit()
{	
// get the sepcific record to work on	
string editname = ApexPages.CurrentPage().getParameters().get('pdesc');	
Integer i = Integer.valueOf(editname);

// make a copy of the index for the record the user is editing
// so i can work on the same record from another method
workingQuoteLineIndex = i;  	

// get the text i want to edit
customProductDescription = editlineItems.get(i).quoteLine.Description__c;

// open the page with the WYSIWYG editor
return Page.page2;
}

 

 

here is how i save the changes in the thickbox and send the user back to the first page...

 

public pageReference saveProductDescription()
{
// update the record to take the value from the editor in the popup
editLineItems.get(workingQuoteLineIndex).quoteLine.Description__c = customProductDescription;

// send the user back to page 1
return Page.page1;

}

 

 *** At this point I want to user go get sent back to the specific record they edited in the dataTable.

 

 

 I know I can do this with javascript but  here is where I am wondering if a different approach via APEX can get this done...

 

 

 If i was sending the user to a new pageReference I could store the anchor value before opening the popup and then use the same anchor when sending them back to the opener window. something like this...

 

 

public pageReference saveProductDescription()
{
pageReference page = new pageReference('/apex/page1#' +storedAnchorValue );
return page;
}

 

If the new pageRerence approach is possible i need help understading how i maintain the " state " of the application when I do not use navigation like this...

 

return page.page1;

 

 what i mean is if the user works in the application and makes a bunch of changes, those changes are lost if i just send them to a new pageReference.

 

should i be working on passing the state of my datatable between the pages in the controller?

 

here is the inner class...

 

// the innerClass for products
public class productWrapper
{
public integer index {get; set;} 
public product2 prod {get; set;}
public boolean selected {get; set;}	
public SFDC_520_QuoteLine__c quoteLine {get; set;}
}

 

my list is of innerClass records....

 

public list<productWrapper> editlineitems {get; set;}
{return editlineitems;}

 

 what i need help understanding is how i pass a named anchor via a new page reference AND maintain the state of the entire application. the application has many objects and values sitting in memory while the user works on it.