You need to sign in to do that
Don't have an account?
Saurabh Dhoble
Problem generating hyperlink inside a repeat
Folks,
I'm running into an issue putting hyperlinks inside a repeat object - please see below VF code -
<apex:outputPanel id="opnlSearchResult">
<apex:repeat value="{!searchResult}" var="contact">
<a href="#">
<h1>{!contact.Name}</h1>
<p>{!contact.Id}</p>
</a>
</apex:repeat>
</apex:outputPanel>
{!searchResult} is a list of type Contact.
I'm expecting this to generate a repeat of the following HTML :-
<a href="#">
<h1>Name1</h1>
<p>Id1</p>
</a>
<a href="#">
<h1>Name2</h1>
<p>Id2</p>
</a>
Instead, I'm getting -
<a href="#"></a>
<h1><a href="#">Name1</a></h1>
<p>Id1</p>
Basically, I want the header & paragraph to appear **inside** the hyperlink - this is required so they render correctly on mobile html5 pages. But Visualforce is somehow distorting the HTML.
Please help !!
I'm running into an issue putting hyperlinks inside a repeat object - please see below VF code -
<apex:outputPanel id="opnlSearchResult">
<apex:repeat value="{!searchResult}" var="contact">
<a href="#">
<h1>{!contact.Name}</h1>
<p>{!contact.Id}</p>
</a>
</apex:repeat>
</apex:outputPanel>
{!searchResult} is a list of type Contact.
I'm expecting this to generate a repeat of the following HTML :-
<a href="#">
<h1>Name1</h1>
<p>Id1</p>
</a>
<a href="#">
<h1>Name2</h1>
<p>Id2</p>
</a>
Instead, I'm getting -
<a href="#"></a>
<h1><a href="#">Name1</a></h1>
<p>Id1</p>
Basically, I want the header & paragraph to appear **inside** the hyperlink - this is required so they render correctly on mobile html5 pages. But Visualforce is somehow distorting the HTML.
Please help !!
<pre>
<apex:page standardController="Contact" recordSetVar="cons">
<apex:outputPanel id="opnlSearchResult">
<apex:repeat value="{!cons}" var="contact">
<a href="#">
<h1>{!contact.Name}</h1>
<p>{!contact.Id}</p>
</a>
</apex:repeat>
</apex:outputPanel>
</apex:page>
</pre>
You are right - it works as is. However, the problem is in the Ajax rendering part - try the below. The page renders correctly at first, but when you click the "Search" button the DOM gets modified, introducing the problem I mentioned above.
<apex:page standardController="Contact" recordSetVar="cons">
<apex:form>
<apex:commandButton id="searchButton" value="Search" reRender="opnlSearchResult"
html-data-inline="true" />
<apex:outputPanel id="opnlSearchResult">
<apex:repeat value="{!cons}" var="contact">
<a href="#">
<h1>{!contact.Name}</h1>
<p>{!contact.Id}</p>
</a>
</apex:repeat>
</apex:outputPanel>
</apex:form>
</apex:page>
Any ideas ?
Thx.
and have a case open at Salesforce. If I receive an answer I will let you know!!