如何解决如何将值从一个 VF 页面传递到另一个页面并刷新发送值的页面两个 VF 页面都将用作 Lightning 记录页面上的组件
我必须创建 2 个 VF 页面(casecreate 和 KNowledgeArticles) 两个组件都将放置在 Lighting Record 页面上,这些页面将用作组件 Case 创建页面是从 Status、Origin 和 Comments 传递和 Case 获取的位置创建的使用自定义控制器创建,我为两个 VF 页面使用相同的控制器
现在的需求是创建案例记录后,第二个Lightning组件(在Case Create下面)应该自动刷新,显示相关的新知识文章,我必须向Second Component发送评论值。
我还没有创建第二个组件,请告诉我如何实现它
我相信 PageReference 和 Redirect 不是这里的一个选项,因为这两个组件每次都会出现,每当传递新评论时,只有第二个组件会显示基于评论词的数据。
我试图在第一个组件中创建案例时实现,该组件工作正常,然后收集评论值并将其发送到下面的组件,即 KNowledgeArticles 并根据评论值使用 SOSL 显示文章。
组件 1 - VF 页面
状态 - 新
来源 - 网络
保存清除
组件 2 - VF 页面
使用包装类刷新并显示基于上述评论字段('错误')的前 3 篇文章
第 1 条
第 2 条
第 3 条
VF page - Create Case
<apex:page sidebar="false" showHeader="false" standardStylesheets="false" showChat="false" controller="CreateCaseController_CF" docType="html-5.0" >
<c:FrameworkBaseComponent_CF boolCFBaseStyle="true" boolCFDataTables="true" boolCFCharts="true" boolCFInputFiles="true" boolCFMultiSelects="true"
boolCFStyle="true" boolCFWizards="true" boolCFLightningAssets="true" />
<c:ValidationsComponent_CF ></c:ValidationsComponent_CF>
<script>
function passValueforStatus()
{
var e = document.getElementById("picklist1");
var strUser = e.options[e.selectedindex].value;
actfun(strUser);
console.log(strUser);
}
function passValueforOrigin()
{
var e = document.getElementById("picklist2");
var strUser = e.options[e.selectedindex].value;
origin(strUser);
console.log(strUser);
}
function passValueforComments()
{
var e = document.getElementById("validation1");
var strUser = e.value;
comments(strUser);
console.log(strUser);
}
</script>
<div class="row">
<div class="col-md-5">
<apex:form >
<apex:pageMessages />
<div class="panel-group collapsible-group card" data-chevron-down="glyphicon-chevron-down" data-chevron-up="glyphicon-chevron-up">
<div class="panel panel-default">
<div class="panel-heading" data-toggle="collapse" data-target="#collapse5">
<h4 class="panel-title">
<i class="glyphicon glyphicon-cog header-icon icon-electric-blue" />
Create Case
<i class="indicator glyphicon glyphicon-chevron-down pull-right" />
</h4>
</div>
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label for="picklist">Status</label>
<select class="form-control" id="picklist1" onchange="passValueforStatus();"
validation-activated="true" validate-required="true" validate-required-alert-type="4"
validate-required-error-message="required field."
validation-inline-message="true" validation-message-container="#validationContainer1">
<option value="" selected="selected" disabled="disabled">--None--</option>
<option value="New">New</option>
<option value="Escalated">Escalated</option>
<option value="Closed">Closed</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label for="picklist">Case Origin</label>
<select class="form-control" id="picklist2" onchange="passValueforOrigin();"
validation-activated="true" validate-required="true" validate-required-alert-type="4"
validate-required-error-message="required field."
validation-inline-message="true" validation-message-container="#validationContainer1">
<option value="" selected="selected" disabled="disabled">--None--</option>
<option value="Phone">Phone</option>
<option value="Email">Email</option>
<option value="Web">Web</option>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col-md-5">
<label for="validation1">Case Comments</label>
<input type="text" id="validation1" name="validation1" value="" class="form-control" placeholder="This is a placeholder."
validation-activated="true" validate-required="true" validate-required-alert-type="4"
validate-required-error-message="required field."
validate-minimum-length="3" validate-minimum-length-error-message="Minimum 3 characters."
validate-on-change="true"
validation-inline-message="true" validation-message-container="#validationContainer1" onkeyup="passValueforComments();"/>
</div>
</div>
<br/>
<div class="panel-footer">
<apex:commandButton styleClass="btn btn-default" onclick="validateFields();" value="Create Case" action="{!createCase}" rerender="none"></apex:commandButton>
<apex:commandButton styleClass="btn btn-default" Value="Clear"></apex:commandButton>
</div>
</div>
</div>
<apex:actionfunction name="actfun" action="{!contmethod}" rerender="frm">
<apex:param name="paramStatus" value="" assignTo="{!contvar}" />
</apex:actionfunction>
<apex:actionfunction name="origin" action="{!passOrigin}" rerender="frm">
<apex:param name="paramOrigin" value="" assignTo="{!originVar}" />
</apex:actionfunction>
<apex:actionfunction name="comments" action="{!passComments}" rerender="frm">
<apex:param name="paramComments" value="" assignTo="{!commentsVar}" />
</apex:actionfunction>
</apex:form>
</div>
</div>
</apex:page>
Controller
public with sharing class CreateCaseController_CF {
public String statusValue { get; set; }
public String originValue { get; set; }
public String currentRecordId {get;set;}
public String Comments { get; set; }
public sObject sobj1 {get;set;}
public String[] words{get;set;}
public List<wrapObj> selectedwrpList{get;set;}
public CreateCaseController_CF(){
currentRecordId = ApexPages.CurrentPage().getparameters().get('id');
system.debug('Record ID:'+currentRecordId);
System.debug('Triggered');
}
public PageReference createCase() {
sObject sobj1 = new Case();
sobj1.put('Origin',originValue);
sobj1.put('Status',statusValue);
sobj1.put('ContactId',currentRecordId);
sobj1.put('Description',Comments);
system.debug('Origin'+originValue);
system.debug('Status'+statusValue);
system.debug('ContactId'+currentRecordId);
system.debug(Comments);
system.debug('Case '+ sobj1);
DMLOperationResultClass_CF stringArray = DMLOperationsClass_CF.insertRecord(sobj1);
system.debug(stringArray.lstResults[0].boolWasCreated);
system.debug(stringArray.lstResults[0].lstErrorMessages);
List<DMLResultClass_CF> test = stringArray.lstResults;
system.debug(test);
PageReference p = new PageReference('/apex/KNowledgeArticle_CF');
p.setRedirect(false);
return p;
}
public PageReference passOrigin() {
originValue = apexpages.currentpage().getparameters().get('paramOrigin');
system.debug('Origin value' +originValue );
return null;
}
public PageReference contmethod() {
statusValue = apexpages.currentpage().getparameters().get('paramStatus');
system.debug('Status value' +statusValue );
return null;
}
public PageReference passComments() {
Comments = apexpages.currentpage().getparameters().get('paramComments');
system.debug('Comments value' +Comments );
return null;
}
public List<wrapObj> getArticles(){
words = Comments.split('\\s');
return selectedwrpList;
}
public class wrapObj{
public KNowLedge__kav article{get;set;}
public wrapObj(KNowLedge__kav k){
this.article = k;
}
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。