代码之家  ›  专栏  ›  技术社区  ›  S.B.

公共字符串不是从select元素设置的,而是从输入框设置的

  •  0
  • S.B.  · 技术社区  · 7 年前

    我觉得我的大脑要爆炸了。请帮忙。

    我有一个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>
    
    1 回复  |  直到 7 年前
        1
  •  0
  •   Matt Kaufman    7 年前