将命令按钮作为输出文本的一部分
我的列表中有包装器类的对象,在我的 Vf 页面中,我检查包装器的对象是否包含 null,如果它包含 null,则我显示“空闲”,否则显示约会详细信息。
我想要一个按钮创建约会而不是“免费”。
插入按钮代码的正确方法是什么?
<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>
编辑: 在我阅读 mmmix 和 LaceySnr 的答案之前,我使用 css 类来实现。不确定这是否是最好的方法。但现在的问题是控制器方法上没有出现参数值。
<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>
<td><div Class="{!IF(ISNULL(slot.sAppointment), 'ShowButton', 'HideButton')}">
<apex:commandButton action="{!Book}" Value="Book">
<apex:param name="Timev" value="{!slot.tstart1}"/></apex:commandButton></div></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>
public PageReference Book()
{
String Timeval=ApexPages.CurrentPage().getParameters().get('Timev');
system.debug('timeval +++++++++++++++'+Timeval) ;// This is returning null
pr=Page.Appointment;
pr.setRedirect(true);
pr.getParameters().put('App_start',Timeval);
pr.getParameters().put('App_start_Date',string.valueof(Appointment.Start_Date__c));
return pr;
}
I have objects of wrapper class in a list and in my Vf page i am checking if the object of the wrapper contains null, if it has null then i am displaying 'Free' else displaying the appointment details.
I want to have a button create Appointment instead of 'Free'.
What would the correct way to insert the button code ?
<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>
EDIT :
Before i read the answers from mmmix and LaceySnr i implemented with use of css classes. not sure if this is the best way. But now the issue is of the param value not coming up on the controller method.
<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>
<td><div Class="{!IF(ISNULL(slot.sAppointment), 'ShowButton', 'HideButton')}">
<apex:commandButton action="{!Book}" Value="Book">
<apex:param name="Timev" value="{!slot.tstart1}"/></apex:commandButton></div></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>
public PageReference Book()
{
String Timeval=ApexPages.CurrentPage().getParameters().get('Timev');
system.debug('timeval +++++++++++++++'+Timeval) ;// This is returning null
pr=Page.Appointment;
pr.setRedirect(true);
pr.getParameters().put('App_start',Timeval);
pr.getParameters().put('App_start_Date',string.valueof(Appointment.Start_Date__c));
return pr;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定我是否理解有关按钮的事情,但您还有另一种执行 !IF 的方法,例如:
如果对于按钮,您正在考虑将 apex:commands 插入中继器并将事件处理程序绑定到特定行,则可以是通过参数完成,
例如,我使用它在每个表行中创建一个comamnd链接:
然后在事件处理程序中,您可以从页面参数中提取参数,例如
ApexPages.CurrentPage().getParameters().get('activeService')
另外,如果您想在 td 标记内呈现 if/then/else 文本/按钮,您可以使用此
Not sure I understand the thing about the button, but you also have an alternative way of doing !IF, for example:
If for button you are thinking about inserting apex:commands into a repeater and tie event handler to specific row, that can be done through parameters
for example I used this to crete a comamnd link in every table row:
Then in the event handler you can extract parameter from page parameters, for example
ApexPages.CurrentPage().getParameters().get('activeService')
Also, if you want to have if/then/else text/button rendering inside a td tag you can use this
我建议使用另一种机制来控制条件渲染。
对此效果很好,尽管没有专门为此目的而设计,例如,您可以将:更改为:
显然在这种情况下它生成了更多代码,但看看其余的代码我认为您可以(根据上下文)进一步将其归结为仅使用其中几个标签和更少的
rendered
属性。I'd suggest just using another mechanism for controlling the conditional rendering.
<apex:variable>
works well for this despite not being expressly designed for this purpose, for example, you could change:to:
Obviously in this case it's generated more code, but looking at the rest of this I think you could (with context) boil this down further to use just a couple of these tags and fewer
rendered
attributes.