简体   繁体   English

我可以在VF页面中基于布尔变量显示输出字段或输入字段吗

[英]Can i show an outputfield or inputfield based on a boolean variable in VF page

I have a boolean variable and based on whether this is true or false i want to show a field as inputfield or outputfield. 我有一个布尔变量,根据这是对还是错,我想将一个字段显示为inputfield或outputfield。

   {!IF(!Showinput), <apex:outputField value="{!a.field1__c}"/>, apex:inputField value="{!a.field1__c}"/>)}
   <apex:inputField value="{!a.field2__c}"/>

When i try to save i get a error 当我尝试保存时出现错误

  Error: Attribute value in <apex:inputField> must contain only a formula expression that resolves to a single controller variable or method

Is there any other way of achieving this 还有其他方法可以做到这一点

Specify both but use rendered attribute to control which one gets rendered 同时指定两者,但使用rendered属性控制要渲染的一个

<apex:outputField value="{!a.field1__c}" rendered="{!NOT(Showinput)}"/>
<apex:inputField value="{!a.field1__c}" rendered="{!Showinput}"/>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM