1

So I have an outputLink that is styled to look like a button. It is essentially a delete button so whenever it is pushed a selected custom object (Relationship_Detail__c) is deleted. The button functions somewhat properly because the object is indeed deleted. However I am receiving an odd URL message saying that the URL no longer exists. I will attach a screenshot of the error message and here is the outputLink code

<apex:outputLink styleClass="btn" target="_top" value="{!URLFOR($Action.Relationship_Detail__c.Delete, selectedDetail)}" rendered="{!IF(BEGINS(selectedId, '00'), true, false)}">
    <apex:outputText value="Delete"/>
</apex:outputLink>

enter image description here

0

I ended up changing from an outputLink to a commandLink and making a delete method within my extension controller.

<apex:commandLink style="font-size:125%" styleClass="btn" action="{!DeleteRelationship}" value="Delete" rendered="{!IF(BEGINS(selectedId, '00'), true, false)}" reRender="Everything"/>

and the method

public void DeleteRelationship(){
  delete selectedDetail;
  boolean foundIt = false;
  Integer i=0;
  Integer relationshipSize = relationships.size();
  while(!foundIt && i<relationshipSize){
      if(relationships[i] == selectedDetail){
          foundIt = true;
          relationships.remove(i);
      }
      i += 1;
  }
  selectedDetail = null;
  selectedId = null;
}

Essentially I make a database call to remove the custom object from the database, then I search through the list of all of the custom objects, find the one I am looking for and remove it from the list. I finish by setting the variables that held information on that object to null

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.