Salesforce visualforce中的重新渲染器和渲染属性
我用源代码编写了一个visualforce页面Salesforce visualforce中的重新渲染器和渲染属性,salesforce,apex-code,visualforce,Salesforce,Apex Code,Visualforce,我用源代码编写了一个visualforce页面 <apex:page controller="MyController1"> <apex:form> <apex:pageBlock > <apex:pageBlockSection id="search"> <apex:commandLink action="{!commandLinkAction}" value="Advance Search" reRender="thePanel" i
<apex:page controller="MyController1">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="search">
<apex:commandLink action="{!commandLinkAction}" value="Advance Search" reRender="thePanel" id="theCommandLink"/>
<apex:outputPanel id="thePanelWrapper">
<apex:outputPanel id="thePanel" rendered="{! rend}" layout="block">My div</apex:outputPanel>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
当我点击高级搜索链接时,什么都没有发生,但我希望id为“thePanel”的outputPanel应该呈现。为什么它没有呈现请有人解释一下???当你点击链接时,面板不在页面上,SF没有呈现它。当你点击链接时,面板不在页面上,SF未渲染它。请尝试以下代码
<apex:page controller="MyController1">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="search">
<apex:commandLink action="{!commandLinkAction}" value="Advance Search" reRender="thePanelWrapper" id="theCommandLink"/>
<apex:outputPanel id="thePanelWrapper">
<apex:outputPanel id="thePanel" rendered="{! rend}" layout="block">My div</apex:outputPanel>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class MyController1{
public Boolean rend{get;set;}
//setting the boolean to false in the constructor
public MyController1(){
rend = false;
}
public void commandLinkAction(){
rend=true;
// return null;
}
}
我的部门
公共类MyController1{
公共布尔rend{get;set;}
//在构造函数中将布尔值设置为false
公共MyController1(){
rend=false;
}
public void commandLinkAction(){
rend=真;
//返回null;
}
}
希望这有帮助 试试下面的代码
<apex:page controller="MyController1">
<apex:form>
<apex:pageBlock >
<apex:pageBlockSection id="search">
<apex:commandLink action="{!commandLinkAction}" value="Advance Search" reRender="thePanelWrapper" id="theCommandLink"/>
<apex:outputPanel id="thePanelWrapper">
<apex:outputPanel id="thePanel" rendered="{! rend}" layout="block">My div</apex:outputPanel>
</apex:outputPanel>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
public class MyController1{
public Boolean rend{get;set;}
//setting the boolean to false in the constructor
public MyController1(){
rend = false;
}
public void commandLinkAction(){
rend=true;
// return null;
}
}
我的部门
公共类MyController1{
公共布尔rend{get;set;}
//在构造函数中将布尔值设置为false
公共MyController1(){
rend=false;
}
public void commandLinkAction(){
rend=真;
//返回null;
}
}
希望这有帮助 正如@Shimshon所说,当从Visualforce生成HTML代码时,标记为
rendered=“false”
的Visualforce组件不会显示在生成的HTML文档中
在这种情况下:
<apex:outputPanel id="thePanel" rendered="{! rend}" layout="block">
如果此面板由rerender属性指向,则“面板捕捉器”及其子节点(“面板”)将被更新。正如@Shimshon所说,当从Visualforce生成HTML代码时,标记为
rendered=“false”
的Visualforce组件不会显示在生成的HTML文档中
在这种情况下:
<apex:outputPanel id="thePanel" rendered="{! rend}" layout="block">
如果此面板由rerender属性指向,则“面板捕捉器”及其子节点(“面板”)将被更新。+1但这是一个没有实际帮助的答案:)您能在此答案上展开一点吗?就像“必须呈现它,它最初可以隐藏(样式设置为‘可见性:无’或‘显示:隐藏’),但它需要在页面中有一个占位符,否则AJAX调用将不知道在何处注入新内容”;)+1但这是一个没有真正帮助的答案:)你能把这个答案扩展一下吗?就像“必须呈现它,它最初可以隐藏(样式设置为‘可见性:无’或‘显示:隐藏’),但它需要在页面中有一个占位符,否则AJAX调用将不知道在何处注入新内容”;)