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
Mitesh SuraMitesh Sura 

need help with Component.Apex.outputLink

Looks like I am missing the name attribute for outputLinks, but there is no such thing as name fot the tag.

 

Like you see in the code I tried "link.expressions.Value" too.

 

public Component.Apex.OutputPanel getLinks(){
		Component.Apex.OutputPanel pnl = new Component.Apex.OutputPanel();
		for(string id : recentItems) {
			
			Component.Apex.outputLink link = new Component.Apex.outputLink(value='/'+id, title=id);		
			//link.expressions.Value = '/{!id}';	This does not work either
			pnl.childComponents.add(link);	
		}
		return pnl;
    } 

 I see the links if I do inspect element, but they are not displayed on the page.

 

<span id="j_id0:j_id1:j_id6_0">
  <a href="https://na9.salesforce.com/001E000000iWHSLIA4" title="001E000000iWHSLIA4"></a>
  <a href="https://na9.salesforce.com/001E000000iWHSMIA4" title="001E000000iWHSMIA4"></a>
</span>

 

What am i missing here?

 

Thanks in advnace.

Best Answer chosen by Admin (Salesforce Developers) 
Mitesh SuraMitesh Sura

Thanks Ashlekh. 

 

I modified the code, because hand icon won't be shown when you hover. Also they were in straight line. 

 

public Component.Apex.OutputPanel getLinks(){
		Component.Apex.OutputPanel pnl = new Component.Apex.OutputPanel();
		for(string id : recentItems) {
			Component.Apex.outputPanel pnl1 = new Component.Apex.outputPanel(layout='block');
			Component.Apex.outputLink link = new Component.Apex.outputLink(value='/'+id, title=id);	
			Component.Apex.outputText txt = new Component.Apex.outputText(value=id);
			
            link.childComponents.add(txt);
			pnl1.childComponents.add(link);
			pnl.childComponents.add(pnl1);
		}
		return pnl;
    }

 

All Answers

Deepak Kumar ShyoranDeepak Kumar Shyoran

Hi,

 

I think you want to show some text and also want to open the given link after clicking on that text. For that you have to put a text between <a></a>

 

<a href="https://na9.salesforce.com/001E000000iWHSLIA4" title="001E000000iWHSLIA4">Link 1</a>
  <a href="https://na9.salesforce.com/001E000000iWHSMIA4" title="001E000000iWHSMIA4">Link 2</a>

try above code you will get a clickable link on your page.

 

 

If this post helps you then hit kudus by clicking on star and accept my post as a solution to your question.

 

Mitesh SuraMitesh Sura
Thanks Deepak. I get that, but how should I have "Link 1" as part of dynamic component?

I would like it that to be defined here
Component.Apex.outputLink link = new Component.Apex.outputLink(value='/'+id, title=id);

Thank you for your time.
AshlekhAshlekh

Hi 

 

Try this code.

 

public Component.Apex.OutputPanel getLinks(){
      Component.Apex.OutputPanel pnl = new Component.Apex.OutputPanel();
      for(string id : recentItems) {
           Component.Apex.outputLink link = new Component.Apex.outputLink(value='/'+id, title=id); 
            Component.Apex.outputLabel outlab = new Component.Apex.outputLabel(value=id);
            link.childComponents.add(outlab);
           pnl.childComponents.add(link); 
       }
      return pnl;
}

 Thanks

Ashlekh

 

If this post helps you then mark it as a solution and don't Forget to give me Kudo's.

Mitesh SuraMitesh Sura

Thanks Ashlekh. 

 

I modified the code, because hand icon won't be shown when you hover. Also they were in straight line. 

 

public Component.Apex.OutputPanel getLinks(){
		Component.Apex.OutputPanel pnl = new Component.Apex.OutputPanel();
		for(string id : recentItems) {
			Component.Apex.outputPanel pnl1 = new Component.Apex.outputPanel(layout='block');
			Component.Apex.outputLink link = new Component.Apex.outputLink(value='/'+id, title=id);	
			Component.Apex.outputText txt = new Component.Apex.outputText(value=id);
			
            link.childComponents.add(txt);
			pnl1.childComponents.add(link);
			pnl.childComponents.add(pnl1);
		}
		return pnl;
    }

 

This was selected as the best answer
BerginBergin
I have related question on this.
<a href="mylink">Text </a>
How to set the property to get Link Text different from "mylink"?