我觉得我的大脑要爆炸了。请帮忙。
我有一个apex:inputText组件,其值为{!searchString},表示它在我的自定义控制器上的公共字符串。
奇怪的是{!searchString}值是由knowledge:articlelist组件设置和读取的。
注意:为了简单起见,我从控制器中删除了currentPagenumber计算,我看不出它与当前问题有什么关系。此外,我使用的是标准HTML select元素,与apex selectlist组件相反,因为knowledge:categorylist不能嵌套在selectlist中。
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>