Javascript 公共字符串不是从select元素设置的,而是从输入框设置的
我觉得我的大脑要爆炸了。请帮忙 我有一个select元素,其中包含从类别列表标准组件加载的选项。它的值为Group:{!groupCategory},表示它在自定义控制器上的公共字符串 我有一个apex:inputText组件,其值为{!searchString},它引用了自定义控制器上的公共字符串 我有一个apex:commandButton组件,它重新提交一个面板组,该面板组从knowledge:articlelist组件编写我的文章 我的问题是{!groupCategory}没有从我的select元素接收所选的选项值(假设),但是当我使用javascript记录select元素值时,它会返回所选选项的值 奇怪的是,{!searchString}值是由knowledge:articlelist组件设置和读取的 注意:我从控制器中删除了currentPagenumber计算以保持简单,我看不出它与当前问题有什么关系。另外,我使用的是标准的HTMLSelect元素,与apex selectlist组件相反,因为knowledge:categorylist不能嵌套在selectlist中 关键字搜索控制器:Javascript 公共字符串不是从select元素设置的,而是从输入框设置的,javascript,html,salesforce,visualforce,apex,Javascript,Html,Salesforce,Visualforce,Apex,我觉得我的大脑要爆炸了。请帮忙 我有一个select元素,其中包含从类别列表标准组件加载的选项。它的值为Group:{!groupCategory},表示它在自定义控制器上的公共字符串 我有一个apex:inputText组件,其值为{!searchString},它引用了自定义控制器上的公共字符串 我有一个apex:commandButton组件,它重新提交一个面板组,该面板组从knowledge:articlelist组件编写我的文章 我的问题是{!groupCategory}没有从我的se
public with sharing class KeywordSearchController {
//Page Size
private Static Final Integer PAGE_NUMBER = 5;
//Search String used in ArticleList tag
public String groupCategory { get; set; }
public String searchstring { get; set; }
public KeywordSearchController() {
String qryString = 'SELECT Id, title, UrlName,
LastPublishedDate,LastModifiedById FROM KnowledgeArticleVersion WHERE
(PublishStatus = \'online\' and Language = \'en_US\')';
List<KnowledgeArticleVersion> articleList= Database.query(qryString);
maxSize = articleList.size() ;
}
<apex:page showHeader="false" standardStyleSheets="false" controller="KeywordSearchController">
<apex:form>
<select id="groupSelect" value="{!groupCategory}">
<knowledge:categoryList categoryVar="category" categoryGroup="Group" rootCategory="All" level="-1">
<option value="Group:{!category.name}">{!category.label}</option>
</knowledge:categoryList>
</select>
<div class="field is-grouped">
<p class="control is-expanded has-icons-left">
<apex:inputText styleClass="input is-medium" value="{!searchstring}" />
<span class="icon is-left">
<i class="fa fa-search"></i>
</span>
</p>
<p class="control">
<apex:commandButton value="Search" id="submitButton" styleClass="button is-primary is-medium" reRender="theSearchResults"/>
</p>
</div>
</apex:form>
<apex:form >
<apex:messages />
<apex:pageBlock title="">
<apex:panelGroup id="theSearchResults" >
<apex:panelGrid width="100%">
<table class="table is-striped is-narrow">
<thead>
<tr>
<th>Title</th>
<th>Article Type</th>
<th>Summary</th>
</tr>
</thead>
<knowledge:articleList articleVar="article" categories="{!groupCategory}"
pageNumber="{!currentPageNumber}" Keyword="{!searchstring}"
hasMoreVar="false" pageSize="5">
<tbody>
<tr>
<td>
<apex:outputLink target="" value="{!URLFOR($Action.KnowledgeArticle.View, article.id,['popup' = 'false'])}">{!article.title}</apex:outputLink>
</td>
<td><apex:outputText >{!article.articleTypeLabel}</apex:outputText></td>
<td><apex:outputText >{!article.abstract}</apex:outputText></td>
</tr>
</tbody>
</knowledge:articleList>
</table>
</apex:panelGrid>
</apex:panelGroup>
</apex:pageBlock>
</apex:form>
public与共享类关键字searchcontroller{
//页面大小
私有静态最终整数页码=5;
//ArticleList标记中使用的搜索字符串
公共字符串groupCategory{get;set;}
公共字符串搜索字符串{get;set;}
公钥SearchController(){
String qryString='选择Id、标题、URL名称,
LastPublishedDate,来自KnowledgeArticleVersion的LastModifiedById,其中
(PublishStatus=\'online\'和Language='en\'U US\');
List articleList=Database.query(qryString);
maxSize=articleList.size();
}
视觉力页面:
public with sharing class KeywordSearchController {
//Page Size
private Static Final Integer PAGE_NUMBER = 5;
//Search String used in ArticleList tag
public String groupCategory { get; set; }
public String searchstring { get; set; }
public KeywordSearchController() {
String qryString = 'SELECT Id, title, UrlName,
LastPublishedDate,LastModifiedById FROM KnowledgeArticleVersion WHERE
(PublishStatus = \'online\' and Language = \'en_US\')';
List<KnowledgeArticleVersion> articleList= Database.query(qryString);
maxSize = articleList.size() ;
}
<apex:page showHeader="false" standardStyleSheets="false" controller="KeywordSearchController">
<apex:form>
<select id="groupSelect" value="{!groupCategory}">
<knowledge:categoryList categoryVar="category" categoryGroup="Group" rootCategory="All" level="-1">
<option value="Group:{!category.name}">{!category.label}</option>
</knowledge:categoryList>
</select>
<div class="field is-grouped">
<p class="control is-expanded has-icons-left">
<apex:inputText styleClass="input is-medium" value="{!searchstring}" />
<span class="icon is-left">
<i class="fa fa-search"></i>
</span>
</p>
<p class="control">
<apex:commandButton value="Search" id="submitButton" styleClass="button is-primary is-medium" reRender="theSearchResults"/>
</p>
</div>
</apex:form>
<apex:form >
<apex:messages />
<apex:pageBlock title="">
<apex:panelGroup id="theSearchResults" >
<apex:panelGrid width="100%">
<table class="table is-striped is-narrow">
<thead>
<tr>
<th>Title</th>
<th>Article Type</th>
<th>Summary</th>
</tr>
</thead>
<knowledge:articleList articleVar="article" categories="{!groupCategory}"
pageNumber="{!currentPageNumber}" Keyword="{!searchstring}"
hasMoreVar="false" pageSize="5">
<tbody>
<tr>
<td>
<apex:outputLink target="" value="{!URLFOR($Action.KnowledgeArticle.View, article.id,['popup' = 'false'])}">{!article.title}</apex:outputLink>
</td>
<td><apex:outputText >{!article.articleTypeLabel}</apex:outputText></td>
<td><apex:outputText >{!article.abstract}</apex:outputText></td>
</tr>
</tbody>
</knowledge:articleList>
</table>
</apex:panelGrid>
</apex:panelGroup>
</apex:pageBlock>
</apex:form>
{!category.label}
标题
物品类型
总结
{!文章标题}
{!article.articleTypeLabel}
{!article.abstract}
您应该使用标记,而不是标准html标记。标准html标记没有内置的集合绑定,只有一个。使用标准的select元素肯定是有用的。使用selectList设置{!groupcategory}字符串的值效果很好(手动键入每个选项)。这对保持动态不太实际。感谢您的回复,但我不理解您的回答。当您说tag时,您指的是salesforce标准组件吗?当您说没有内置绑定时,您是什么意思?