如何使用outputlink从visualforce页面提供指向记录的链接

时间:2011-10-20 01:07:43

标签: salesforce visualforce

有没有人可以帮助我在这种情况下提供链接

<apex:repeat var="slot" value="{!liTimeSlots}">

<tr class="{!IF(ISNULL(slot.sAppointment), 'Free', 'Fill')}">
    <td ><apex:outputText value="{!slot.tstart1}"/></td>

      <td><apex:outputText value="{!IF(ISNULL(slot.sAppointment), 'Free', slot.sAppointment.name)}"/></td>
      <td><apex:outputText value="{!IF(ISNULL(slot.sAppointment), '', slot.sAppointment.Appointment_Type__c)}"/></td>
      <td><apex:outputText value="{!IF(ISNULL(slot.sAppointment), '', slot.sAppointment.Patient__c)}"/></td>
        </tr> 
    <tr >
    <td></td>

      <td><apex:outputText value="{!IF(ISNULL(slot.sAppointmentOverlap), ' ', slot.sAppointmentOverlap.name)}"/></td>
      <td><apex:outputText value="{!IF(ISNULL(slot.sAppointmentOverlap), '', slot.sAppointmentOverlap.Appointment_Type__c)}"/></td>
      <td><apex:outputText value="{!IF(ISNULL(slot.sAppointmentOverlap), '', slot.sAppointmentOverlap.Patient__c)}"/></td>
        </tr>   
 </apex:repeat>

我想仅在slot.sAppointment或slot.sAppointmentOverlap不为空时显示链接。

任何想法如何解决这个问题。

由于

Prady

1 个答案:

答案 0 :(得分:4)

与几乎所有apex: Visualforce标记一样,apex:outputLink具有rendered属性,可用于显示或隐藏它,并且可以使用合并字段/公式价值,所以你将寻找以下内容:

<apex:outputLink value="url" rendered="{!NOT(ISNULL(slot.sAppointment)) || NOT(ISNULL(slow.AppointmentOverlap))}">The link</a>

我用于一组标记元素的条件渲染的另一个技巧是将它们包装在apex:variable标记中:

<apex:variable var="v" value="" rendered="{!ShouldThisRender}">
   <!-- Some page elements -->
</apex:outputVariable>